From e203618511bb6b04df43f6903029664066bcac3c Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Fri, 27 Sep 2024 20:34:15 -0400 Subject: [PATCH 1/6] patch support for HTML web components with test case --- package.json | 4 +- .../greenwood.config.js | 3 + .../loaders-html-webcomponents.spec.js | 94 +++++++++ .../package.json | 3 + .../src/components/picture-frame.js | 14 ++ .../src/index.html | 14 ++ ...-build.prerender-import-attributes.spec.js | 1 - patches/wc-compiler+0.14.0.patch | 90 ++++++++ yarn.lock | 195 +++++++++++++++++- 9 files changed, 415 insertions(+), 3 deletions(-) create mode 100644 packages/cli/test/cases/loaders-build.html-web-components/greenwood.config.js create mode 100644 packages/cli/test/cases/loaders-build.html-web-components/loaders-html-webcomponents.spec.js create mode 100644 packages/cli/test/cases/loaders-build.html-web-components/package.json create mode 100644 packages/cli/test/cases/loaders-build.html-web-components/src/components/picture-frame.js create mode 100644 packages/cli/test/cases/loaders-build.html-web-components/src/index.html create mode 100644 patches/wc-compiler+0.14.0.patch diff --git a/package.json b/package.json index fe45e2b24..98a64bcd5 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "lint:js": "eslint \"*.js\" \"./packages/**/**/*.js\" \"./test/*.js\" \"./www/**/**/*.js\"", "lint:ts": "eslint \"./packages/**/**/*.ts\"", "lint:css": "stylelint \"./www/**/*.js\", \"./www/**/*.css\"", - "lint": "ls-lint && yarn lint:js && yarn lint:css" + "lint": "ls-lint && yarn lint:js && yarn lint:css", + "postinstall": "patch-package" }, "resolutions": { "lit": "^3.1.0" @@ -50,6 +51,7 @@ "jsdom": "^16.5.0", "lerna": "^3.16.4", "mocha": "^9.1.3", + "patch-package": "^8.0.0", "rimraf": "^2.6.3", "stylelint": "^13.8.0", "stylelint-a11y": "^1.2.3", diff --git a/packages/cli/test/cases/loaders-build.html-web-components/greenwood.config.js b/packages/cli/test/cases/loaders-build.html-web-components/greenwood.config.js new file mode 100644 index 000000000..8dc4be464 --- /dev/null +++ b/packages/cli/test/cases/loaders-build.html-web-components/greenwood.config.js @@ -0,0 +1,3 @@ +export default { + prerender: true +}; \ No newline at end of file diff --git a/packages/cli/test/cases/loaders-build.html-web-components/loaders-html-webcomponents.spec.js b/packages/cli/test/cases/loaders-build.html-web-components/loaders-html-webcomponents.spec.js new file mode 100644 index 000000000..5abbd0279 --- /dev/null +++ b/packages/cli/test/cases/loaders-build.html-web-components/loaders-html-webcomponents.spec.js @@ -0,0 +1,94 @@ +/* + * Use Case + * Run Greenwood and correctly prerender "HTML" Web Components. + * + * User Result + * Should generate a static Greenwood build with the expected prerender "HTML" Web Components content. + * + * User Command + * greenwood build + * + * User Config + * + * { + * prerender: true, + * } + * + * User Workspace + * src/ + * components/ + * picture-frame.js +* index.html + */ +import chai from 'chai'; +import fs from 'fs'; +import glob from 'glob-promise'; +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'; + +const expect = chai.expect; + +describe('Build Greenwood With: ', function() { + const LABEL = 'Prerendering with HTML 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(false, true); + }); + + describe(LABEL, function() { + before(function() { + runner.setup(outputPath, getSetupFiles(outputPath)); + runner.runCommand(cliPath, 'build'); + }); + + runSmokeTest(['public'], LABEL); + + describe('Prerender HTML Web Component', function() { + let dom; + let pictureFrame; + + before(async function() { + dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, './index.html')); + pictureFrame = dom.window.document.querySelectorAll('app-picture-frame'); + }); + + it('should not have any