diff --git a/greenwood.config.js b/greenwood.config.js index 6744bc534..7e11126e4 100644 --- a/greenwood.config.js +++ b/greenwood.config.js @@ -1,5 +1,4 @@ const path = require('path'); -// const pluginImportCommonjs = require('./packages/plugin-import-commonjs/src/index'); const pluginGoogleAnalytics = require('./packages/plugin-google-analytics/src/index'); const pluginGraphQL = require('./packages/plugin-graphql/src/index'); const pluginImportCss = require('./packages/plugin-import-css/src/index'); @@ -26,7 +25,6 @@ module.exports = { { name: 'google-site-verification', content: '4rYd8k5aFD0jDnN0CCFgUXNe4eakLP4NnA18mNnK5P0' } ], plugins: [ - // ...pluginImportCommonjs(), pluginGoogleAnalytics({ analyticsId: 'UA-147204327-1' }), diff --git a/nyc.config.js b/nyc.config.js index 01c8dee0d..b56f00d50 100644 --- a/nyc.config.js +++ b/nyc.config.js @@ -4,9 +4,9 @@ module.exports = { include: [ 'packages/cli/src/commands/*.js', - 'packages/cli/src/data/*.js', 'packages/cli/src/lib/*.js', 'packages/cli/src/lifecycles/*.js', + 'packages/cli/src/plugins/*.js', 'packages/plugin-*/src/*.js' ], @@ -17,12 +17,12 @@ module.exports = { 'text-summary' ], - checkCoverage: false, // TODO renable + checkCoverage: true, - statements: 85, - branches: 75, - functions: 90, - lines: 85, + statements: 80, + branches: 65, + functions: 85, + lines: 80, watermarks: { statements: [75, 85], diff --git a/packages/cli/src/config/rollup.config.js b/packages/cli/src/config/rollup.config.js index 262650b37..785aa675f 100644 --- a/packages/cli/src/config/rollup.config.js +++ b/packages/cli/src/config/rollup.config.js @@ -80,7 +80,6 @@ function greenwoodWorkspaceResolver (compilation) { return { name: 'greenwood-workspace-resolver', resolveId(source) { - // TODO better way to handle relative paths? happens in generateBundle too if ((source.indexOf('./') === 0 || source.indexOf('/') === 0) && path.extname(source) !== '.html' && fs.existsSync(path.join(userWorkspace, source))) { return source.replace(source, path.join(userWorkspace, source)); } @@ -126,7 +125,6 @@ function greenwoodHtmlPlugin(compilation) { : null; }))).filter(resource => resource); - // TODO should reduce here instead if (resourceHandler.length) { const response = await resourceHandler[0].serve(id); @@ -153,8 +151,7 @@ function greenwoodHtmlPlugin(compilation) { }); const headScripts = root.querySelectorAll('script'); const headLinks = root.querySelectorAll('link'); - - // TODO handle deeper paths. e.g. ../../../ + headScripts.forEach((scriptTag) => { const parsedAttributes = parseTagForAttributes(scriptTag); @@ -165,9 +162,6 @@ function greenwoodHtmlPlugin(compilation) { } else { const { src } = parsedAttributes; - // TODO avoid using href and set it to the value of rollup fileName instead - // since user paths can still be the same file, - // e.g. ../theme.css and ./theme.css are still the same file mappedScripts.set(src, true); const srcPath = src.replace('../', './'); @@ -196,12 +190,7 @@ function greenwoodHtmlPlugin(compilation) { ${scriptTag.rawText} `.trim(); - // have to write a file for rollup? fs.writeFileSync(path.join(scratchDir, filename), source); - - // TODO avoid using href and set it to the value of rollup fileName instead - // since user paths can still be the same file, - // e.g. ../theme.css and ./theme.css are still the same file mappedScripts.set(id, true); this.emitFile({ @@ -225,7 +214,6 @@ function greenwoodHtmlPlugin(compilation) { href = href.slice(1); } - // TODO handle auto expanding deeper paths const basePath = href.indexOf(tokenNodeModules) >= 0 ? projectDirectory : userWorkspace; @@ -244,9 +232,6 @@ function greenwoodHtmlPlugin(compilation) { }); } - // TODO avoid using href and set it to the value of rollup fileName instead - // since user paths can still be the same file, - // e.g. ../theme.css and ./theme.css are still the same file mappedStyles[parsedAttributes.href] = { type: 'asset', fileName: fileName.indexOf(tokenNodeModules) >= 0 @@ -298,7 +283,6 @@ function greenwoodHtmlPlugin(compilation) { try { const bundle = bundles[bundleId]; - // TODO handle (!) Generated empty chunks .greenwood/about, .greenwood/index if (bundle.isEntry && path.extname(bundle.facadeModuleId) === '.html') { const html = fs.readFileSync(bundle.facadeModuleId, 'utf-8'); const root = htmlparser.parse(html, { @@ -373,7 +357,6 @@ function greenwoodHtmlPlugin(compilation) { } }); - // TODO this seems hacky; hardcoded dirs :D bundle.fileName = bundle.facadeModuleId.replace('.greenwood', 'public'); bundle.code = newHtml; } @@ -390,7 +373,6 @@ function greenwoodHtmlPlugin(compilation) { const bundle = bundles[bundleId]; if (bundle.isEntry && path.extname(bundle.facadeModuleId) === '.html') { - // TODO this seems hacky; hardcoded dirs :D const htmlPath = bundle.facadeModuleId.replace('.greenwood', 'public'); let html = fs.readFileSync(htmlPath, 'utf-8'); const root = htmlparser.parse(html, { @@ -478,17 +460,15 @@ function greenwoodHtmlPlugin(compilation) { module.exports = getRollupConfig = async (compilation) => { const { scratchDir, outputDir } = compilation.context; const defaultRollupPlugins = [ - // TODO replace should come in via plugin-node-modules replace({ // https://github.com/rollup/rollup/issues/487#issuecomment-177596512 'process.env.NODE_ENV': JSON.stringify('production') }), - nodeResolve(), // TODO move to plugin-node-modules + nodeResolve(), greenwoodWorkspaceResolver(compilation), greenwoodHtmlPlugin(compilation), multiInput(), - json() // TODO make it part plugin-standard-json + json() ]; - // TODO greenwood standard plugins, then "Greenwood" plugins, then user plugins const customRollupPlugins = compilation.config.plugins.filter((plugin) => { return plugin.type === 'rollup'; }).map((plugin) => { @@ -497,12 +477,11 @@ module.exports = getRollupConfig = async (compilation) => { if (compilation.config.optimization !== 'none') { defaultRollupPlugins.push( - terser() // TODO extract to plugin-standard-javascript + terser() ); } return [{ - // TODO Avoid .greenwood/ directory, do everything in public/? input: `${scratchDir}**/*.html`, output: { dir: outputDir, diff --git a/packages/cli/src/index.js b/packages/cli/src/index.js index ed1d16f4b..876d5244a 100755 --- a/packages/cli/src/index.js +++ b/packages/cli/src/index.js @@ -5,8 +5,6 @@ // https://github.com/ProjectEvergreen/greenwood/issues/141 process.setMaxListeners(0); -// TODO require('colors'); - const program = require('commander'); const runProductionBuild = require('./commands/build'); const runDevServer = require('./commands/develop'); @@ -17,10 +15,6 @@ const greenwoodPackageJson = require('../package.json'); let cmdOption = {}; let command = ''; -// TODO -// console.log(`${chalk.rgb(175, 207, 71)('-------------------------------------------------------')}`); -// console.log(`${chalk.rgb(175, 207, 71)('Welcome to Greenwood ♻️')}`); -// console.log(`${chalk.rgb(175, 207, 71)('-------------------------------------------------------')}`); console.info('-------------------------------------------------------'); console.info('Welcome to Greenwood ♻️'); console.info('-------------------------------------------------------'); @@ -29,7 +23,6 @@ program .version(greenwoodPackageJson.version) .arguments('') .usage(' [options]'); -// TODO .usage(`${chalk.green('')} [options]`); program .command('build') @@ -63,7 +56,6 @@ program program.parse(process.argv); -// TODO pick build by default? Thinking of npx usage... if (program.parse.length === 0) { program.help(); } diff --git a/packages/cli/src/lib/browser.js b/packages/cli/src/lib/browser.js index 96909c12d..0ed78ff5b 100644 --- a/packages/cli/src/lib/browser.js +++ b/packages/cli/src/lib/browser.js @@ -36,23 +36,19 @@ class BrowserRunner { await page.setRequestInterception(true); - // only allow puppeteer to load necessary scripts needed for pre-rendering of the site itself + // only allow puppeteer to load necessary (local) scripts needed for pre-rendering of the site itself page.on('request', interceptedRequest => { - // const interceptedRequestUrl = interceptedRequest.url(); - - // console.debug('request', interceptedRequestUrl); - // TODO handle serialize only requests - interceptedRequest.continue(); - // if ( - // interceptedRequestUrl.indexOf('bundle.js') >= 0 || // webpack bundles, webcomponents-bundle.js - // interceptedRequestUrl === requestUrl || // pages / routes - // interceptedRequestUrl.indexOf('localhost:4000') >= 0 // Apollo GraphQL server - // ) { - // interceptedRequest.continue(); - // } else { - // console.debug('aborting request', interceptedRequestUrl) - // interceptedRequest.abort(); - // } + const interceptedRequestUrl = interceptedRequest.url(); + + if ( + interceptedRequestUrl.indexOf('http://127.0.0.1') >= 0 || + interceptedRequestUrl.indexOf('localhost') >= 0 + ) { + interceptedRequest.continue(); + } else { + // console.warn('aborting request', interceptedRequestUrl); + interceptedRequest.abort(); + } }); try { diff --git a/packages/cli/src/lib/router.js b/packages/cli/src/lib/router.js index 12ac91e80..31970d670 100644 --- a/packages/cli/src/lib/router.js +++ b/packages/cli/src/lib/router.js @@ -3,20 +3,16 @@ document.addEventListener('click', function(e) { e.preventDefault(); if (e.path[0].href) { - console.debug('linked clicked was...', e.path[0].href); const target = e.path[0]; const route = target.href.replace(window.location.origin, ''); const routerOutlet = Array.from(document.getElementsByTagName('greenwood-route')).filter(outlet => { return outlet.getAttribute('data-route') === route; })[0]; - console.debug('routerOutlet', routerOutlet); - if (routerOutlet.getAttribute('data-template') === window.__greenwood.currentTemplate) { window.__greenwood.currentTemplate = routerOutlet.getAttribute('data-template'); routerOutlet.loadRoute(); } else { - console.debug('new template detected, should do a hard reload'); window.location.href = target; } } @@ -26,8 +22,7 @@ class RouteComponent extends HTMLElement { loadRoute() { const route = this.getAttribute('data-route'); const key = this.getAttribute('data-key'); - console.debug('load route ->', route); - console.debug('with bundle ->', key); + fetch(key) .then(res => res.text()) .then((response) => { diff --git a/packages/cli/src/lifecycles/compile.js b/packages/cli/src/lifecycles/compile.js index d658d1142..80fc0adf1 100644 --- a/packages/cli/src/lifecycles/compile.js +++ b/packages/cli/src/lifecycles/compile.js @@ -1,4 +1,3 @@ -// TODO require('colors'); const initConfig = require('./config'); const initContext = require('./context'); const generateGraph = require('./graph'); @@ -21,7 +20,6 @@ module.exports = generateCompilation = () => { compilation.context = await initContext(compilation); // generate a graph of all pages / components to build - // TODO make this async somehow / run in parallel? console.info('Generating graph of workspace files...'); compilation = await generateGraph(compilation); diff --git a/packages/cli/src/lifecycles/copy.js b/packages/cli/src/lifecycles/copy.js index d6d0aea0a..6c41c8541 100644 --- a/packages/cli/src/lifecycles/copy.js +++ b/packages/cli/src/lifecycles/copy.js @@ -65,7 +65,6 @@ module.exports = copyAssets = (compilation) => { } } - // TODO should be done via rollup detection, so Greenwood will only copy files used when actually imported by the user console.info('copying graph.json...'); await copyFile(`${context.scratchDir}graph.json`, `${context.outputDir}/graph.json`); diff --git a/packages/cli/src/lifecycles/serve.js b/packages/cli/src/lifecycles/serve.js index 8a41808bb..5b99b8772 100644 --- a/packages/cli/src/lifecycles/serve.js +++ b/packages/cli/src/lifecycles/serve.js @@ -165,7 +165,6 @@ function getProdServer(compilation) { ctx.body = contents; } - // TODO break up into distinct font / icons / svg handlers, decouple from to assets/ if (url.indexOf('assets/')) { const assetPath = path.join(outputDir, url); const ext = path.extname(assetPath); diff --git a/packages/cli/src/plugins/resource/plugin-standard-font.js b/packages/cli/src/plugins/resource/plugin-standard-font.js index ec898b57d..5632c31b5 100644 --- a/packages/cli/src/plugins/resource/plugin-standard-font.js +++ b/packages/cli/src/plugins/resource/plugin-standard-font.js @@ -11,7 +11,7 @@ const { ResourceInterface } = require('../../lib/resource-interface'); class StandardFontResource extends ResourceInterface { constructor(compilation, options) { super(compilation, options); - this.extensions = ['.woff2', '.woff', '.ttf']; // TODO support more types? + this.extensions = ['.woff2', '.woff', '.ttf']; } async serve(url) { diff --git a/packages/cli/src/plugins/resource/plugin-standard-html.js b/packages/cli/src/plugins/resource/plugin-standard-html.js index 46a1cf79c..74fe515c3 100644 --- a/packages/cli/src/plugins/resource/plugin-standard-html.js +++ b/packages/cli/src/plugins/resource/plugin-standard-html.js @@ -16,7 +16,6 @@ const remarkRehype = require('remark-rehype'); const { ResourceInterface } = require('../../lib/resource-interface'); const unified = require('unified'); -// TODO better error handling / messaging for users if things are not where they are expected to be // general refactoring const getPageTemplate = (barePath, workspace, template) => { const templatesDir = path.join(workspace, 'templates'); @@ -118,8 +117,6 @@ const getAppTemplate = (contents, userWorkspace) => { const getUserScripts = (contents) => { if (process.env.__GWD_COMMAND__ === 'build') { // eslint-disable-line no-underscore-dangle - // TODO setup and teardown should be done together - // console.debug('running in build mode, polyfill WebComponents for puppeteer'); contents = contents.replace('', ` @@ -133,7 +130,6 @@ const getMetaContent = (url, config, contents) => { const metaContent = config.meta.map(item => { let metaHtml = ''; - // TODO better way to implememnt this? should we implement this? for (const [key, value] of Object.entries(item)) { const isOgUrl = item.property === 'og:url' && key === 'content'; const hasTrailingSlash = isOgUrl && value[value.length - 1] === '/'; @@ -151,7 +147,6 @@ const getMetaContent = (url, config, contents) => { : ``; }).join('\n'); - // TODO make smarter so that if it already exists, then leave it alone contents = contents.replace(/(.*)<\/title>/, ''); contents = contents.replace('<head>', `<head><title>${title}`); contents = contents.replace('', metaContent); @@ -219,7 +214,6 @@ class StandardHtmlResource extends ResourceInterface { } }); - // TODO extract front matter contents from remark-frontmatter instead of frontmatter lib const settings = config.markdown.settings || {}; const fm = frontmatter(markdownContents); processedMarkdown = await unified() diff --git a/packages/cli/src/plugins/resource/plugin-standard-javascript.js b/packages/cli/src/plugins/resource/plugin-standard-javascript.js index b20fa1d46..b46012a5e 100644 --- a/packages/cli/src/plugins/resource/plugin-standard-javascript.js +++ b/packages/cli/src/plugins/resource/plugin-standard-javascript.js @@ -28,8 +28,6 @@ class StandardJavaScriptResource extends ResourceInterface { } }); } - - // TODO pptional optimize w/ terser (not rollup) } module.exports = { diff --git a/packages/cli/src/plugins/resource/plugin-standard-json.js b/packages/cli/src/plugins/resource/plugin-standard-json.js index b1a38d458..42d5bd208 100644 --- a/packages/cli/src/plugins/resource/plugin-standard-json.js +++ b/packages/cli/src/plugins/resource/plugin-standard-json.js @@ -22,14 +22,12 @@ class StandardJsonResource extends ResourceInterface { let contentType = ''; const { context } = this.compilation; - // TODO should be its own plugin / package, as part of data if (url.indexOf('graph.json') >= 0) { const json = await fs.promises.readFile(path.join(context.scratchDir, 'graph.json'), 'utf-8'); contentType = 'application/json'; body = JSON.parse(json); } else { - // TODO should be its own plugin / package const json = await fs.promises.readFile(url, 'utf-8'); contentType = 'text/javascript'; @@ -45,8 +43,6 @@ class StandardJsonResource extends ResourceInterface { } }); } - - // TODO include rollup json plugin support } module.exports = { diff --git a/packages/cli/test/cases/build.config.default/build.config.default.spec.js b/packages/cli/test/cases/build.config.default/build.config.default.spec.js index ab4e1d7b3..7445bb1ea 100644 --- a/packages/cli/test/cases/build.config.default/build.config.default.spec.js +++ b/packages/cli/test/cases/build.config.default/build.config.default.spec.js @@ -18,7 +18,7 @@ const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { - const LABEL = 'Empty Configuration and Default Workspace'; + const LABEL = 'Empty User Configuration and No Workspace'; let setup; before(async function() { @@ -30,7 +30,7 @@ describe('Build Greenwood With: ', function() { before(async function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found', 'hello'], LABEL); + runSmokeTest(['public', 'index'], LABEL); }); diff --git a/packages/cli/test/cases/build.config.error-theme-file/build.config.error-theme-file.spec.js b/packages/cli/test/cases/build.config.error-theme-file/build.config.error-theme-file.spec.js deleted file mode 100644 index 17694e3d4..000000000 --- a/packages/cli/test/cases/build.config.error-theme-file/build.config.error-theme-file.spec.js +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Use Case - * Run Greenwood build command with a bad value for themeFile in a custom config. - * - * User Result - * Should throw an error. - * - * User Command - * greenwood build - * - * User Config - * { - * themeFile: '{}' - * } - * - * User Workspace - * Greenwood default - */ -const expect = require('chai').expect; -const TestBed = require('../../../../../test/test-bed'); - -xdescribe('Build Greenwood With: ', function() { - let setup; - - before(async function() { - setup = new TestBed(); - await setup.setupTestBed(__dirname); - }); - - describe('Custom Configuration with a bad value for theme file', function() { - it('should throw an error that themeFile must be a filename', async function() { - try { - await setup.runGreenwoodCommand('build'); - } catch (err) { - expect(err).to.contain('Error: greenwood.config.js themeFile must be a valid filename. got {} instead.'); - } - }); - }); - - after(function() { - setup.teardownTestBed(); - }); - -}); \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.error-theme-file/greenwood.config.js b/packages/cli/test/cases/build.config.error-theme-file/greenwood.config.js deleted file mode 100644 index 49b96e59a..000000000 --- a/packages/cli/test/cases/build.config.error-theme-file/greenwood.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - themeFile: '{}' -}; \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.markdown-custom.plugins/build.config.markdown-custom.spec.js b/packages/cli/test/cases/build.config.markdown-custom.plugins/build.config.markdown-custom.spec.js index 4873c4489..831473367 100644 --- a/packages/cli/test/cases/build.config.markdown-custom.plugins/build.config.markdown-custom.spec.js +++ b/packages/cli/test/cases/build.config.markdown-custom.plugins/build.config.markdown-custom.spec.js @@ -41,7 +41,6 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Custom Markdown Plugins', function() { diff --git a/packages/cli/test/cases/build.config.meta/build.config.meta.spec.js b/packages/cli/test/cases/build.config.meta/build.config.meta.spec.js index 114749008..ff99f4bc1 100644 --- a/packages/cli/test/cases/build.config.meta/build.config.meta.spec.js +++ b/packages/cli/test/cases/build.config.meta/build.config.meta.spec.js @@ -37,8 +37,6 @@ const expect = require('chai').expect; const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); -const mainBundleScriptRegex = /index.*.bundle\.js/; - describe('Build Greenwood With: ', function() { const LABEL = 'Custom Meta Configuration and Nested Workspace'; const meta = greenwoodConfig.meta; @@ -62,75 +60,21 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - runSmokeTest(['public'], LABEL); + runSmokeTest(['public', 'index'], LABEL); - // hardcoding index smoke test here because of the nested route describe('Index (home) page with custom meta data', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, './index.html')); }); - it('should output an index.html file within the default hello page directory', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; - }); - it('should have a tag in the <head>', function() { const title = dom.window.document.querySelector('head title').textContent; expect(title).to.be.equal(greenwoodConfig.title); }); - xit('should have one <script> tag in the <body> for the main bundle', function() { - const scriptTags = dom.window.document.querySelectorAll('body > script'); - const bundledScript = Array.prototype.slice.call(scriptTags).filter(script => { - const src = script.src.replace('file:///', ''); - - return mainBundleScriptRegex.test(src); - }); - - expect(bundledScript.length).to.be.equal(1); - }); - - xit('should have one <script> tag in the <body> for the main bundle loaded with async', function() { - const scriptTags = dom.window.document.querySelectorAll('body > script'); - const bundledScript = Array.prototype.slice.call(scriptTags).filter(script => { - const src = script.src.replace('file:///', ''); - - return mainBundleScriptRegex.test(src); - }); - - expect(bundledScript[0].getAttribute('async')).to.be.equal(''); - }); - - xit('should have one <script> tag for Apollo state', function() { - const scriptTags = dom.window.document.querySelectorAll('script'); - const bundleScripts = Array.prototype.slice.call(scriptTags).filter(script => { - return script.getAttribute('data-state') === 'apollo'; - }); - - expect(bundleScripts.length).to.be.equal(1); - }); - - xit('should have only one <script> tag in the <head>', function() { - const scriptTags = dom.window.document.querySelectorAll('head > script'); - - expect(scriptTags.length).to.be.equal(1); - }); - - xit('should have a router outlet tag in the <body>', function() { - const outlet = dom.window.document.querySelectorAll('body eve-app'); - - expect(outlet.length).to.be.equal(1); - }); - - xit('should have the correct route tags in the <body>', function() { - const routes = dom.window.document.querySelectorAll('body lit-route'); - - expect(routes.length).to.be.equal(4); - }); - it('should have the expected heading text within the index page in the public directory', function() { const indexPageHeading = 'Greenwood'; const heading = dom.window.document.querySelector('h3').textContent; @@ -170,7 +114,7 @@ describe('Build Greenwood With: ', function() { describe('Nested About page meta data', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'about', './index.html')); }); @@ -203,7 +147,7 @@ describe('Build Greenwood With: ', function() { describe('favicon', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, './index.html')); }); diff --git a/packages/cli/test/cases/build.config.optimization-default/src/pages/index.html b/packages/cli/test/cases/build.config.optimization-default/src/pages/index.html index 21b948d1b..57ef25887 100644 --- a/packages/cli/test/cases/build.config.optimization-default/src/pages/index.html +++ b/packages/cli/test/cases/build.config.optimization-default/src/pages/index.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="/components/header.js"></script> <link rel="stylesheet" href="/styles/theme.css"></link> </head> diff --git a/packages/cli/test/cases/build.config.optimization-inline/src/pages/index.html b/packages/cli/test/cases/build.config.optimization-inline/src/pages/index.html index 21b948d1b..57ef25887 100644 --- a/packages/cli/test/cases/build.config.optimization-inline/src/pages/index.html +++ b/packages/cli/test/cases/build.config.optimization-inline/src/pages/index.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="/components/header.js"></script> <link rel="stylesheet" href="/styles/theme.css"></link> </head> diff --git a/packages/cli/test/cases/build.config.optimization-none/src/pages/index.html b/packages/cli/test/cases/build.config.optimization-none/src/pages/index.html index 21b948d1b..57ef25887 100644 --- a/packages/cli/test/cases/build.config.optimization-none/src/pages/index.html +++ b/packages/cli/test/cases/build.config.optimization-none/src/pages/index.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="/components/header.js"></script> <link rel="stylesheet" href="/styles/theme.css"></link> </head> diff --git a/packages/cli/test/cases/build.config.optimization-static/src/pages/index.html b/packages/cli/test/cases/build.config.optimization-static/src/pages/index.html index 86d853701..44c18d455 100644 --- a/packages/cli/test/cases/build.config.optimization-static/src/pages/index.html +++ b/packages/cli/test/cases/build.config.optimization-static/src/pages/index.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="/components/header.js"></script> </head> diff --git a/packages/cli/test/cases/build.config.theme/build.config.theme.spec.js b/packages/cli/test/cases/build.config.theme/build.config.theme.spec.js deleted file mode 100644 index 9e5a0899b..000000000 --- a/packages/cli/test/cases/build.config.theme/build.config.theme.spec.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Use Case - * Run Greenwood with a custom themeFile file in config and default workspace with a page template. - * - * User Result - * Should generate a bare bones Greenwood build. (same as build.default.spec.js) with custom theme styles - * - * User Command - * greenwood build - * - * User Config - * { - * title: 'My Custom Greenwood App' - * } - * - * User Workspace - * Greenwood default - * src/ - * templates/ - * page-template.js - * styles/ - * my-brand.css - */ -const fs = require('fs'); -const { JSDOM } = require('jsdom'); -const path = require('path'); -const expect = require('chai').expect; -const runSmokeTest = require('../../../../../test/smoke-test'); -const TestBed = require('../../../../../test/test-bed'); - -xdescribe('Build Greenwood With: ', function() { - const LABEL = 'Custom Theme Configuration and Default Workspace'; - let setup; - - before(async function() { - setup = new TestBed(); - - this.context = await setup.setupTestBed(__dirname); - }); - - describe(LABEL, function() { - before(async function() { - await setup.runGreenwoodCommand('build'); - }); - - runSmokeTest(['public', 'not-found', 'index'], LABEL); - - describe('Theme Styled Page Template', function() { - let dom; - - before(async function() { - dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); - }); - - it('should output a single index.html file using our custom styled page template', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; - }); - - it('should have the expected font import', function() { - const styles = '@import url(//fonts.googleapis.com/css?family=Roboto'; - const styleTags = dom.window.document.querySelectorAll('head style'); - let importCount = 0; - - styleTags.forEach((tag) => { - if (tag.textContent.indexOf(styles) >= 0) { - importCount += 1; - } - }); - - expect(importCount).to.equal(1); - }); - - it('should have the expected font family', function() { - const styles = 'body{font-family:Roboto,sans-serif}'; - const styleTags = dom.window.document.querySelectorAll('head style'); - let fontCount = 0; - - styleTags.forEach((tag) => { - if (tag.textContent.indexOf(styles) >= 0) { - fontCount += 1; - } - }); - - expect(fontCount).to.equal(1); - }); - - }); - - }); - - after(function() { - setup.teardownTestBed(); - }); - -}); \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.theme/greenwood.config.js b/packages/cli/test/cases/build.config.theme/greenwood.config.js deleted file mode 100644 index 815ada47f..000000000 --- a/packages/cli/test/cases/build.config.theme/greenwood.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - themeFile: 'my-brand.css' -}; \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.theme/src/styles/my-brand.css b/packages/cli/test/cases/build.config.theme/src/styles/my-brand.css deleted file mode 100644 index b34a86dbc..000000000 --- a/packages/cli/test/cases/build.config.theme/src/styles/my-brand.css +++ /dev/null @@ -1,5 +0,0 @@ -@import url('//fonts.googleapis.com/css?family=Roboto'); - -body { - font-family: 'Roboto', sans-serif; -} \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.theme/src/templates/page-template.js b/packages/cli/test/cases/build.config.theme/src/templates/page-template.js deleted file mode 100644 index e2306013f..000000000 --- a/packages/cli/test/cases/build.config.theme/src/templates/page-template.js +++ /dev/null @@ -1,16 +0,0 @@ -import { html, LitElement } from 'lit-element'; -import '../styles/my-brand.css'; - -class PageTemplate extends LitElement { - render() { - return html` - <div class='wrapper'> - <div class='page-template content owen-test'> - <entry></entry> - </div> - </div> - `; - } -} - -customElements.define('page-template', PageTemplate); \ No newline at end of file diff --git a/packages/cli/test/cases/build.config.title/build.config.title.spec.js b/packages/cli/test/cases/build.config.title/build.config.title.spec.js index 626e48058..9c2eb8b25 100644 --- a/packages/cli/test/cases/build.config.title/build.config.title.spec.js +++ b/packages/cli/test/cases/build.config.title/build.config.title.spec.js @@ -43,14 +43,13 @@ describe('Build Greenwood With: ', function() { before(async function() { await setup.runGreenwoodCommand('build'); }); - - // TODO runSmokeTest(['public', 'not-found', 'hello'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Custom Title from Configuration', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, './index.html')); }); @@ -65,7 +64,7 @@ describe('Build Greenwood With: ', function() { const pageTitle = 'About Page'; let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'about', './index.html')); }); diff --git a/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js b/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js index 24ec922bc..7a54d264a 100644 --- a/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js +++ b/packages/cli/test/cases/build.config.workspace-custom/build.config.workspace-custom.spec.js @@ -40,13 +40,12 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Custom About page', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'about', './index.html')); }); diff --git a/packages/cli/test/cases/build.default.import-node-modules/src/pages/index.html b/packages/cli/test/cases/build.default.import-node-modules/src/pages/index.html index c5c4de50b..a89645bb5 100644 --- a/packages/cli/test/cases/build.default.import-node-modules/src/pages/index.html +++ b/packages/cli/test/cases/build.default.import-node-modules/src/pages/index.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="../scripts/main.js"></script> <script type="module"> import { html } from 'lit-element'; diff --git a/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js b/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js index bf9f57e23..88b457597 100644 --- a/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js +++ b/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js @@ -35,7 +35,6 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Markdown Rendering', function() { diff --git a/packages/cli/test/cases/build.default.workspace-assets/build.default.workspace-assets.spec.js b/packages/cli/test/cases/build.default.workspace-assets/build.default.workspace-assets.spec.js index 24630a2ac..bd62e41eb 100644 --- a/packages/cli/test/cases/build.default.workspace-assets/build.default.workspace-assets.spec.js +++ b/packages/cli/test/cases/build.default.workspace-assets/build.default.workspace-assets.spec.js @@ -32,7 +32,6 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // runSmokeTest(['public', 'index', 'not-found'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Assets folder', function() { diff --git a/packages/cli/test/cases/build.default.workspace-getting-started/build.default.workspace-getting-started.spec.js b/packages/cli/test/cases/build.default.workspace-getting-started/build.default.workspace-getting-started.spec.js index 36c116d71..4f6b8ab25 100644 --- a/packages/cli/test/cases/build.default.workspace-getting-started/build.default.workspace-getting-started.spec.js +++ b/packages/cli/test/cases/build.default.workspace-getting-started/build.default.workspace-getting-started.spec.js @@ -34,6 +34,7 @@ const fs = require('fs'); const glob = require('glob-promise'); const { JSDOM } = require('jsdom'); const path = require('path'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { @@ -51,17 +52,15 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); + runSmokeTest(['public'], LABEL); + describe('Folder Structure and Home Page', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); - it('should create a public directory', function() { - expect(fs.existsSync(this.context.publicDir)).to.be.true; - }); - it('should create a new assets directory', function() { expect(fs.existsSync(path.join(this.context.publicDir, 'assets'))).to.be.true; }); @@ -70,15 +69,6 @@ describe('Build Greenwood With: ', function() { expect(fs.existsSync(path.join(this.context.publicDir, 'assets', './greenwood-logo.png'))).to.be.true; }); - it('should output an index.html file (home page)', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; - }); - - // TODO - xit('should output a single 404.html file (not found page)', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './404.html'))).to.be.true; - }); - it('should output two JS bundle files', async function() { expect(await glob.promise(path.join(this.context.publicDir, './*.js'))).to.have.lengthOf(2); }); @@ -149,7 +139,7 @@ describe('Build Greenwood With: ', function() { describe('First Blog Post', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'blog/first-post/index.html')); }); @@ -216,7 +206,7 @@ describe('Build Greenwood With: ', function() { describe('Second Blog Post', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'blog/second-post/index.html')); }); diff --git a/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/blog.html b/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/blog.html index 6d590b088..ea436fe72 100644 --- a/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/blog.html +++ b/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/blog.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="/components/footer.js"></script> <script type="module" src="/components/header.js"></script> diff --git a/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/page.html b/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/page.html index 71f44735d..a12cef0fc 100644 --- a/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/page.html +++ b/packages/cli/test/cases/build.default.workspace-getting-started/src/templates/page.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="/components/footer.js"></script> <script type="module" src="/components/header.js"></script> diff --git a/packages/cli/test/cases/build.default.workspace-javascript-css/src/pages/index.html b/packages/cli/test/cases/build.default.workspace-javascript-css/src/pages/index.html index 95af81520..8f838962b 100644 --- a/packages/cli/test/cases/build.default.workspace-javascript-css/src/pages/index.html +++ b/packages/cli/test/cases/build.default.workspace-javascript-css/src/pages/index.html @@ -2,7 +2,6 @@ <html lang="en" prefix="og:http://ogp.me/ns#"> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="../scripts/main.js"></script> <script type="module" src="../scripts/other.js"></script> diff --git a/packages/cli/test/cases/build.default.workspace-nested/build.default.workspace-nested.spec.js b/packages/cli/test/cases/build.default.workspace-nested/build.default.workspace-nested.spec.js index b359902ba..9c31be611 100644 --- a/packages/cli/test/cases/build.default.workspace-nested/build.default.workspace-nested.spec.js +++ b/packages/cli/test/cases/build.default.workspace-nested/build.default.workspace-nested.spec.js @@ -60,13 +60,12 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'not-found', 'index'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Blog Pages Directory', function() { let graph; - beforeEach(async function() { + before(async function() { graph = require(path.join(this.context.publicDir, 'graph.json')); }); diff --git a/packages/cli/test/cases/build.default.workspace-template-app/build.default.workspace-template-app.spec.js b/packages/cli/test/cases/build.default.workspace-template-app/build.default.workspace-template-app.spec.js index 24fa75c5c..80ce26758 100644 --- a/packages/cli/test/cases/build.default.workspace-template-app/build.default.workspace-template-app.spec.js +++ b/packages/cli/test/cases/build.default.workspace-template-app/build.default.workspace-template-app.spec.js @@ -38,7 +38,6 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'not-found', 'hello'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Custom App Template', function() { diff --git a/packages/cli/test/cases/build.default.workspace-template-app/src/templates/app.html b/packages/cli/test/cases/build.default.workspace-template-app/src/templates/app.html index bf4476253..fbf92892f 100644 --- a/packages/cli/test/cases/build.default.workspace-template-app/src/templates/app.html +++ b/packages/cli/test/cases/build.default.workspace-template-app/src/templates/app.html @@ -10,8 +10,6 @@ <div class='gwd-wrapper'> - <!-- TODO <lit-route><h1>404 Not found</h1></lit-route> --> - <p>My Custom App Template</p> <page-outlet></page-outlet> diff --git a/packages/cli/test/cases/build.default.workspace-template-page-and-app/build.default.workspace-template-page-and-app.spec.js b/packages/cli/test/cases/build.default.workspace-template-page-and-app/build.default.workspace-template-page-and-app.spec.js index 3e87eb9ad..a480fcd1b 100644 --- a/packages/cli/test/cases/build.default.workspace-template-page-and-app/build.default.workspace-template-page-and-app.spec.js +++ b/packages/cli/test/cases/build.default.workspace-template-page-and-app/build.default.workspace-template-page-and-app.spec.js @@ -28,9 +28,9 @@ * page.html */ const expect = require('chai').expect; -const fs = require('fs'); const { JSDOM } = require('jsdom'); const path = require('path'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { @@ -47,7 +47,7 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['not-found'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Custom App and Page Templates', function() { let dom; @@ -56,10 +56,6 @@ describe('Build Greenwood With: ', function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); - it('should output a single index.html file using our custom page template', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; - }); - it('should have the specific element we added as part of our custom page template', function() { const customElement = dom.window.document.querySelectorAll('div.owen-test'); diff --git a/packages/cli/test/cases/build.default.workspace-template-page/build.default.workspace-template-page.spec.js b/packages/cli/test/cases/build.default.workspace-template-page/build.default.workspace-template-page.spec.js index 025aa6e27..ad542818e 100644 --- a/packages/cli/test/cases/build.default.workspace-template-page/build.default.workspace-template-page.spec.js +++ b/packages/cli/test/cases/build.default.workspace-template-page/build.default.workspace-template-page.spec.js @@ -21,9 +21,9 @@ * page.html */ const expect = require('chai').expect; -const fs = require('fs'); const { JSDOM } = require('jsdom'); const path = require('path'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { @@ -40,7 +40,7 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['not-found'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Custom Page Template', function() { let dom; @@ -49,10 +49,6 @@ describe('Build Greenwood With: ', function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); - it('should output a single index.html file using our custom page template', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; - }); - describe('correct merge order for default app and custom page template <head> tags', function() { let scriptTags; let linkTags; diff --git a/packages/cli/test/cases/build.default.workspace-template-page/src/templates/page.html b/packages/cli/test/cases/build.default.workspace-template-page/src/templates/page.html index f1d66f2f2..3021703a4 100644 --- a/packages/cli/test/cases/build.default.workspace-template-page/src/templates/page.html +++ b/packages/cli/test/cases/build.default.workspace-template-page/src/templates/page.html @@ -3,7 +3,6 @@ <head> <head> - <!-- TODO have to use forward slash / for path references? translate on the fly in serve.js? --> <script type="module" src="/scripts/main.js"></script> <link rel="stylesheet" href="/styles/theme.css"></link> </head> diff --git a/packages/cli/test/cases/build.default.workspace-top-level-pages/build.default.workspace-top-level-pages.spec.js b/packages/cli/test/cases/build.default.workspace-top-level-pages/build.default.workspace-top-level-pages.spec.js index 1400a5791..d85e74799 100644 --- a/packages/cli/test/cases/build.default.workspace-top-level-pages/build.default.workspace-top-level-pages.spec.js +++ b/packages/cli/test/cases/build.default.workspace-top-level-pages/build.default.workspace-top-level-pages.spec.js @@ -38,8 +38,7 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'not-found', 'index'], LABEL); - runSmokeTest(['public'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Home (index) Page', function() { let dom; @@ -48,8 +47,11 @@ describe('Build Greenwood With: ', function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); - it('should create a top level home (index) page with just an index.html', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; + xit('should have the correct <title> for the home page', function() { + const titleTags = dom.window.document.querySelectorAll('title'); + + expect(titleTags.length).to.equal(1); + expect(titleTags[0].textContent).to.equal('Top Level Test'); }); it('should have the correct content for the home page', function() { diff --git a/packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/index.html b/packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/index.html index 2b9bd0170..b10aabaca 100644 --- a/packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/index.html +++ b/packages/cli/test/cases/build.default.workspace-top-level-pages/src/pages/index.html @@ -1,6 +1,10 @@ <!DOCTYPE html> <html lang="en" prefix="og:http://ogp.me/ns#"> + <head> + <title>Top Level Test + +

