https://github.com/govtechsg/purple-a11y-tests
Functional tests for Purple A11y
https://github.com/govtechsg/purple-a11y-tests
Last synced: 3 months ago
JSON representation
Functional tests for Purple A11y
- Host: GitHub
- URL: https://github.com/govtechsg/purple-a11y-tests
- Owner: GovTechSG
- License: mit
- Created: 2024-06-25T08:35:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-11T11:16:09.000Z (over 1 year ago)
- Last Synced: 2025-02-22T10:31:26.771Z (over 1 year ago)
- Language: HTML
- Size: 10.4 MB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# purple-a11y-tests
[Cypress](https://www.cypress.io/) functional tests for [Purple A11y](https://github.com/govtechsg/purple-a11y) to verify the correctness of Purple A11y CLI and integration module.
## Run Locally
#### Step 1:
- Edit the /etc/hosts file by running `sudo nano /etc/hosts` in terminal.
- At the end of the file, add these new lines with the following format:
```
127.0.0.1 main.purplea11y.local
127.0.0.1 diffHostname.purplea11y.local
```
This is needed to test the `strategy` flag in Purple A11y.
#### Step 2:
- Install dependencies then run the `host_websites_and_run_cypress.sh` script, which hosts the functional test website on a python server then runs the cypress tests.
Note: The `host_websites_and_run_cypress.sh` script accepts an argument that specifies the package of Purple A11y you want to test. To test your specific branch of Purple A11y, just change "master" with your preferred branch. (see below)
```
npm install
shell_scripts/host_websites_and_run_cypress.sh git+https://github.com/GovTechSG/purple-a11y.git#master
```
- After running the `shell_scripts/host_websites_and_run_cypress.sh` script, find generated cypress report under `./cypress/reports/index.html` from project root directory.
- If you make code changes in the `src` folder, ensure you do `npm run build` to compile the typescript into the `dist` folder.
## Run via Docker Container
#### Prerequisites:
Ensure that you have these installed:
- [Colima](https://github.com/abiosoft/colima) on MacOS, or Docker Engine on Linux or Windows (via Linux VM)
- Docker (install via `brew install docker`)
#### Step 1: Start colima
```
colima start
```
#### Step 2: Host functional test website on python server and run functional tests
Note: The `start_docker.sh` script accepts an argument that specifies the package of Purple A11y you want to test. To test your specific branch of Purple A11y, just change "master" with your preferred branch. (see below)
```
shell_scripts/start_docker.sh git+https://github.com/GovTechSG/purple-a11y.git#master
```
#### Step 3: Stop running container and remove image by running `stop_docker.sh` from a new terminal
```
shell_scripts/stop_docker.sh
```
- Cypress tests report will then be copied over from inside the container to your local repo at ./cypress/reports (view `index.html` for report)
#### Step 4: Stop colima
```
colima stop
```
## Run on GitHub Actions
Test changes to tests by triggering Actions to run the test on any branch of `tests` or `purple-a11y`.
- Go to [Actions](https://github.com/GovTechSG/purple-a11y-tests/actions/workflows/docker-tests.yml) tab.
- Select `Run workflow` and choose the branch under `Use workflow from` to change the tests branch.
- Optionally, the different git+URL of Purple A11y to change the branch of Purple A11y in `Checkout a specific purple a11y branch`.
## Limitations
- Docker can only run Chromium in headless mode or through Xvfb (`xvfb-run`).
- The tests will not run successfully on Chrome or Edge in Docker.