diff --git a/.github/workflows/branch--lint-unit-and-smoke-test.yml b/.github/workflows/branch--lint-unit-and-smoke-test.yml index 271bc4f2..4a15c2f0 100644 --- a/.github/workflows/branch--lint-unit-and-smoke-test.yml +++ b/.github/workflows/branch--lint-unit-and-smoke-test.yml @@ -5,8 +5,8 @@ on: - master - main paths-ignore: - - 'docs/**' - - '**/README.md' + - "docs/**" + - "**/README.md" workflow_dispatch: jobs: lint-and-test: @@ -125,6 +125,11 @@ jobs: run: | yarn smoke-tests/designer smoke-test-headless ls -lah smoke-tests/designer/reports/ + - name: Run Lighthouse on urls and validate with lighthouserc + uses: treosh/lighthouse-ci-action@v8 + with: + configPath: "./lighthouserc.js" + uploadArtifacts: true - name: "Tar files" if: ${{ success() || failure() }} run: tar -cvf smoke-tests.tar smoke-tests/designer/reports diff --git a/.gitignore b/.gitignore index 57cbc508..aeb8060c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ smoke-tests/designer/reports/ */dist/ */.dist/ tsconfig.tsbuildinfo +.lighthouseci .yarn/* !.yarn/releases diff --git a/lighthouserc.js b/lighthouserc.js new file mode 100644 index 00000000..65859121 --- /dev/null +++ b/lighthouserc.js @@ -0,0 +1,24 @@ +module.exports = { + ci: { + collect: { + url: [ + "http://localhost:3000/app", + "http://localhost:3000/app/new", + "http://localhost:3000/app/choose-existing", + "http://localhost:3000/app/designer/test-form-a", + "http://localhost:3009/components/all-components", + ], + startServerCommand: "", + }, + assert: { + assertions: { + "first-contentful-paint": ["error", { minScore: 0.6 }], + }, + preset: "lighthouse:recommended", + }, + upload: { + target: "filesystem", + //target: "temporary-public-storage", + }, + }, +}; diff --git a/runner/package.json b/runner/package.json index 0ec9126e..c84db724 100644 --- a/runner/package.json +++ b/runner/package.json @@ -19,7 +19,7 @@ "test:dev": "lab -T test/.transform.js -P **/**/*.test.* -v test --coverage-exclude src", "unit-test": "lab -T test/.transform.js -P **/**/*.test.* -v test -S -v -r console -o stdout -r html -o unit-test.html -I version -l", "unit-test-cov": "lab -T test/.transform.js -P **/**/*.test.* -v test -t 83 -S -v -r console -o stdout -r lcov -o test-coverage/lab/lcov.info -r html -o test-coverage/lab/unit-test.html -r junit -o test-results/junit/unit-test.xml -I version -l", - "a11y": "node test/audit/components && node lighthouse", + "lighthousea11y": "node test/audit && node lighthouse", "symlink-env": "./bin/symlink-config", "type-check": "tsc --noEmit", "generate-docs": "typedoc src --tsconfig tsconfig.json --out ../docs/runner/typedoc --exclude '**/*+(index|.test|.jest).ts'" diff --git a/runner/test/audit/components.json b/runner/src/server/forms/components.json similarity index 93% rename from runner/test/audit/components.json rename to runner/src/server/forms/components.json index dbf00ff2..4d7f0832 100644 --- a/runner/test/audit/components.json +++ b/runner/src/server/forms/components.json @@ -11,7 +11,6 @@ "name": "textField", "title": "Text field", "hint": "Help text", - "options": {}, "schema": {} }, { @@ -19,101 +18,84 @@ "name": "multilineTextField", "title": "Multiline text field", "hint": "Help text", - "options": {}, "schema": {} }, { "type": "NumberField", "name": "numberField", "title": "Number field", - "options": {}, "schema": {} }, { "type": "DateField", "name": "dateField", "title": "Date field", - "options": {}, "schema": {} }, { "type": "DatePartsField", "name": "datePartsField", "title": "Date parts field", - "options": {}, "schema": {} }, { "type": "TimeField", "name": "timeField", "title": "Time field", - "options": {}, "schema": {} }, { "type": "DateTimeField", "name": "dateTimeField", "title": "Date time field", - "options": {}, "schema": {} }, { "type": "DateTimePartsField", "name": "dateTimePartsField", "title": "Date time parts field", - "options": {}, "schema": {} }, { "type": "YesNoField", "name": "yesNoField", "title": "Yes/No field", - "options": {}, "schema": {} }, { "type": "EmailAddressField", "name": "emailAddressField", "title": "Email address field", - "options": {}, "schema": {} }, { "type": "TelephoneNumberField", "name": "telephoneNumberField", "title": "Telephone number field", - "options": {}, "schema": {} }, { "type": "UkAddressField", "name": "addressField", "title": "Telephone number field", - "options": {}, "schema": {} }, { "type": "RadiosField", "name": "radiosField", "title": "Radios field", - "options": { - "list": "companyType" - }, + "list": "companyType", "schema": {} }, { "type": "SelectField", "name": "selectField", "title": "Select field", - "options": { - "list": "country" - }, + "list": "country", "schema": {} }, { - "options": { - "list": "horseBreed" - }, + "list": "horseBreed", "type": "CheckboxesField", "name": "checkboxesField", "title": "Checkboxes field", @@ -123,20 +105,17 @@ { "type": "Para", "content": "Paragraph...", - "options": {}, "schema": {} }, { "type": "InsetText", "content": "Inset text", - "options": {}, "schema": {} }, { "type": "Details", "title": "Title", "content": "Content", - "options": {}, "schema": {} } ] @@ -146,9 +125,7 @@ "title": "All Components Optional", "components": [ { - "options": { - "required": false - }, + "required": false, "type": "TextField", "name": "textField", "title": "Text field", @@ -156,9 +133,7 @@ "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "MultilineTextField", "name": "multilineTextField", "title": "Multiline text field", @@ -166,72 +141,56 @@ "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "NumberField", "name": "numberField", "title": "Number field", "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "DateField", "name": "dateField", "title": "Date field", "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "DatePartsField", "name": "datePartsField", "title": "Date parts field", "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "TimeField", "name": "timeField", "title": "Time field", "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "DateTimeField", "name": "dateTimeField", "title": "Date time field", "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "DateTimePartsField", "name": "dateTimePartsField", "title": "Date time parts field", "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "YesNoField", "name": "yesNoField", "title": "Yes/No field", "schema": {} }, { - "options": { - "required": false - }, + "required": false, "type": "EmailAddressField", "name": "emailAddressField", "title": "Email address field", @@ -256,10 +215,8 @@ "schema": {} }, { - "options": { - "required": false, - "list": "companyType" - }, + "required": false, + "list": "companyType", "type": "RadiosField", "name": "radiosField", "title": "Radios field", @@ -269,16 +226,12 @@ "type": "SelectField", "name": "selectField", "title": "Select field", - "options": { - "list": "country" - }, + "list": "country", "schema": {} }, { - "options": { - "required": false, - "list": "horseBreed" - }, + "required": false, + "list": "horseBreed", "type": "CheckboxesField", "name": "checkboxesField", "title": "Checkboxes field", diff --git a/runner/test/audit/components.js b/runner/test/audit/components.js index 6b47d4da..190c8f44 100644 --- a/runner/test/audit/components.js +++ b/runner/test/audit/components.js @@ -1,6 +1,6 @@ -import createServer from "../../src/server"; +import createServer from "src/server"; import lighthouse from "lighthouse"; -import chromeLauncher from "chrome-launcher"; +import { launch } from "chrome-launcher"; import fs from "fs"; const opts = { @@ -29,13 +29,11 @@ createServer({ formFileName: "components.json", formFilePath: __dirname }) }); function launchChromeAndRunLighthouse(url, opts, config = null) { - return chromeLauncher - .launch({ chromeFlags: opts.chromeFlags }) - .then((chrome) => { - opts.port = chrome.port; - return lighthouse(url, opts, config).then((results) => { - fs.writeFileSync(`./report.${opts.output}`, results.report); - return chrome.kill().then(() => results.lhr); - }); + return launch({ chromeFlags: opts.chromeFlags }).then((chrome) => { + opts.port = chrome.port; + return lighthouse(url, opts, config).then((results) => { + fs.writeFileSync(`./report.${opts.output}`, results.report); + return chrome.kill().then(() => results.lhr); }); + }); } diff --git a/smoke-tests/designer/wdio.conf.js b/smoke-tests/designer/wdio.conf.js index ab48eb6c..9f0b216a 100644 --- a/smoke-tests/designer/wdio.conf.js +++ b/smoke-tests/designer/wdio.conf.js @@ -1,6 +1,6 @@ const { hooks } = require("./support/hooks"); const drivers = { - chrome: { version: "95.0.4638.69" }, // https://chromedriver.chromium.org/ + chrome: { version: "97.0.4692.71" }, // https://chromedriver.chromium.org/ firefox: { version: "0.29.1" }, // https://github.com/mozilla/geckodriver/releases };