Skip to content

Commit

Permalink
Merge branch 'main' into lmm/1006-remove-register-pass-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
loganmcdonald-noaa authored May 6, 2024
2 parents 6e702d4 + 39002ca commit 41db5d1
Show file tree
Hide file tree
Showing 25 changed files with 289 additions and 228 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ module.exports = {
},
},
{
files: ["tests/**/*.js", "spatial-data/**/*.js", "web/**/tests/**/*.js"],
files: [
"tests/**/*.js",
"spatial-data/**/*.js",
"web/**/tests/**/*.js",
"playwright.config.js",
],
extends: ["airbnb-base", "prettier", "plugin:cypress/recommended"],
env: {
es6: true,
Expand Down
7 changes: 3 additions & 4 deletions .github/actions/build-drupal-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ runs:
using: composite
steps:
- name: setup image cacheing
if: needs.should-test.outputs.yes == 'true'
uses: actions/cache@v4
id: cache
id: docker-cache
with:
key: drupal-image-${{ hashFiles('composer.lock','web/sites/example.settings.dev.php','Dockerfile.dev') }}
path: /tmp/image.tar

- name: Set up Docker Buildx
if: needs.should-test.outputs.yes == 'true' && steps.cache.outputs.cache-hit != 'true'
if: steps.docker-cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v3

- name: build and export
if: needs.should-test.outputs.yes == 'true' && steps.cache.outputs.cache-hit != 'true'
if: steps.docker-cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v5
with:
context: .
Expand Down
13 changes: 6 additions & 7 deletions .github/actions/populate-database/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ runs:
using: composite
steps:
- name: database dump cache
if: needs.should-test.outputs.yes == 'true'
uses: actions/cache@v4
id: db-cache
with:
key: drupal-database-${{ hashFiles('web/config/**/*.yml', 'web/scs-export/**/*') }}
path: weathergov.sql

- name: setup image cacheing
if: needs.should-test.outputs.yes == 'true' && steps.db-cache.outputs.cache-hit != 'true'
if: steps.db-cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
key: drupal-image-${{ hashFiles('composer.lock','web/sites/example.settings.dev.php','Dockerfile.dev') }}
path: /tmp/image.tar

- name: cache spatial data
if: needs.should-test.outputs.yes == 'true' && steps.db-cache.outputs.cache-hit != 'true'
if: steps.db-cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
key: spatial-data-05mr24
Expand All @@ -26,28 +25,28 @@ runs:
spatial-data/s_05mr24.zip
- name: start the site
if: needs.should-test.outputs.yes == 'true' && steps.db-cache.outputs.cache-hit != 'true'
if: steps.db-cache.outputs.cache-hit != 'true'
shell: bash
run: |
docker load --input /tmp/image.tar
docker compose up -d
# Give the containers a moment to settle.
- name: wait a tick
if: needs.should-test.outputs.yes == 'true' && steps.db-cache.outputs.cache-hit != 'true'
if: steps.db-cache.outputs.cache-hit != 'true'
shell: bash
run: sleep 10

- name: populate the site
if: needs.should-test.outputs.yes == 'true' && steps.db-cache.outputs.cache-hit != 'true'
if: steps.db-cache.outputs.cache-hit != 'true'
shell: bash
run: |
cp web/sites/example.settings.dev.php web/sites/settings.dev.php
make install-site
make load-spatial
- name: dump database
if: needs.should-test.outputs.yes == 'true' && steps.db-cache.outputs.cache-hit != 'true'
if: steps.db-cache.outputs.cache-hit != 'true'
shell: bash
run: |
mysqldump \
Expand Down
5 changes: 0 additions & 5 deletions .github/actions/setup-site/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ runs:
using: composite
steps:
- name: setup image cacheing
if: needs.should-test.outputs.yes == 'true'
uses: actions/cache@v4
with:
key: drupal-image-${{ hashFiles('composer.lock','web/sites/example.settings.dev.php','Dockerfile.dev') }}
path: /tmp/image.tar

- name: database dump cache
if: needs.should-test.outputs.yes == 'true'
uses: actions/cache@v4
id: db-cache
with:
key: drupal-database-${{ hashFiles('web/config/**/*.yml', 'web/scs-export/**/*') }}
path: weathergov.sql

- name: start the site
if: needs.should-test.outputs.yes == 'true'
shell: bash
run: |
mkdir .coverage
Expand All @@ -27,12 +24,10 @@ runs:
# Give the containers a moment to settle.
- name: wait a tick
if: needs.should-test.outputs.yes == 'true'
shell: bash
run: sleep 10

- name: populate the site
if: needs.should-test.outputs.yes == 'true'
shell: bash
run: |
cp web/sites/example.settings.dev.php web/sites/settings.dev.php
Expand Down
45 changes: 26 additions & 19 deletions .github/workflows/code-standards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,15 @@ jobs:
filename: clover.xml
metric: statements

end-to-end-tests:
name: end-to-end tests
accessibility-tests:
name: accessibility tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]

steps:
- uses: browser-actions/setup-chrome@v1
- uses: browser-actions/setup-edge@v1

- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
Expand All @@ -279,31 +282,28 @@ jobs:
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site

- name: Cypress run
if: needs.should-test.outputs.yes == 'true'
uses: cypress-io/github-action@v6
- uses: actions/setup-node@v4
with:
project: tests/e2e
cache-key: cypress-e2e-${{ hashFiles('package-lock.json') }}
node-version: 18

- name: save screenshots
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tests/e2e/cypress/screenshots/screenshots.cy.js/
- name: install dependencies
run: npm ci

accessibility-tests:
name: accessibility tests
- name: install browsers
run: npx playwright install --with-deps

- name: run tests
run: npx playwright test a11y

end-to-end-tests:
name: end-to-end tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]

steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
with:
lfs: true

- name: setup site
if: needs.should-test.outputs.yes == 'true'
Expand All @@ -313,8 +313,15 @@ jobs:
if: needs.should-test.outputs.yes == 'true'
uses: cypress-io/github-action@v6
with:
project: tests/a11y
cache-key: cypress-a11y-${{ hashFiles('package-lock.json') }}
project: tests/e2e
cache-key: cypress-e2e-${{ hashFiles('package-lock.json') }}

- name: save screenshots
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tests/e2e/cypress/screenshots/screenshots.cy.js/

page-load-time-tests:
name: page load time tests
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ spatial-data/*.shx
spatial-data/*.shp
spatial-data/*.txt
!spatial-data/us.cities500.txt.zip
/.gitattributes
/.gitattributes
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ load-spatial: # Load spatial data into the database
### Testing
a11y: accessibility-test
accessibility-test: ## Run accessibility tests (alias a11y)
npx cypress run --project tests/a11y
npx playwright test a11y

be: backend-test
backend-test: ## Run all backend tests. (alias be)
Expand Down
7 changes: 4 additions & 3 deletions docs/dev/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ then:
site with our content.
5. Run `npm ci` from the command line.
This installs our Javascript and Sass code linters and formatters, as well as
Cypress, which is necessary for end-to-end and accessibility testing.
6. Browse to [http://localhost:8080](http://localhost:8080) in your broswer. You
Playwright, which is necessary for end-to-end and accessibility testing.
6. Run `npx playwright install --with-deps` to install Playwright's browsers.
7. Browse to [http://localhost:8080](http://localhost:8080) in your broswer. You
should see our front page! Congrats!
7. Browse to [http://localhost:8080/user/login](http://localhost:8080/user/login)
8. Browse to [http://localhost:8080/user/login](http://localhost:8080/user/login)
to log in. Your username is `admin` and your password is `root`. Then you can
do stuff!

Expand Down
12 changes: 6 additions & 6 deletions docs/dev/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ make ee

Automated accessibility testing can identify about half of all kinds of
accessibility bugs, so it is not a total solution. However, even a partial
automated solution is helpful! We also use [Cypress](https://www.cypress.io) for
accessibility testing, with the addition of the
[cypress-axe](https://www.npmjs.com/package/cypress-axe) library. This library
integrates [Axe core](https://github.com/dequelabs/axe-core) to test the
rendered page. We use the [WCAG2AA](https://www.w3.org/WAI/WCAG2AA-Conformance)
standard.
automated solution is helpful! We also use [Playwright](https://playwright.dev/)
for accessibility testing, with the addition of the
[@axe-core/playwright](https://www.npmjs.com/package/@axe-core/playwright)
library. This library integrates [Axe core](https://github.com/dequelabs/axe-core)
to test the rendered page. We use the
[WCAG2AA](https://www.w3.org/WAI/WCAG2AA-Conformance) standard.

To run accessibility tests locally, the Makefile command is:

Expand Down
Loading

0 comments on commit 41db5d1

Please sign in to comment.