Skip to content

Commit e6851c5

Browse files
enable app template case
1 parent 6b58605 commit e6851c5

File tree

3 files changed

+27
-96
lines changed

3 files changed

+27
-96
lines changed

packages/cli/test/cases/build.default.workspace-template-app/build.default.workspace-template-app.spec.js

+4-83
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ const { JSDOM } = require('jsdom');
2222
const path = require('path');
2323
const TestBed = require('../../../../../test/test-bed');
2424

25-
const mainBundleScriptRegex = /index.*.bundle\.js/;
26-
27-
xdescribe('Build Greenwood With: ', function() {
25+
describe('Build Greenwood With: ', function() {
2826
const LABEL = 'Default Greenwood Configuration and Workspace w/Custom App Template';
2927
let setup;
3028

@@ -40,85 +38,8 @@ xdescribe('Build Greenwood With: ', function() {
4038
await setup.runGreenwoodCommand('build');
4139
});
4240

43-
runSmokeTest(['public', 'not-found', 'hello'], LABEL);
44-
45-
describe('Custom Index (Home) page', function() {
46-
const indexPageHeading = 'Greenwood';
47-
const indexPageBody = 'This is the home page built by Greenwood. Make your own pages in src/pages/index.js!';
48-
let dom;
49-
50-
beforeEach(async function() {
51-
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html'));
52-
});
53-
54-
it('should have the default config title in the <title> tag in the <head>', function() {
55-
const title = dom.window.document.querySelector('head title').textContent;
56-
57-
expect(title).to.be.equal('My App');
58-
});
59-
60-
it('should have one <script> tag in the <body> for the main bundle', function() {
61-
const scriptTags = dom.window.document.querySelectorAll('body > script');
62-
const bundledScript = Array.prototype.slice.call(scriptTags).filter(script => {
63-
const src = script.src.replace('file:///', '');
64-
65-
return mainBundleScriptRegex.test(src);
66-
});
67-
68-
expect(bundledScript.length).to.be.equal(1);
69-
});
70-
71-
it('should have one <script> tag in the <body> for the main bundle loaded with async', function() {
72-
const scriptTags = dom.window.document.querySelectorAll('body > script');
73-
const bundledScript = Array.prototype.slice.call(scriptTags).filter(script => {
74-
const src = script.src.replace('file:///', '');
75-
76-
return mainBundleScriptRegex.test(src);
77-
});
78-
79-
expect(bundledScript[0].getAttribute('async')).to.be.equal('');
80-
});
81-
82-
it('should have one <script> tag for Apollo state', function() {
83-
const scriptTags = dom.window.document.querySelectorAll('script');
84-
const bundleScripts = Array.prototype.slice.call(scriptTags).filter(script => {
85-
return script.getAttribute('data-state') === 'apollo';
86-
});
87-
88-
expect(bundleScripts.length).to.be.equal(1);
89-
});
90-
91-
it('should have only one <script> tag in the <head>', function() {
92-
const scriptTags = dom.window.document.querySelectorAll('head > script');
93-
94-
expect(scriptTags.length).to.be.equal(1);
95-
});
96-
97-
it('should have a router outlet tag in the <body>', function() {
98-
const outlet = dom.window.document.querySelectorAll('body app-root');
99-
100-
expect(outlet.length).to.be.equal(1);
101-
});
102-
103-
// no 404 route in our custom app-template.js, like greenwood does
104-
it('should have the correct route tags in the <body>', function() {
105-
const routes = dom.window.document.querySelectorAll('body lit-route');
106-
107-
expect(routes.length).to.be.equal(2);
108-
});
109-
110-
it('should have the expected heading text within the index page in the public directory', function() {
111-
const heading = dom.window.document.querySelector('h3').textContent;
112-
113-
expect(heading).to.equal(indexPageHeading);
114-
});
115-
116-
it('should have the expected paragraph text within the index page in the public directory', function() {
117-
let paragraph = dom.window.document.querySelector('p').textContent;
118-
119-
expect(paragraph).to.equal(indexPageBody);
120-
});
121-
});
41+
// TODO runSmokeTest(['public', 'not-found', 'hello'], LABEL);
42+
runSmokeTest(['public', 'index'], LABEL);
12243

12344
describe('Custom App Template', function() {
12445
before(async function() {
@@ -130,7 +51,7 @@ xdescribe('Build Greenwood With: ', function() {
13051
});
13152

13253
it('should have the specific element we added as part of our custom app template', function() {
133-
const customParagraph = dom.window.document.querySelector('p#custom-app-template').textContent;
54+
const customParagraph = dom.window.document.querySelector('body p').textContent;
13455

13556
expect(customParagraph).to.equal('My Custom App Template');
13657
});

packages/cli/test/cases/build.default.workspace-template-app/src/templates/app-template.js

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en" prefix="og:http://ogp.me/ns#">
3+
4+
<head>
5+
<meta charset='utf-8'>
6+
<meta name='viewport' content='width=device-width, initial-scale=1'/>
7+
</head>
8+
9+
<body>
10+
11+
<div class='gwd-wrapper'>
12+
13+
<!-- TODO <lit-route><h1>404 Not found</h1></lit-route> -->
14+
15+
<p>My Custom App Template</p>
16+
17+
<page-outlet></page-outlet>
18+
19+
</div>
20+
21+
</body>
22+
23+
</html>

0 commit comments

Comments
 (0)