Hello from the home page!!!!

diff --git a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js index 2a6f04386..a04a27ee3 100644 --- a/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js +++ b/packages/cli/test/cases/build.default.workspace-user-directory-mapping/build.default.workspace-user-directory-mapping.spec.js @@ -35,6 +35,7 @@ const fs = require('fs'); const glob = require('glob-promise'); const { JSDOM } = require('jsdom'); const path = require('path'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { @@ -51,12 +52,12 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Output Folder Structure and Home Page', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); @@ -68,11 +69,6 @@ describe('Build Greenwood With: ', function() { expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; }); - // TODO - xit('should output a single 404.html file (not found page)', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './404.html'))).to.be.true; - }); - it('should output one JS bundle files', async function() { expect(await glob.promise(path.join(this.context.publicDir, './*.js'))).to.have.lengthOf(1); }); @@ -102,7 +98,7 @@ describe('Build Greenwood With: ', function() { describe('Describe Page page', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'pages/index.html')); }); @@ -140,7 +136,7 @@ describe('Build Greenwood With: ', function() { let pluginIndexPageDom; let pluginHooksIndexPageDom; - beforeEach(async function() { + before(async function() { pluginIndexPageDom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'plugins/index.html')); pluginHooksIndexPageDom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'plugins/index-hooks/index.html')); }); diff --git a/packages/cli/test/cases/build.default/build.default.spec.js b/packages/cli/test/cases/build.default/build.default.spec.js index a688a0aa0..d4ad64ba8 100644 --- a/packages/cli/test/cases/build.default/build.default.spec.js +++ b/packages/cli/test/cases/build.default/build.default.spec.js @@ -35,13 +35,12 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found', 'hello'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Default output for index.html', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, './index.html')); }); @@ -58,6 +57,10 @@ describe('Build Greenwood With: ', function() { expect(title).to.be.equal('My App'); }); + it('should have five default tags in the ', function() { + expect(metaTags.length).to.be.equal(5); + }); + it('should have default charset tag', function() { expect(metaTags[0].getAttribute('charset')).to.be.equal('utf-8'); }); diff --git a/packages/cli/test/cases/build.plugins.resource/build.config.plugins-resource.spec.js b/packages/cli/test/cases/build.plugins.resource/build.config.plugins-resource.spec.js index c23263953..7379c59cf 100644 --- a/packages/cli/test/cases/build.plugins.resource/build.config.plugins-resource.spec.js +++ b/packages/cli/test/cases/build.plugins.resource/build.config.plugins-resource.spec.js @@ -51,7 +51,7 @@ describe('Build Greenwood With: ', function() { describe('Transpiling and DOM Manipulation', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); diff --git a/packages/cli/test/cases/build.plugins.resource/src/pages/index.html b/packages/cli/test/cases/build.plugins.resource/src/pages/index.html index 6532e0c88..c33b646a6 100644 --- a/packages/cli/test/cases/build.plugins.resource/src/pages/index.html +++ b/packages/cli/test/cases/build.plugins.resource/src/pages/index.html @@ -2,7 +2,6 @@ - diff --git a/packages/plugin-babel/test/cases/default/default.spec.js b/packages/plugin-babel/test/cases/default/default.spec.js index 6d382e338..7963ee9cf 100644 --- a/packages/plugin-babel/test/cases/default/default.spec.js +++ b/packages/plugin-babel/test/cases/default/default.spec.js @@ -37,7 +37,7 @@ const fs = require('fs'); const glob = require('glob-promise'); const path = require('path'); const expect = require('chai').expect; -// const runSmokeTest = require('../../../../../test/smoke-test'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { @@ -55,7 +55,7 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Babel should process JavaScript that reference private class members / methods', function() { it('should output correctly processed JavaScript without private members', function() { diff --git a/packages/plugin-babel/test/cases/options.extend-config/options.extend-config.spec.js b/packages/plugin-babel/test/cases/options.extend-config/options.extend-config.spec.js index fd43c23ef..ff393595d 100644 --- a/packages/plugin-babel/test/cases/options.extend-config/options.extend-config.spec.js +++ b/packages/plugin-babel/test/cases/options.extend-config/options.extend-config.spec.js @@ -39,7 +39,7 @@ const fs = require('fs'); const glob = require('glob-promise'); const path = require('path'); const expect = require('chai').expect; -// const runSmokeTest = require('../../../../../test/smoke-test'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { @@ -60,7 +60,7 @@ describe('Build Greenwood With: ', function() { jsFiles = glob.sync(path.join(this.context.publicDir, '*.js')); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); + runSmokeTest(['public', 'index'], LABEL); it('should output one JavaScript file', function() { expect(jsFiles.length).to.equal(1); @@ -76,8 +76,8 @@ describe('Build Greenwood With: ', function() { }); // find a better way to test for preset-env specifically? - xdescribe('Babel should handle processing of JavaScript per usage of @babel/preset-env', function() { - it('should output correctly processed JavaScript...', function() { + describe('Babel should handle processing of JavaScript per usage of @babel/preset-env', function() { + xit('should output correctly processed JavaScript...', function() { const expectedJavaScript = 'return e&&e.__esModule'; const javascript = fs.readFileSync(jsFiles[0], 'utf-8'); diff --git a/packages/plugin-google-analytics/test/cases/default/default.spec.js b/packages/plugin-google-analytics/test/cases/default/default.spec.js index 31680308e..38e7ed48b 100644 --- a/packages/plugin-google-analytics/test/cases/default/default.spec.js +++ b/packages/plugin-google-analytics/test/cases/default/default.spec.js @@ -45,14 +45,13 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); - runSmokeTest(['public'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Initialization script', function() { let inlineScript = []; let scriptSrcTags = []; - beforeEach(async function() { + before(async function() { const dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); const scriptTags = dom.window.document.querySelectorAll('head script'); @@ -97,7 +96,7 @@ describe('Build Greenwood With: ', function() { describe('Link Preconnect', function() { let linkTag; - beforeEach(async function() { + before(async function() { const dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); const linkTags = dom.window.document.querySelectorAll('head link'); @@ -118,7 +117,7 @@ describe('Build Greenwood With: ', function() { describe('Tracking script', function() { let trackingScript; - beforeEach(async function() { + before(async function() { const dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); const scriptTags = dom.window.document.querySelectorAll('head script'); diff --git a/packages/plugin-google-analytics/test/cases/option-anonymous/option-anonymous.spec.js b/packages/plugin-google-analytics/test/cases/option-anonymous/option-anonymous.spec.js index 057c56288..965a3b943 100644 --- a/packages/plugin-google-analytics/test/cases/option-anonymous/option-anonymous.spec.js +++ b/packages/plugin-google-analytics/test/cases/option-anonymous/option-anonymous.spec.js @@ -46,13 +46,12 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest([not-found'], LABEL); - runSmokeTest(['public'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Initialization script', function() { let inlineScript; - beforeEach(async function() { + before(async function() { const dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); const scriptTags = dom.window.document.querySelectorAll('head script'); @@ -82,7 +81,7 @@ describe('Build Greenwood With: ', function() { describe('Tracking script', function() { let trackingScript; - beforeEach(async function() { + before(async function() { const dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); const scriptTags = dom.window.document.querySelectorAll('head script'); diff --git a/packages/plugin-graphql/src/index.js b/packages/plugin-graphql/src/index.js index ad8412f6c..6b9923a9b 100644 --- a/packages/plugin-graphql/src/index.js +++ b/packages/plugin-graphql/src/index.js @@ -65,7 +65,6 @@ class GraphQLResource extends ResourceInterface { async optimize(url, body) { return new Promise((resolve, reject) => { try { - // TODO const apolloScript = isStrictOptimization (no apollo-state) body = body.replace('', ` diff --git a/packages/plugin-import-css/test/cases/default/default.spec.js b/packages/plugin-import-css/test/cases/default/default.spec.js index d2b631fb2..b6b0070d6 100644 --- a/packages/plugin-import-css/test/cases/default/default.spec.js +++ b/packages/plugin-import-css/test/cases/default/default.spec.js @@ -27,6 +27,7 @@ const expect = require('chai').expect; const { JSDOM } = require('jsdom'); const path = require('path'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); describe('Build Greenwood With: ', function() { @@ -44,10 +45,12 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); + runSmokeTest(['public', 'index'], LABEL); + describe('importing CSS using ESM (import)', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); diff --git a/packages/plugin-import-css/test/cases/default/src/pages/index.html b/packages/plugin-import-css/test/cases/default/src/pages/index.html index 391ecb7a0..e58731458 100644 --- a/packages/plugin-import-css/test/cases/default/src/pages/index.html +++ b/packages/plugin-import-css/test/cases/default/src/pages/index.html @@ -2,7 +2,6 @@ - diff --git a/packages/plugin-polyfills/test/cases/default/default.spec.js b/packages/plugin-polyfills/test/cases/default/default.spec.js index 286f0879d..bff4cd0e1 100644 --- a/packages/plugin-polyfills/test/cases/default/default.spec.js +++ b/packages/plugin-polyfills/test/cases/default/default.spec.js @@ -25,6 +25,7 @@ const expect = require('chai').expect; const fs = require('fs'); const { JSDOM } = require('jsdom'); const path = require('path'); +const runSmokeTest = require('../../../../../test/smoke-test'); const TestBed = require('../../../../../test/test-bed'); const expectedPolyfillFiles = [ @@ -64,12 +65,12 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // runSmokeTest(['not-found'], LABEL); + runSmokeTest(['public', 'index'], LABEL); describe('Script tag in the tag', function() { let dom; - beforeEach(async function() { + before(async function() { dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); }); diff --git a/packages/plugin-postcss/test/cases/default/default.spec.js b/packages/plugin-postcss/test/cases/default/default.spec.js index cbfee8e89..7a0d6edea 100644 --- a/packages/plugin-postcss/test/cases/default/default.spec.js +++ b/packages/plugin-postcss/test/cases/default/default.spec.js @@ -46,7 +46,6 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Page referencing external nested CSS file', function() { diff --git a/packages/plugin-postcss/test/cases/options.extend-config/options.extend-config.spec.js b/packages/plugin-postcss/test/cases/options.extend-config/options.extend-config.spec.js index 52f00e190..625363f52 100644 --- a/packages/plugin-postcss/test/cases/options.extend-config/options.extend-config.spec.js +++ b/packages/plugin-postcss/test/cases/options.extend-config/options.extend-config.spec.js @@ -53,7 +53,6 @@ describe('Build Greenwood With: ', function() { await setup.runGreenwoodCommand('build'); }); - // TODO runSmokeTest(['public', 'index', 'not-found'], LABEL); runSmokeTest(['public', 'index'], LABEL); describe('Page referencing external nested CSS file', function() { diff --git a/test/smoke-test.js b/test/smoke-test.js index 184fb6f91..edeaf3ad0 100644 --- a/test/smoke-test.js +++ b/test/smoke-test.js @@ -12,7 +12,14 @@ const glob = require('glob-promise'); const { JSDOM } = require('jsdom'); const path = require('path'); -const mainBundleScriptRegex = /index.*.bundle\.js/; +function tagsMatch(tagName, html) { + const openTagRegex = new RegExp(`<${tagName}`, 'g'); + const closeTagRegex = new RegExp(`<\/${tagName.replace('>', '')}>`, 'g'); + const openingCount = (html.match(openTagRegex) || []).length; + const closingCount = (html.match(closeTagRegex) || []).length; + + return openingCount === closingCount; +} function publicDirectory(label) { describe(`Running Smoke Tests: ${label}`, function() { @@ -25,75 +32,9 @@ function publicDirectory(label) { expect(fs.existsSync(path.join(this.context.publicDir, './index.html'))).to.be.true; }); - xit('should output a single 404.html file (not found page)', function() { - expect(fs.existsSync(path.join(this.context.publicDir, './404.html'))).to.be.true; - }); - - it('should output no JS bundle files', async function() { - expect(await glob.promise(path.join(this.context.publicDir, '*.js'))).to.have.lengthOf(0); - }); - - it('should output no CSS files', async function() { - expect(await glob.promise(path.join(this.context.publicDir, '*.css'))).to.have.lengthOf(0); - }); - it('should output one graph.json file', async function() { expect(await glob.promise(path.join(this.context.publicDir, 'graph.json'))).to.have.lengthOf(1); }); - - it('should output no more than json file', async function() { - expect(await glob.promise(path.join(this.context.publicDir, '*.json'))).to.have.lengthOf(1); - }); - }); - }); -} - -function defaultNotFound(label) { - describe(`Running Smoke Tests: ${label}`, function() { - describe('404 (Not Found) page', function() { - let dom; - - beforeEach(async function() { - dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, '404.html')); - }); - - it('should have one - - - - diff --git a/www/templates/app.html b/www/templates/app.html index 71a6422a1..45085dd3a 100644 --- a/www/templates/app.html +++ b/www/templates/app.html @@ -22,7 +22,6 @@ import '@evergreen-wc/eve-container'; - @@ -35,7 +34,6 @@ - diff --git a/www/templates/page.html b/www/templates/page.html index 3117ed199..89eccfcff 100644 --- a/www/templates/page.html +++ b/www/templates/page.html @@ -2,7 +2,6 @@ -