generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tidy up e2e test configuration and README
Move all example e2e configuration into .env files and ensure they all contain the same entries Update/simplify the README
- Loading branch information
1 parent
8e5701d
commit a8b6b97
Showing
5 changed files
with
103 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
API_CLIENT_ID=approved-premises-ui | ||
APPROVED_PREMISES_API_URL=http://localhost:8080 | ||
CAS1_E2E_ADMINISTRATOR_PASSWORD=*REDACTED* | ||
CAS1_E2E_ADMINISTRATOR_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_ASSESSOR_EMAIL=[email protected] | ||
CAS1_E2E_ASSESSOR_NAME="AP_USER TEST_1" | ||
CAS1_E2E_ASSESSOR_PASSWORD=*REDACTED* | ||
CAS1_E2E_ASSESSOR_USERNAME=AP_USER_TEST_1 | ||
CAS1_E2E_CRU_MEMBER_PASSWORD=*REDACTED* | ||
CAS1_E2E_CRU_MEMBER_USERNAME=AP_USER_TEST_4 | ||
CAS1_E2E_DELIUS_USERNAME_TO_ADD_AND_DELETE=JOSEPHHOLLINSHEAD | ||
CAS1_E2E_EMERGENCY_ASSESSOR_NAME_TO_ALLOCATE_TO="AP_USER TEST_1" | ||
CAS1_E2E_FUTURE_MANAGER_PASSWORD=*REDACTED* | ||
CAS1_E2E_FUTURE_MANAGER_USERNAME=AP_USER_TEST_5 | ||
CAS1_E2E_PERSON_FOR_ADHOC_BOOKING_CRN=X349420 | ||
CAS1_E2E_REPORT_VIEWER_PASSWORD=*REDACTED* | ||
CAS1_E2E_REPORT_VIEWER_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_USER_WITHOUT_ROLES_PASSWORD=*REDACTED* | ||
CAS1_E2E_USER_WITHOUT_ROLES_USERNAME=AP_USER_TEST_1 | ||
CAS1_E2E_CHECK_EMAILS=false | ||
NOTIFY_API_KEY=*REDACTED* | ||
HMPPS_AUTH_EXTERNAL_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_NAME="AP_USER TEST_1" | ||
HMPPS_AUTH_PASSWORD=*REDACTED* | ||
HMPPS_AUTH_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_USERNAME=AP_USER_TEST_1 | ||
SYSTEM_CLIENT_ID=approved-premises-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,25 +4,25 @@ CAS1_E2E_ADMINISTRATOR_PASSWORD=secret | |
CAS1_E2E_ADMINISTRATOR_USERNAME=JIMSNOWLDAP | ||
CAS1_E2E_ASSESSOR_EMAIL=[email protected] | ||
CAS1_E2E_ASSESSOR_NAME="Test Jim Snow" | ||
CAS1_E2E_ASSESSOR_PASSWORD=secret | ||
CAS1_E2E_ASSESSOR_PASSWORD=doesntmatter | ||
CAS1_E2E_ASSESSOR_USERNAME=JIMSNOWLDAP | ||
CAS1_E2E_CRU_MEMBER_PASSWORD=secret | ||
CAS1_E2E_CRU_MEMBER_PASSWORD=doesntmatter | ||
CAS1_E2E_CRU_MEMBER_USERNAME=LAOFULLACCESS | ||
CAS1_E2E_DELIUS_USERNAME_TO_ADD_AND_DELETE=john-smith | ||
CAS1_E2E_EMERGENCY_ASSESSOR_NAME_TO_ALLOCATE_TO="Test Jim Snow" | ||
CAS1_E2E_FUTURE_MANAGER_PASSWORD=secret | ||
CAS1_E2E_FUTURE_MANAGER_PASSWORD=doesntmatter | ||
CAS1_E2E_FUTURE_MANAGER_USERNAME=LAOFULLACCESS | ||
CAS1_E2E_PERSON_FOR_ADHOC_BOOKING_CRN=X320811 | ||
CAS1_E2E_REPORT_VIEWER_PASSWORD=secret | ||
CAS1_E2E_REPORT_VIEWER_PASSWORD=doesntmatter | ||
CAS1_E2E_REPORT_VIEWER_USERNAME=JIMSNOWLDAP | ||
CAS1_E2E_USER_WITHOUT_ROLES_PASSWORD=secret | ||
CAS1_E2E_USER_WITHOUT_ROLES_PASSWORD=doesntmatter | ||
CAS1_E2E_USER_WITHOUT_ROLES_USERNAME=JIMSNOWLDAP | ||
CAS1_E2E_CHECK_EMAILS=false | ||
NOTIFY_API_KEY=*REDACTED* | ||
HMPPS_AUTH_EXTERNAL_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_NAME=AP_USER TEST_1 | ||
HMPPS_AUTH_PASSWORD=*REDACTED* | ||
HMPPS_AUTH_PASSWORD=doesntmatter | ||
HMPPS_AUTH_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_USERNAME=AP_USER_TEST_1 | ||
NOTIFY_API_KEY=*REDACTED* | ||
SYSTEM_CLIENT_ID=approved-premises-api | ||
ENABLE_V2_MATCH=true | ||
ENABLE_V2_MATCH=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
API_CLIENT_ID=approved-premises-ui | ||
APPROVED_PREMISES_API_URL=http://localhost:8080 | ||
CAS1_E2E_ADMINISTRATOR_PASSWORD=doesntmatter | ||
CAS1_E2E_ADMINISTRATOR_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_ASSESSOR_EMAIL=stuart.harrison2+test1@digital.justice.gov.uk | ||
CAS1_E2E_ASSESSOR_NAME=AP_USER TEST_1 | ||
CAS1_E2E_ASSESSOR_PASSWORD=doesntmatter | ||
CAS1_E2E_ASSESSOR_USERNAME=AP_USER_TEST_1 | ||
CAS1_E2E_CRU_MEMBER_PASSWORD=doesntmatter | ||
CAS1_E2E_CRU_MEMBER_USERNAME=AP_USER_TEST_4 | ||
CAS1_E2E_DELIUS_USERNAME_TO_ADD_AND_DELETE=JOSEPHHOLLINSHEAD | ||
CAS1_E2E_EMERGENCY_ASSESSOR_NAME_TO_ALLOCATE_TO=AP_USER TEST_1 | ||
CAS1_E2E_FUTURE_MANAGER_PASSWORD=doesntmatter | ||
CAS1_E2E_FUTURE_MANAGER_USERNAME=AP_USER_TEST_4 | ||
CAS1_E2E_PERSON_FOR_ADHOC_BOOKING_CRN=X349420 | ||
CAS1_E2E_REPORT_VIEWER_PASSWORD=doesntmatter | ||
CAS1_E2E_REPORT_VIEWER_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_USER_WITHOUT_ROLES_PASSWORD=doesntmatter | ||
CAS1_E2E_USER_WITHOUT_ROLES_USERNAME=AP_USER_TEST_1 | ||
CAS1_E2E_CHECK_EMAILS=false | ||
NOTIFY_API_KEY=*REDACTED* | ||
HMPPS_AUTH_EXTERNAL_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_NAME=AP_USER TEST_1 | ||
HMPPS_AUTH_PASSWORD=doesntmatter | ||
HMPPS_AUTH_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_USERNAME=AP_USER_TEST_1 | ||
SYSTEM_CLIENT_ID=approved-premises-api | ||
ENABLE_V2_MATCH=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,181 +71,78 @@ npm install | |
npx playwright install | ||
``` | ||
|
||
### Running locally against the deployed `dev` environment | ||
### Running against UI/API hosted in the `dev` environment | ||
|
||
#### Environment variables | ||
Copy the contents of `.env.dev` into `.env`. Update the user passwords to the actual values (available in 1Password) | ||
|
||
You will need to have the following **environment variables** in your local `.env` file: | ||
If you also want to test emails, review the 'Testing Emails' section below | ||
|
||
``` | ||
API_CLIENT_ID=approved-premises-ui | ||
APPROVED_PREMISES_API_URL=http://localhost:8080 | ||
CAS1_E2E_ADMINISTRATOR_PASSWORD=*REDACTED* | ||
CAS1_E2E_ADMINISTRATOR_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_ASSESSOR_EMAIL=e2e.test.user@example.digital.justice.gov.uk | ||
CAS1_E2E_ASSESSOR_NAME="AP_USER TEST_1" | ||
CAS1_E2E_ASSESSOR_PASSWORD=*REDACTED* | ||
CAS1_E2E_ASSESSOR_USERNAME=AP_USER_TEST_1 | ||
CAS1_E2E_CRU_MEMBER_PASSWORD=*REDACTED* | ||
CAS1_E2E_CRU_MEMBER_USERNAME=AP_USER_TEST_4 | ||
CAS1_E2E_DELIUS_USERNAME_TO_ADD_AND_DELETE=JOSEPHHOLLINSHEAD | ||
CAS1_E2E_EMERGENCY_ASSESSOR_NAME_TO_ALLOCATE_TO="AP_USER TEST_1" | ||
CAS1_E2E_EMERGENCY_NAME_TO_ALLOCATE_TO="AP_USER TEST_1" | ||
CAS1_E2E_FUTURE_MANAGER_PASSWORD=*REDACTED* | ||
CAS1_E2E_FUTURE_MANAGER_USERNAME=AP_USER_TEST_5 | ||
CAS1_E2E_PERSON_FOR_ADHOC_BOOKING_CRN=X349420 | ||
CAS1_E2E_REPORT_VIEWER_PASSWORD=*REDACTED* | ||
CAS1_E2E_REPORT_VIEWER_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_USER_WITHOUT_ROLES_PASSWORD=*REDACTED* | ||
CAS1_E2E_USER_WITHOUT_ROLES_USERNAME=AP_USER_TEST_1 | ||
HMPPS_AUTH_EXTERNAL_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_NAME="AP_USER TEST_1" | ||
HMPPS_AUTH_PASSWORD=*REDACTED* | ||
HMPPS_AUTH_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_USERNAME=AP_USER_TEST_1 | ||
NOTIFY_API_KEY=*REDACTED* | ||
SYSTEM_CLIENT_ID=approved-premises-api | ||
``` | ||
|
||
To run headless: | ||
Then start the tests using one of the following: | ||
|
||
```bash | ||
npm run test:e2e:ci | ||
# -> npx playwright test --config ./e2e/playwright.config.ts --project=dev | ||
``` | ||
|
||
or with the UI: | ||
|
||
```bash | ||
# headless | ||
npm run test:e2e:ci | ||
# ui | ||
npm run test:e2e:ui | ||
# -> npx playwright test --config ./e2e/playwright.config.ts --project=dev --ui | ||
|
||
``` | ||
|
||
### Running locally against your `local` development environment | ||
|
||
#### Environment variables | ||
### Running against UI/API hosted in your local dev environment (ap-tools) | ||
|
||
You will need to have the following **environment variables** in your local `.env` file. | ||
|
||
NOTIFY_API_KEY will need updating (speak to colleagues). All other defaults should work out of the box. | ||
First start the ap-tools using | ||
|
||
``` | ||
API_CLIENT_ID=approved-premises-ui | ||
APPROVED_PREMISES_API_URL=http://localhost:8080 | ||
CAS1_E2E_ADMINISTRATOR_PASSWORD=secret | ||
CAS1_E2E_ADMINISTRATOR_USERNAME=JIMSNOWLDAP | ||
[email protected] | ||
CAS1_E2E_ASSESSOR_NAME="Test Jim Snow" | ||
CAS1_E2E_ASSESSOR_PASSWORD=secret | ||
CAS1_E2E_ASSESSOR_USERNAME=JIMSNOWLDAP | ||
CAS1_E2E_CRU_MEMBER_PASSWORD=secret | ||
CAS1_E2E_CRU_MEMBER_USERNAME=LAOFULLACCESS | ||
CAS1_E2E_DELIUS_USERNAME_TO_ADD_AND_DELETE=john-smith | ||
CAS1_E2E_EMERGENCY_ASSESSOR_NAME_TO_ALLOCATE_TO="Test Jim Snow" | ||
CAS1_E2E_FUTURE_MANAGER_PASSWORD=secret | ||
CAS1_E2E_FUTURE_MANAGER_USERNAME=LAOFULLACCESS | ||
CAS1_E2E_PERSON_FOR_ADHOC_BOOKING_CRN=X320811 | ||
CAS1_E2E_REPORT_VIEWER_PASSWORD=secret | ||
CAS1_E2E_REPORT_VIEWER_USERNAME=JIMSNOWLDAP | ||
CAS1_E2E_USER_WITHOUT_ROLES_PASSWORD=secret | ||
CAS1_E2E_USER_WITHOUT_ROLES_USERNAME=JIMSNOWLDAP | ||
CAS1_E2E_CHECK_EMAILS=false | ||
HMPPS_AUTH_EXTERNAL_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_NAME=AP_USER TEST_1 | ||
HMPPS_AUTH_PASSWORD=*REDACTED* | ||
HMPPS_AUTH_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_USERNAME=AP_USER_TEST_1 | ||
NOTIFY_API_KEY=*REDACTED* | ||
SYSTEM_CLIENT_ID=approved-premises-api | ||
ENABLE_V2_MATCH=true | ||
ap-tools server stop --clear-databases | ||
ap-tools server start --local-ui --local-api | ||
``` | ||
|
||
#### Testing Email Locally | ||
|
||
When testing locally emails will not be enabled by default. To enable this behaviour: | ||
Copy the contents of `.env.local` into `.env` | ||
|
||
1. Update .env, changing: | ||
|
||
``` | ||
CAS1_E2E_CHECK_EMAILS=true | ||
NOTIFY_API_KEY=set to the local-e2e test key (speak to collegues) | ||
``` | ||
If you also want to test emails, review the 'Testing Emails' section below | ||
|
||
2. In the api project, update application-local.yml, adding the following: | ||
Then start the tests using one of the following: | ||
|
||
``` | ||
notify: | ||
mode: TEST_AND_GUEST_LIST | ||
api-key: aforementioned NOTIFY_API_KEY value | ||
guest-list-api-key: aforementioned NOTIFY_API_KEY value | ||
npm run test:e2e:local | ||
npm run test:e2e:local:ui | ||
``` | ||
|
||
#### Running locally but using upstream dev services (emulate tests that run in 'dev') | ||
#### Running against UI/API hosted in your local dev environment against upstream services in dev (emulate circle ci e2e test execution) | ||
|
||
Start ap-tools as follows: | ||
First start the ap-tools using | ||
|
||
```shell | ||
docker compose down --clear-databases | ||
``` | ||
ap-tools server stop --clear-databases | ||
ap-tools server start --local-ui --local-api-dev-upstream | ||
``` | ||
|
||
Use this in .env | ||
|
||
```shell | ||
API_CLIENT_ID=approved-premises-ui | ||
APPROVED_PREMISES_API_URL=http://localhost:8080 | ||
CAS1_E2E_ADMINISTRATOR_PASSWORD=doesntmatter | ||
CAS1_E2E_ADMINISTRATOR_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_ASSESSOR_EMAIL=stuart.harrison2+test1@digital.justice.gov.uk | ||
CAS1_E2E_ASSESSOR_NAME=AP_USER TEST_1 | ||
CAS1_E2E_ASSESSOR_PASSWORD=doesntmatter | ||
CAS1_E2E_ASSESSOR_USERNAME=AP_USER_TEST_1 | ||
CAS1_E2E_CRU_MEMBER_PASSWORD=doesntmatter | ||
CAS1_E2E_CRU_MEMBER_USERNAME=AP_USER_TEST_4 | ||
CAS1_E2E_DELIUS_USERNAME_TO_ADD_AND_DELETE=JOSEPHHOLLINSHEAD | ||
CAS1_E2E_EMERGENCY_ASSESSOR_NAME_TO_ALLOCATE_TO=AP_USER TEST_1 | ||
CAS1_E2E_FUTURE_MANAGER_PASSWORD=doesntmatter | ||
CAS1_E2E_FUTURE_MANAGER_USERNAME=AP_USER_TEST_4 | ||
CAS1_E2E_PERSON_FOR_ADHOC_BOOKING_CRN=X349420 | ||
CAS1_E2E_REPORT_VIEWER_PASSWORD=doesntmatter | ||
CAS1_E2E_REPORT_VIEWER_USERNAME=AP_USER_TEST_2 | ||
CAS1_E2E_USER_WITHOUT_ROLES_PASSWORD=doesntmatter | ||
CAS1_E2E_USER_WITHOUT_ROLES_USERNAME=AP_USER_TEST_1 | ||
CAS1_E2E_CHECK_EMAILS=false | ||
HMPPS_AUTH_EXTERNAL_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_NAME=AP_USER TEST_1 | ||
HMPPS_AUTH_PASSWORD=*REDACTED* | ||
HMPPS_AUTH_URL=http://localhost:9091/auth | ||
HMPPS_AUTH_USERNAME=AP_USER_TEST_1 | ||
SYSTEM_CLIENT_ID=approved-premises-api | ||
ENABLE_V2_MATCH=true | ||
``` | ||
Copy the contents of `.env.local-dev-upstream` into `.env` | ||
|
||
If you also want to test emails, review the 'Testing Emails' section below | ||
|
||
Then start using one of | ||
Then start the tests using one of the following: | ||
|
||
``` | ||
npx playwright test --config ./e2e/playwright.config.ts --project=local-dev-upstream | ||
npx playwright test --config ./e2e/playwright.config.ts --project=local-dev-upstream --ui | ||
npm run test:e2e:local-dev-upstream | ||
npm run test:e2e:local-dev-upstream:ui | ||
``` | ||
|
||
#### CLI commands | ||
### Testing Emails | ||
|
||
Headless: | ||
The E2E test do not check emails by default. To enable this in the e2e tests update the .env file, changing: | ||
|
||
```bash | ||
npm run test:e2e:local | ||
# -> npx playwright test --config ./e2e/playwright.config.ts --project=local | ||
``` | ||
CAS1_E2E_CHECK_EMAILS=true | ||
NOTIFY_API_KEY=set to the local-e2e test key (speak to collegues) | ||
``` | ||
|
||
With UI: | ||
If then API is also running locally, that will need configuring to send emails to notify: | ||
|
||
```bash | ||
npm run test:e2e:local:ui | ||
# -> npx playwright test --config ./e2e/playwright.config.ts --project=local --ui | ||
``` | ||
|
||
When running with UI it may select 'setupLocal' project by default. Click on projects and select 'local' too to see all tests | ||
notify: | ||
mode: TEST_AND_GUEST_LIST | ||
api-key: aforementioned NOTIFY_API_KEY value | ||
guest-list-api-key: aforementioned NOTIFY_API_KEY value | ||
``` | ||
|
||
## Feature flags | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters