Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main #202

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# You should not have any spaces separating = or the vpc:add script won't work
# You should not have any spaces separating = or the vpc:add script won't work (not much of an issue anymore since we auth through VPN)

ONE_LOGIN_BASE_URL=signin.integration.account.gov.uk
ONE_LOGIN_USERNAME=example_user
ONE_LOGIN_PASSWORD=example_password

APPLICATION_BASE_URL=https://www.google.com
POST_LOGIN_BASE_URL=https://www.google.com
[email protected]
ONE_LOGIN_APPLICANT_PASSWORD=example_password
ONE_LOGIN_APPLICANT_SUB=urn:fdc:gov.uk:20XX:1234567890qwertyuiopasdfghjklzxcvbnm
Expand All @@ -19,11 +13,18 @@ ONE_LOGIN_TECHNICAL_SUPPORT_EMAIL=example+technical_support@cabinetoffice.gov.uk
ONE_LOGIN_TECHNICAL_SUPPORT_PASSWORD=example_password
ONE_LOGIN_TECHNICAL_SUPPORT_SUB=urn:fdc:gov.uk:20XX:1234567890qwertyuiopasdfghjklzxcvbnm

USERS_DATABASE_URL=postgres://postgres:postgres@localhost:5432
ONE_LOGIN_BASE_URL=signin.integration.account.gov.uk
ONE_LOGIN_USERNAME=example_user
ONE_LOGIN_PASSWORD=example_password

APPLICATION_BASE_URL=https://www.google.com
POST_LOGIN_BASE_URL=https://www.google.com

USERS_DATABASE_URL=postgres://postgres_username:postgres_password@localhost:5432
USERS_DATABASE_NAME=userdbname
APPLY_DATABASE_URL=postgres://postgres:postgres@localhost:5432
APPLY_DATABASE_URL=postgres://postgres_username:postgres_password@localhost:5432
APPLY_DATABASE_NAME=applydbname
FIND_DATABASE_URL=postgres://postgres:postgres@localhost:5432
FIND_DATABASE_URL=postgres://postgres_username:postgres_password@localhost:5432
FIND_DATABASE_NAME=finddbname

CONTENTFUL_SPACE_ID=spaceId
Expand All @@ -43,4 +44,5 @@ AWS_API_GATEWAY_SECRET_KEY=1234567890123456789012345678901234567890
AWS_API_GATEWAY_USAGE_PLAN_ID=1234567890
AWS_ENVIRONMENT=dev

# This value MUST be unique to each user
FIRST_USER_ID=1
5 changes: 3 additions & 2 deletions .github/workflows/reusable_e2e_test_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,14 @@ jobs:
if: ${{ !cancelled() && failure() }}

- name: Set current date as env variable
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
id: now
run: echo "NOW=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_ENV
if: ${{ !cancelled() }}

- name: Upload accessibility report
uses: actions/upload-artifact@v4
with:
name: accessibility-report-${{ inputs.environment }}-${{ inputs.browser }}-${{ env.NOW }}
name: accessibility-report-${{ inputs.environment }}-${{ inputs.browser }}-${{ steps.now.outputs.NOW }}
path: /home/runner/work/gap-automated-tests/gap-automated-tests/cypress/accessibility/logs
retention-days: 30
if: ${{ !cancelled() }}
27 changes: 0 additions & 27 deletions .github/workflows/scheduled_e2e_test_run.yml

This file was deleted.

35 changes: 23 additions & 12 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

