diff --git a/packages/cli/package.json b/packages/cli/package.json index 0722a8162..4ec483e8a 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -53,7 +53,7 @@ "remark-rehype": "^7.0.0", "rollup": "^3.29.4", "unified": "^9.2.0", - "wc-compiler": "~0.14.0" + "wc-compiler": "~0.15.0" }, "devDependencies": { "@babel/runtime": "^7.10.4", diff --git a/packages/cli/test/cases/build.config.prerender-html-web-components/build.config.prerender-html-web-components.spec.js b/packages/cli/test/cases/build.config.prerender-html-web-components/build.config.prerender-html-web-components.spec.js new file mode 100644 index 000000000..54ce76e2c --- /dev/null +++ b/packages/cli/test/cases/build.config.prerender-html-web-components/build.config.prerender-html-web-components.spec.js @@ -0,0 +1,123 @@ +/* + * Use Case + * Run Greenwood build command with prerender config set to true and using HTML (Light DOM) Web Components. + * + * User Result + * Should generate a Greenwood build with the expected generated output using custom elements. + * + * User Command + * greenwood build + * + * User Config + * { + * prerender: true + * } + * + * User Workspace + * src/ + * components/ + * caption.js + * picture-frame.js + * pages/ + * index.html + */ +import chai from 'chai'; +import { JSDOM } from 'jsdom'; +import path from 'path'; +import { runSmokeTest } from '../../../../../test/smoke-test.js'; +import { getSetupFiles, getOutputTeardownFiles } from '../../../../../test/utils.js'; +import { Runner } from 'gallinago'; +import { fileURLToPath, URL } from 'url'; +import fs from 'fs/promises'; + +const expect = chai.expect; + +describe('Build Greenwood With: ', function() { + const LABEL = 'Prerender Configuration and HTML (Light DOM) Web Components'; + const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js'); + const outputPath = fileURLToPath(new URL('.', import.meta.url)); + let runner; + + before(function() { + this.context = { + publicDir: path.join(outputPath, 'public') + }; + runner = new Runner(); + }); + + describe(LABEL, function() { + + before(function() { + runner.setup(outputPath, getSetupFiles(outputPath)); + runner.runCommand(cliPath, 'build'); + }); + + runSmokeTest(['public', 'index'], LABEL); + + describe('Prerendered output for index.html', function() { + let dom; + let pictureFrame; + let expectedHtml; + let actualHtml; + + before(async function() { + actualHtml = await fs.readFile(new URL('./public/index.html', import.meta.url), 'utf-8'); + dom = new JSDOM(actualHtml); + pictureFrame = dom.window.document.querySelectorAll('wcc-picture-frame'); + expectedHtml = await fs.readFile(new URL('./expected.html', import.meta.url), 'utf-8'); + }); + + describe(LABEL, function() { + it('should not have any