From 6d220faf8f3a0cdc0b369d18301a4e31bdf333f2 Mon Sep 17 00:00:00 2001 From: Paul Grad Date: Thu, 30 Mar 2023 13:44:15 -0700 Subject: [PATCH 01/12] fix: resolve accessibility issues Fix the errors reported by Lighthouse. --- client/src/components/Header/Header.js | 1 + client/src/index.html | 2 +- client/src/pages/NewTree/NewTreeButton.js | 1 + client/src/pages/UserLocation/GeolocateControl.js | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/components/Header/Header.js b/client/src/components/Header/Header.js index 70021ee6..0b52aa3e 100644 --- a/client/src/components/Header/Header.js +++ b/client/src/components/Header/Header.js @@ -41,6 +41,7 @@ const Header = () => { }} color="success" className="header__btn-menu" + title="Menu" > - + diff --git a/client/src/pages/NewTree/NewTreeButton.js b/client/src/pages/NewTree/NewTreeButton.js index 0d9c7d38..0fec8d5b 100644 --- a/client/src/pages/NewTree/NewTreeButton.js +++ b/client/src/pages/NewTree/NewTreeButton.js @@ -84,6 +84,7 @@ export default function NewTreeButton({ map }) { value="Plant" selected={isPlanting} onChange={handlePlantClick} + title="Plant New Tree" /> {map && } diff --git a/client/src/pages/UserLocation/GeolocateControl.js b/client/src/pages/UserLocation/GeolocateControl.js index 96a22c52..ec082c06 100644 --- a/client/src/pages/UserLocation/GeolocateControl.js +++ b/client/src/pages/UserLocation/GeolocateControl.js @@ -60,7 +60,7 @@ export default function GeolocateControl({ map }) { return ( <> - + Date: Thu, 30 Mar 2023 16:23:32 -0700 Subject: [PATCH 02/12] test: Add Lighthouse CI locally Added the Lighthouse CI config file. I had to tweak the info message server/index.js emits, because Lighthouse needs to see something like "Listening on..." to detect that the server has started. --- lighthouserc.js | 17 +++++++++++++++++ server/index.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 lighthouserc.js diff --git a/lighthouserc.js b/lighthouserc.js new file mode 100644 index 00000000..81b6fbbd --- /dev/null +++ b/lighthouserc.js @@ -0,0 +1,17 @@ +module.exports = { + ci: { + collect: { + startServerCommand: 'npm run start:dev', + url: ['http://localhost:3001'], + }, + assert: { + assertions: { + 'categories:accessibility': ['error', { minScore: 1 }], + 'categories:best-practices': ['error', { minScore: 1 }], + }, + }, + upload: { + target: 'temporary-public-storage', + }, + }, +}; \ No newline at end of file diff --git a/server/index.js b/server/index.js index 77d7399a..77cbbe5a 100644 --- a/server/index.js +++ b/server/index.js @@ -38,4 +38,4 @@ app.get('/*', (req, res) => { }); const httpServer = http.createServer(app); -httpServer.listen(port, () => logger.info(`${host}:${port}`)); +httpServer.listen(port, () => logger.info(`listening on ${host}:${port}`)); From ac6624637ec3fa8f23df77689b1daf00fc2f757f Mon Sep 17 00:00:00 2001 From: Paul Grad Date: Thu, 30 Mar 2023 16:26:13 -0700 Subject: [PATCH 03/12] ci: Added Lighthouse CI github action Lighthouse CI should now run in pre-flight. The scores for accessibility and best practices need to be 100 for CI to pass. --- .github/workflows/lighthouse-ci.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/lighthouse-ci.yaml diff --git a/.github/workflows/lighthouse-ci.yaml b/.github/workflows/lighthouse-ci.yaml new file mode 100644 index 00000000..5d0d2964 --- /dev/null +++ b/.github/workflows/lighthouse-ci.yaml @@ -0,0 +1,20 @@ +name: Build project and run Lighthouse CI +on: [push] +jobs: + lhci: + name: Lighthouse CI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Use Node.js 18.x + uses: actions/setup-node@v1 + with: + node-version: 18.x + - name: npm install production + run: | + npm install --production + - name: run Lighthouse CI + run: | + npm install -g @lhci/cli@10.1.0 + npm run build + lhci autorun --upload.target=temporary-public-storage || echo "LHCI failed!" \ No newline at end of file From 4103eea2bc737eee5513f561d6b96f86d398f723 Mon Sep 17 00:00:00 2001 From: Paul Grad Date: Thu, 30 Mar 2023 16:46:24 -0700 Subject: [PATCH 04/12] test: Update snapshots Adding a title for accessibility to Header changed its test snapshot, so it had to be updated. --- client/src/tests/__snapshots__/Header.test.js.snap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/tests/__snapshots__/Header.test.js.snap b/client/src/tests/__snapshots__/Header.test.js.snap index 9b51dd92..0f3fc540 100644 --- a/client/src/tests/__snapshots__/Header.test.js.snap +++ b/client/src/tests/__snapshots__/Header.test.js.snap @@ -390,6 +390,7 @@ exports[`
spec renders Header correctly 1`] = `