- To install dependencies, run `npm install`
- You'll then need to copy the `.env.example` file to a file called `.env` and enter the login in details for the accounts you will use for testing. You can obtain these by following the steps below.
- `ONE_LOGIN_SANDBOX_` properties used for signing in to the One Login integration environment - this is a static username/password for the whole environment, and you can obtain these by speaking to Conor Fayle (or probably most devs by this point).
- The other email/password combinations are for specific accounts.
- `ONE_LOGIN_USERNAME` & `ONE_LOGIN_PASSWORD` properties used for signing in to the One Login integration environment - this is a static username/password for the whole environment, and you can obtain these and most other env vars by speaking to Arul. Most env vars are also obtainable via AWS.
- QA technically does not need authorisation, but the tests expect these env vars to be available so you can just use the same ones as in sandbox.
- The other email/password/sub combinations are for specific account roles, and should be unique to each user. You should generate them yourself using the steps below.
- ESLint, Prettier and Husky are installed, so your code will auto-format when committing changes.
- Make sure you are connected to the correct VPN for the environment you are running on - you should have been issued with your own VPN profiles which you can use with OpenVPN.
- Tests can be run against QA or Sandbox. You'll need to have the appropriate .env file in order to be able to run tests against each environment. The current `.env` file in use should be called simply `.env` and the other should be called `.env.qa` or `.env.sandbox` respectively.
- There is a command to switch your current environment between the two: `npm run env:switch`
- You will need to set up 3 users with One Login, and use these to run E2E tests locally. Steps:
- There is a command to switch your current environment between the two: `npm run env:switch` (remember to switch your VPN as well)
- You will need to set up 4 users with One Login, and use these to run E2E tests locally. Steps:
1. Go to Find a Grant for the environment you wish to run against
2. Click `Sign in and Apply`
3. Create a new account for the intended role (you can use the + trick to generate a "new" email still linked to your inbox) until you reach the dashboard **(passwords cannot contain #)**
4. Repeat steps 2-3 for applicant, admin and super admin
5. Put each of these 3 emails into the .env under ONE_LOGIN_APPLICANT_EMAIL, ONE_LOGIN_ADMIN_EMAIL and ONE_LOGIN_SUPER_ADMIN_EMAIL appropriately.
6. Add yourself to the VPC if you haven't already (`npm run vpc:add`)
7. Run `npm run subs` to get the subs for each of your users
3. Create a new account for the intended role (you can use the + trick to generate a "new" email still linked to your inbox) until you reach the dashboard. **(passwords cannot contain #)**
- e.g. [email protected]
4. Repeat steps 2-3 until you have created an applicant, admin, super admin and tech support user (they do not need to actually have that role at this step, just named appropriately)
5. Put each of these 4 emails into the .env under ONE_LOGIN_APPLICANT_EMAIL, ONE_LOGIN_ADMIN_EMAIL, ONE_LOGIN_SUPER_ADMIN_EMAIL and ONE_LOGIN_TECHNICAL_SUPPORT_EMAIL appropriately.
6. In terminal at the root of the project, run `npm run subs` to get the subs for each of your users. Example output:
```
[email protected]
ONE_LOGIN_APPLICANT_SUB=urn:fdc:gov.uk:20XX:1234567890qwertyuiopasdfghjklzxcvbnm
Expand All @@ -26,7 +27,17 @@
ONE_LOGIN_SUPER_ADMIN_EMAIL=example+super_admin@cabinetoffice.gov.uk
ONE_LOGIN_SUPER_ADMIN_SUB=urn:fdc:gov.uk:20XX:1234567890qwertyuiopasdfghjklzxcvbnm
ONE_LOGIN_SUPER_ADMIN_PASSWORD=XXXXXXXX
ONE_LOGIN_TECHNICAL_SUPPORT_EMAIL=example+technical_support@cabinetoffice.gov.uk
ONE_LOGIN_TECHNICAL_SUPPORT_SUB=urn:fdc:gov.uk:20XX:1234567890qwertyuiopasdfghjklzxcvbnm
ONE_LOGIN_TECHNICAL_SUPPORT_PASSWORD=example_password
```
8. Copy the output into your .env
9. Fill in the passwords
- You _must_ set the .env FIRST_USER_ID to a number unique to yourself. It will iterate up by the number of users and grants (3 at the time of writing) so please ensure there are no collisions.
7. Copy the output into your .env
8. Fill in the passwords
9. Add a unique FIRST_USER_ID to your `.env`.
- You _must_ set the .env FIRST_USER_ID to a number unique to yourself.
- It will iterate up by the number of users and grants (4 at the time of writing) so please ensure there are no collisions.
- Incrementing IDs by 10 for each person running tests is safe.
- Note that the users and grants etc that are created will have NEGATIVE ids to ensure they don't collide with existing data. Only E2E test data should have negative IDs.
- To check existing IDs you can perform the following DB query against the users DB for the appropriate environment:
- `SELECT gap_user_id, email, sub, dept_id FROM public.gap_users WHERE gap_user_id < 0;`
9. Now when you run the tests, the existing users will be purged and recreated with the appropriate roles and IDs.
3 changes: 2 additions & 1 deletion cypress/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ function accessibilityLogInfo(violationData) {
const info = formatAccessibilityViolations(violationData, url);

const specName = Cypress.spec.name;
const testName = Cypress.currentTest.title;
// Replaces all illegal chars for a filename
const testName = Cypress.currentTest.title.replace(/[<>"=/\\]/g, '');

cy.writeFile(
`cypress/accessibility/logs/${specName}/${testName}.md`,
Expand Down
Loading