From 52b02262fe6e5820d1eefc7ea1deebcead44c80c Mon Sep 17 00:00:00 2001 From: dominicwest <101722961+dominicwest@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:58:25 +0100 Subject: [PATCH 1/3] Fixing uploading accessibility report format (#197) * Fixing uploading accessibility report format * Replace all illegal chars in filename --- .github/workflows/reusable_e2e_test_run.yml | 5 +++-- cypress/common/common.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable_e2e_test_run.yml b/.github/workflows/reusable_e2e_test_run.yml index e2bd0e7..724a0e3 100644 --- a/.github/workflows/reusable_e2e_test_run.yml +++ b/.github/workflows/reusable_e2e_test_run.yml @@ -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() }} diff --git a/cypress/common/common.ts b/cypress/common/common.ts index bd57524..6b18c96 100644 --- a/cypress/common/common.ts +++ b/cypress/common/common.ts @@ -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`, From ee8c9e9004d68ccb6fa2d9af60dfe63d77373c6b Mon Sep 17 00:00:00 2001 From: Conor Fayle <141320269+ConorFayleTCO@users.noreply.github.com> Date: Mon, 6 May 2024 15:59:51 +0100 Subject: [PATCH 2/3] update setup docs and .env.example (#200) Co-authored-by: conor --- .env.example | 22 ++++++++++++---------- SETUP.md | 35 +++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.env.example b/.env.example index e10090e..516a974 100644 --- a/.env.example +++ b/.env.example @@ -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 ONE_LOGIN_APPLICANT_EMAIL=example+applicant@cabinetoffice.gov.uk ONE_LOGIN_APPLICANT_PASSWORD=example_password ONE_LOGIN_APPLICANT_SUB=urn:fdc:gov.uk:20XX:1234567890qwertyuiopasdfghjklzxcvbnm @@ -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 @@ -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 diff --git a/SETUP.md b/SETUP.md index 0be9c2f..9aee3e9 100644 --- a/SETUP.md +++ b/SETUP.md @@ -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. example.name+e2e_applicant@cabinetoffice.gov.uk + 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: ``` ONE_LOGIN_APPLICANT_EMAIL=example+applicant@cabinetoffice.gov.uk ONE_LOGIN_APPLICANT_SUB=urn:fdc:gov.uk:20XX:1234567890qwertyuiopasdfghjklzxcvbnm @@ -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. From ae8c88413feccb593a7bfc4c2b4aae78b9f354cc Mon Sep 17 00:00:00 2001 From: dominicwest <101722961+dominicwest@users.noreply.github.com> Date: Wed, 15 May 2024 11:52:57 +0100 Subject: [PATCH 3/3] Delete .github/workflows/scheduled_e2e_test_run.yml (#201) --- .github/workflows/scheduled_e2e_test_run.yml | 27 -------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/scheduled_e2e_test_run.yml diff --git a/.github/workflows/scheduled_e2e_test_run.yml b/.github/workflows/scheduled_e2e_test_run.yml deleted file mode 100644 index 80f270a..0000000 --- a/.github/workflows/scheduled_e2e_test_run.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Scheduled E2E Test Run Workflow - -on: - schedule: - - cron: "0 4 * * 1-5" # every weekday at 4am - -jobs: - call-sandbox-reusable-e2e-test-run-workflow: - name: Sandbox E2E Test Run - uses: ./.github/workflows/reusable_multi_browser_e2e_test_run.yml - with: - notify: true - environment: SANDBOX - branch: develop - secrets: inherit - - call-qa-reusable-e2e-test-run-workflow: - name: QA E2E Test Run - uses: ./.github/workflows/reusable_multi_browser_e2e_test_run.yml - with: - notify: true - environment: QA - branch: main - secrets: inherit - if: ${{ vars.SHOULD_RUN_SCHEDULED_QA_TESTS == 'true' }} - - # =============================