-
Notifications
You must be signed in to change notification settings - Fork 53
Cypress
fzhao99 edited this page Mar 20, 2024
·
9 revisions
E2E/Integration tests are available using Cypress.
This file is required in the root of the prime-simplereport repo to run integration tests. Please reach out to an engineering team member if you need credentials.
.env
If you're using the docker-compose e2e setup, you'll need to fill out all of these variables in the .env
file.
Caution If you are using a Mac with the newer arm64 CPU architecture, this setup will not work, as first noticed on 04/18/2023. Please refer to the local setup instead.
# .env
# Docker settings
DOCKER_CLIENT_TIMEOUT=180
COMPOSE_HTTP_TIMEOUT=180
# Backend settings
SPRING_PROFILES_ACTIVE=e2e,db-dockerized
WIREMOCK_URL=http://cypress:8088
SPRING_LIQUIBASE_ENABLED="true"
OKTA_TESTING_DISABLEHTTPSCHECK="true"
OKTA_API_KEY="Get this from your user account in Okta"
OKTA_OAUTH2_CLIENT_ID=
SMARTY_AUTH_ID=
SMARTY_AUTH_TOKEN=
# Cypress settings
SPEC_PATH="cypress/integration/*"
CYPRESS_OKTA_USERNAME=
CYPRESS_OKTA_PASSWORD=
CYPRESS_OKTA_SECRET=
# Frontend settings
REACT_APP_BACKEND_URL=https://localhost.simplereport.gov/api
PUBLIC_URL=/app/
REACT_APP_OKTA_ENABLED=true
REACT_APP_DISABLE_MAINTENANCE_BANNER=true
REACT_APP_OKTA_URL=http://cypress:8088
REACT_APP_BASE_URL=https://localhost.simplereport.gov
REACT_APP_OKTA_CLIENT_ID=
# Shared settings (Backend, Frontend)
GIT_DISCOVERY_ACROSS_FILESYSTEM=1
If you're running e2e tests against a set of local apps with Okta enabled, you only need the following.
# .env
OKTA_API_KEY="Get this from your user account in Okta"
SMARTY_AUTH_ID=
SMARTY_AUTH_TOKEN=
CYPRESS_OKTA_USERNAME=
CYPRESS_OKTA_PASSWORD=
CYPRESS_OKTA_SECRET=
//(or whatever your REACT_APP_BACKEND_URL is set to)
CYPRESS_BACKEND_URL=https://localhost.simplereport.gov/api
If you're running e2e tests against a set of local apps without Okta enabled, you only need the following.
# .env
SMARTY_AUTH_ID=
SMARTY_AUTH_TOKEN=
//(or whatever your REACT_APP_BACKEND_URL is set to)
CYPRESS_BACKEND_URL=https://localhost.simplereport.gov/api
You'll also need to run the backend locally with the following demo config in your application-local.yaml
simple-report:
demo-users:
default-user:
authorization:
granted-roles: ADMIN
site-admin-emails:
- [email protected]
The .env
file has a template at .env.cypress.sample
for running cypress against your local setup or .env.cypress.remote.sample
to run against a remote environment.
- Install docker and docker-compose.
- Stop any local instances of your apps to prevent port conflicts.
- Run Cypress.
yarn e2e
- Start your local apps however you normally do!
- Move to the
cypress/
directory. - Run
yarn install
in the cypress directory. - Run the yarn command that matches your setup.
- Run Cypress locally and open interactive mode. Do this if you're running the apps locally on bare metal with Okta disabled.
yarn e2e:local
- Run Cypress locally and open interactive mode. Do this if you're running the apps locally on bare metal with Okta enabled.
yarn e2e:local:okta
- Run Cypress locally and open interactive mode. Do this if you're running the apps locally with docker-compose with Okta disabled.
yarn e2e:nginx
- Run Cypress locally and open interactive mode. Do this if you're running the apps locally with docker-compose with Okta enabled.
yarn e2e:nginx:okta
We utilize cypress to audit the accessibility of our pages. See the Accessibility Auditing page for more info.
- Check that you have brought down all instances of your apps; you may need to kill a hanging process, and try again.
- Try installing
mkcert
and runyarn start
. This will create the certs you need.
- If you want to visit the app in your browser while Cypress runs in docker, you'll need to edit your local /etc/hosts and add the following line.
127.0.0.1 localhost.simplereport.gov
- Connection refused errors coming out of Nginx logs are normal until your apps have started successfully. When they start, Cypress will begin running tests. If they fail to start, Cypress will time out and bring down all the containers.
- Check that you have escaped special characters in your
.env
file.
- Check that you have added the correct user roles to your
application-local.yaml
as documented here
See the Cypress documentation for writing new tests. If you need to generate new Wiremock mappings for external services, see this wiki page.
- Getting Started
- [Setup] Docker and docker compose development
- [Setup] IntelliJ run configurations
- [Setup] Running DB outside of Docker (optional)
- [Setup] Running nginx locally (optional)
- [Setup] Running outside of docker
- Accessing and testing weird parts of the app on local dev
- Accessing patient experience in local dev
- API Testing with Insomnia
- Cypress
- How to run e2e locally for development
- E2E tests
- Database maintenance
- MailHog
- Running tests
- SendGrid
- Setting up okta
- Sonar
- Storybook and Chromatic
- Twilio
- User roles
- Wiremock
- CSV Uploader
- Log local DB queries
- Code review and PR conventions
- SimpleReport Style Guide
- How to Review and Test Pull Requests for Dependabot
- How to Review and Test Pull Requests with Terraform Changes
- SimpleReport Deployment Process
- Adding a Developer
- Removing a developer
- Non-deterministic test tracker
- Alert Response - When You Know What is Wrong
- What to Do When You Have No Idea What is Wrong
- Main Branch Status
- Maintenance Mode
- Swapping Slots
- Monitoring
- Container Debugging
- Debugging the ReportStream Uploader
- Renew Azure Service Principal Credentials
- Releasing Changelog Locks
- Muting Alerts
- Architectural Decision Records
- Backend Stack Overview
- Frontend Overview
- Cloud Architecture
- Cloud Environments
- Database ERD
- External IDs
- GraphQL Flow
- Hibernate Lazy fetching and nested models
- Identity Verification (Experian)
- Spring Profile Management
- SR Result bulk uploader device validation logic
- Test Metadata and how we store it
- TestOrder vs TestEvent
- ReportStream Integration
- Feature Flag Setup
- FHIR Resources
- FHIR Conversions
- Okta E2E Integration
- Deploy Application Action
- Slack notifications for support escalations
- Creating a New Environment Within a Resource Group
- How to Add and Use Environment Variables in Azure
- Web Application Firewall (WAF) Troubleshooting and Maintenance
- How to Review and Test Pull Requests with Terraform Changes