From 1436334563326ca5d51e197072c965fb48ac9121 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Tue, 2 Jan 2024 13:59:36 +0000 Subject: [PATCH 01/28] Add smoke logout test --- .../e2e/1-ndr-smoke-tests/homepage.cy.js | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js index 96691d02b..cf1fd5cb9 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js @@ -36,7 +36,37 @@ describe('Home Page', () => { cy.get('.nhsuk-header__navigation').should('exist'); cy.get('.nhsuk-header__navigation-list').should('exist'); }, + ); + + it.only( + '[Smoke] should display home page with no navigation after user log out', + { tags: 'smoke' }, + () => { + cy.get('header').should('exist'); + + cy.get('.nhsuk-logo__background').should('exist'); + cy.get('.nhsuk-header__transactional-service-name').should('exist'); + cy.get('.nhsuk-header__transactional-service-name').children().should('have.length', 1); + cy.get('.nhsuk-header__transactional-service-name--link').should('exist'); + cy.get('.nhsuk-header__transactional-service-name--link').should( + 'have.text', + 'Access and store digital GP records', + ); + cy.get('.nhsuk-header__navigation').should('not.exist'); + cy.get('.nhsuk-header__navigation-list').should('not.exist'); - //TODO: Add logout test + cy.smokeLogin(Roles.GP_CLINICAL); + + cy.url().should('eq', baseUrl + searchUrl); + cy.get('.nhsuk-header__navigation').should('exist'); + cy.get('.nhsuk-header__navigation-list').should('exist'); + + cy.getByTestId('logout-btn').should('exist'); + cy.getByTestId('logout-btn').click(); + cy.url({ timeout: 10000 }).should('contain', baseUrl + homeUrl); + + cy.get('.nhsuk-header__navigation').should('not.exist'); + cy.get('.nhsuk-header__navigation-list').should('not.exist'); + }, ); }); From 460bb6aa534d38008790d5f7f533abc6b7941909 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Tue, 2 Jan 2024 15:03:59 +0000 Subject: [PATCH 02/28] Finish homepage smoke tests --- .../e2e/0-ndr-core-tests/homepage.cy.js | 54 +++++++--- .../e2e/1-ndr-smoke-tests/homepage.cy.js | 102 ++++++++++-------- 2 files changed, 92 insertions(+), 64 deletions(-) diff --git a/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js b/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js index 5f5bac141..871490d4c 100644 --- a/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js @@ -12,6 +12,25 @@ describe('Home Page', () => { cy.url().should('eq', baseUrl + homeUrl); }); + it('displays correct page title on home page', { tags: 'regression' }, () => { + cy.get('.app-homepage-content h1').should( + 'have.text', + 'Access and store digital GP records', + ); + }); + + it('displays start now button on home page', { tags: 'regression' }, () => { + cy.get('.nhsuk-button').should('have.text', 'Start now'); + }); + + it('displays service banner', { tags: 'regression' }, () => { + cy.get('.govuk-phase-banner__content__tag').should('have.text', 'New Service'); + cy.get('.govuk-phase-banner__text').should( + 'have.text', + 'Your feedback will help us to improve this service.', + ); + }); + context('Login tests', () => { it( 'should display patient search page with navigation after user log in from homepage', @@ -42,37 +61,38 @@ describe('Home Page', () => { }); context('Logout tests', () => { - // TODO: Align with smoke logout test it( 'should display home page with no navigation after user log out', { tags: 'regression' }, () => { - cy.get('header').should('have.length', 1); + cy.get('header').should('exist'); - cy.get('.nhsuk-logo__background').should('have.length', 1); - cy.get('.nhsuk-header__transactional-service-name').should('have.length', 1); + cy.get('.nhsuk-logo__background').should('exist'); + cy.get('.nhsuk-header__transactional-service-name').should('exist'); cy.get('.nhsuk-header__transactional-service-name') .children() .should('have.length', 1); + cy.get('.nhsuk-header__transactional-service-name--link').should('exist'); cy.get('.nhsuk-header__transactional-service-name--link').should( 'have.text', 'Access and store digital GP records', ); + cy.get('.nhsuk-header__navigation').should('not.exist'); + cy.get('.nhsuk-header__navigation-list').should('not.exist'); - cy.get('.nhsuk-header__navigation').should('have.length', 0); - cy.get('.nhsuk-header__navigation-list').should('have.length', 0); - }, - ); + cy.login(Roles.GP_CLINICAL); + + cy.url().should('eq', baseUrl + searchUrl); + cy.get('.nhsuk-header__navigation').should('exist'); + cy.get('.nhsuk-header__navigation-list').should('exist'); - it('displays correct page title on home page', { tags: 'regression' }, () => { - cy.get('.app-homepage-content h1').should( - 'have.text', - 'Access and store digital GP records', - ); - }); + cy.getByTestId('logout-btn').should('exist'); + cy.getByTestId('logout-btn').click(); + cy.url({ timeout: 10000 }).should('contain', baseUrl + homeUrl); - it('displays start now button on home page', { tags: 'regression' }, () => { - cy.get('.nhsuk-button').should('have.text', 'Start now'); - }); + cy.get('.nhsuk-header__navigation').should('not.exist'); + cy.get('.nhsuk-header__navigation-list').should('not.exist'); + }, + ); }); }); diff --git a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js index cf1fd5cb9..342d55729 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js @@ -13,60 +13,68 @@ describe('Home Page', () => { cy.url().should('eq', baseUrl + homeUrl); }); - it( - '[Smoke] should display patient search page with navigation after user log in from homepage', - { tags: 'smoke' }, - () => { - cy.get('header').should('exist'); + context('Login tests', () => { + it( + '[Smoke] should display patient search page with navigation after user log in from homepage', + { tags: 'smoke' }, + () => { + cy.get('header').should('exist'); - cy.get('.nhsuk-logo__background').should('exist'); - cy.get('.nhsuk-header__transactional-service-name').should('exist'); - cy.get('.nhsuk-header__transactional-service-name').children().should('have.length', 1); - cy.get('.nhsuk-header__transactional-service-name--link').should('exist'); - cy.get('.nhsuk-header__transactional-service-name--link').should( - 'have.text', - 'Access and store digital GP records', - ); - cy.get('.nhsuk-header__navigation').should('not.exist'); - cy.get('.nhsuk-header__navigation-list').should('not.exist'); + cy.get('.nhsuk-logo__background').should('exist'); + cy.get('.nhsuk-header__transactional-service-name').should('exist'); + cy.get('.nhsuk-header__transactional-service-name') + .children() + .should('have.length', 1); + cy.get('.nhsuk-header__transactional-service-name--link').should('exist'); + cy.get('.nhsuk-header__transactional-service-name--link').should( + 'have.text', + 'Access and store digital GP records', + ); + cy.get('.nhsuk-header__navigation').should('not.exist'); + cy.get('.nhsuk-header__navigation-list').should('not.exist'); - cy.smokeLogin(Roles.GP_CLINICAL); + cy.smokeLogin(Roles.GP_CLINICAL); - cy.url().should('eq', baseUrl + searchUrl); - cy.get('.nhsuk-header__navigation').should('exist'); - cy.get('.nhsuk-header__navigation-list').should('exist'); - }, - ); + cy.url().should('eq', baseUrl + searchUrl); + cy.get('.nhsuk-header__navigation').should('exist'); + cy.get('.nhsuk-header__navigation-list').should('exist'); + }, + ); + }); - it.only( - '[Smoke] should display home page with no navigation after user log out', - { tags: 'smoke' }, - () => { - cy.get('header').should('exist'); + context('Logout tests', () => { + it( + '[Smoke] should display home page with no navigation after user log out', + { tags: 'smoke' }, + () => { + cy.get('header').should('exist'); - cy.get('.nhsuk-logo__background').should('exist'); - cy.get('.nhsuk-header__transactional-service-name').should('exist'); - cy.get('.nhsuk-header__transactional-service-name').children().should('have.length', 1); - cy.get('.nhsuk-header__transactional-service-name--link').should('exist'); - cy.get('.nhsuk-header__transactional-service-name--link').should( - 'have.text', - 'Access and store digital GP records', - ); - cy.get('.nhsuk-header__navigation').should('not.exist'); - cy.get('.nhsuk-header__navigation-list').should('not.exist'); + cy.get('.nhsuk-logo__background').should('exist'); + cy.get('.nhsuk-header__transactional-service-name').should('exist'); + cy.get('.nhsuk-header__transactional-service-name') + .children() + .should('have.length', 1); + cy.get('.nhsuk-header__transactional-service-name--link').should('exist'); + cy.get('.nhsuk-header__transactional-service-name--link').should( + 'have.text', + 'Access and store digital GP records', + ); + cy.get('.nhsuk-header__navigation').should('not.exist'); + cy.get('.nhsuk-header__navigation-list').should('not.exist'); - cy.smokeLogin(Roles.GP_CLINICAL); + cy.smokeLogin(Roles.GP_CLINICAL); - cy.url().should('eq', baseUrl + searchUrl); - cy.get('.nhsuk-header__navigation').should('exist'); - cy.get('.nhsuk-header__navigation-list').should('exist'); + cy.url().should('eq', baseUrl + searchUrl); + cy.get('.nhsuk-header__navigation').should('exist'); + cy.get('.nhsuk-header__navigation-list').should('exist'); - cy.getByTestId('logout-btn').should('exist'); - cy.getByTestId('logout-btn').click(); - cy.url({ timeout: 10000 }).should('contain', baseUrl + homeUrl); + cy.getByTestId('logout-btn').should('exist'); + cy.getByTestId('logout-btn').click(); + cy.url({ timeout: 10000 }).should('contain', baseUrl + homeUrl); - cy.get('.nhsuk-header__navigation').should('not.exist'); - cy.get('.nhsuk-header__navigation-list').should('not.exist'); - }, - ); + cy.get('.nhsuk-header__navigation').should('not.exist'); + cy.get('.nhsuk-header__navigation-list').should('not.exist'); + }, + ); + }); }); From 11e99426e92a576f84838dacf1cdd4d67c07844a Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Tue, 2 Jan 2024 15:27:48 +0000 Subject: [PATCH 03/28] Add tests for GP patient search --- .../patient_search_and_verify_workflow.cy.js | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js new file mode 100644 index 000000000..ef0af50ce --- /dev/null +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -0,0 +1,95 @@ +import { Roles, roleName } from '../../../support/roles'; + +describe('GP Workflow: Patient search and verify', () => { + // env vars + const baseUrl = Cypress.config('baseUrl'); + const gpRoles = [Roles.GP_ADMIN, Roles.GP_CLINICAL]; + + const testNotFoundPatient = '1000000001'; + const activePatient = '9449305552'; + const inactivePatient = '9449305552'; + + gpRoles.forEach((role) => { + beforeEach(() => { + cy.smokeLogin(role); + }); + + it( + `[Smoke] Shows patient upload screen when patient search is used by as a + ${roleName(role)} and patient response is inactive`, + { tags: 'smoke' }, + () => { + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(inactivePatient); + + cy.get('#search-submit').click(); + + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); + cy.get('#gp-message').should('be.visible'); + cy.get('#gp-message').should( + 'have.text', + 'Ensure these patient details match the records and attachments that you upload', + ); + cy.get('#verify-submit').click(); + + cy.url().should('include', 'submit'); + cy.url().should('eq', baseUrl + '/upload/submit'); + }, + ); + + it.only( + `[Smoke] Does not show verify patient view when the search finds no patient as ${roleName( + role, + )}`, + { tags: 'smoke' }, + () => { + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(testNotFoundPatient); + + cy.get('#search-submit').click(); + + cy.get('#nhs-number-input--error-message').should('be.visible'); + cy.get('#nhs-number-input--error-message').should( + 'have.text', + 'Error: Sorry, patient data not found.', + ); + cy.get('#error-box-summary').should('be.visible'); + cy.get('#error-box-summary').should('have.text', 'There is a problem'); + }, + ); + + it( + `[Smoke] Shows the upload documents page when upload patient is verified and inactive as a ${roleName( + role, + )} `, + { tags: 'smoke' }, + () => { + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(inactivePatient); + cy.get('#search-submit').click(); + + cy.get('#verify-submit').click(); + + cy.url().should('include', 'submit'); + cy.url().should('eq', baseUrl + '/upload/submit'); + }, + ); + + it( + `[Smoke] Shows the Lloyd george view page when upload patient is verified and active as a ${roleName( + role, + )} `, + { tags: 'smoke' }, + () => { + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(activePatient); + cy.get('#search-submit').click(); + + cy.get('#verify-submit').click(); + + cy.url().should('include', 'lloyd-george-record'); + cy.url().should('eq', baseUrl + '/search/patient/lloyd-george-record'); + }, + ); + }); +}); From 6df364e4cfce6dba0d6dd70da673517149d0d662 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 10:01:40 +0000 Subject: [PATCH 04/28] Add smoke tests for pcse workflow --- .../patient_search_and_verify_workflow.cy.js | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js diff --git a/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js new file mode 100644 index 000000000..87ffbd5ba --- /dev/null +++ b/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js @@ -0,0 +1,63 @@ +const { Roles } = require('../../../support/roles'); + +describe('PCSE Workflow: patient search and verify', () => { + // env vars + const baseUrl = Cypress.config('baseUrl'); + const homeUrl = '/'; + + beforeEach(() => { + cy.visit(homeUrl); + }); + + it( + '[Smoke] It redirects to the patient download screen when patient search successfully by a PCSE user', + { tags: 'smoke' }, + () => { + const activePatient = '9449305552'; + cy.smokeLogin(Roles.PCSE); + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(activePatient); + + cy.get('#search-submit').click(); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/patient/result'); + cy.get('#gp-message').should('not.exist'); + + cy.get('#verify-submit').click(); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/results'); + }, + ); + + it( + '[Smoke] It searches for a valid patient successfully when the user enters a known nhs number with spaces by a PCSE user', + { tags: 'smoke' }, + () => { + const activePatient = '944 930 5552'; + cy.smokeLogin(Roles.PCSE); + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(activePatient); + + cy.get('#search-submit').click(); + cy.wait('@search'); + + cy.url().should('include', 'result'); + cy.url().should('eq', baseUrl + '/search/patient/result'); + }, + ); + + it( + '[Smoke] It searches for a valid patient successfully when the user enters a known nhs number with dashes by a PCSE user', + { tags: 'smoke' }, + () => { + const activePatient = '944-930-5552'; + + cy.smokeLogin(Roles.PCSE); + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(activePatient); + + cy.get('#search-submit').click(); + + cy.url().should('include', 'result'); + cy.url().should('eq', baseUrl + '/search/patient/result'); + }, + ); +}); From a2177fce33e544dfb5c1661fe622848957fa7000 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 10:02:49 +0000 Subject: [PATCH 05/28] Remove search stubs from pcse tests --- .../patient_search_and_verify_workflow.cy.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js index 87ffbd5ba..2ac919a12 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js @@ -37,10 +37,11 @@ describe('PCSE Workflow: patient search and verify', () => { cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); - cy.wait('@search'); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/patient/result'); + cy.get('#gp-message').should('not.exist'); - cy.url().should('include', 'result'); - cy.url().should('eq', baseUrl + '/search/patient/result'); + cy.get('#verify-submit').click(); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/results'); }, ); @@ -55,9 +56,11 @@ describe('PCSE Workflow: patient search and verify', () => { cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/patient/result'); + cy.get('#gp-message').should('not.exist'); - cy.url().should('include', 'result'); - cy.url().should('eq', baseUrl + '/search/patient/result'); + cy.get('#verify-submit').click(); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/results'); }, ); }); From b26e316213c72f8e3dd1427561a4815d477c73d6 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 10:39:41 +0000 Subject: [PATCH 06/28] Remove duplicate test cases --- .../patient_search_and_verify_workflow.cy.js | 54 ++----------------- .../patient_search_and_verify_workflow.cy.js | 2 +- 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js index 6f1f1c790..6fd10fdc5 100644 --- a/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js @@ -4,12 +4,11 @@ describe('PCSE Workflow: patient search and verify', () => { // env vars const baseUrl = Cypress.config('baseUrl'); const homeUrl = '/'; - const testPatient = '9000000009'; const patient = { birthDate: '1970-01-01', familyName: 'Default Surname', givenName: ['Default Given Name'], - nhsNumber: testPatient, + nhsNumber: '9000000009', postalCode: 'AA1 1AA', superseded: false, restricted: false, @@ -19,37 +18,11 @@ describe('PCSE Workflow: patient search and verify', () => { cy.visit(homeUrl); }); - it( - 'It redirects to the patient download screen when patient search successfully by a PCSE user', - { tags: 'regression' }, - () => { - cy.intercept('GET', '/SearchPatient*', { - statusCode: 200, - body: patient, - }).as('search'); - - cy.login(Roles.PCSE); - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(testPatient); - - cy.get('#search-submit').click(); - cy.wait('@search'); - - cy.url().should('include', 'result'); - cy.url().should('eq', baseUrl + '/search/patient/result'); - cy.get('#gp-message').should('not.exist'); - - cy.get('#verify-submit').click(); - - cy.url().should('include', 'results'); - cy.url().should('eq', baseUrl + '/search/results'); - }, - ); - it( 'It shows the download documents page when download patient is verified by a PCSE user', { tags: 'regression' }, () => { + const testPatient = '9000000009'; cy.login(Roles.PCSE); cy.intercept('GET', '/SearchPatient*', { statusCode: 200, @@ -66,31 +39,11 @@ describe('PCSE Workflow: patient search and verify', () => { }, ); - it( - 'It searches for a valid patient successfully when the user enters a known nhs number by a PCSE user', - { tags: 'regression' }, - () => { - cy.intercept('GET', '/SearchPatient*', { - statusCode: 200, - body: patient, - }).as('search'); - - cy.login(Roles.PCSE); - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(testPatient); - - cy.get('#search-submit').click(); - cy.wait('@search'); - - cy.url().should('include', 'result'); - cy.url().should('eq', baseUrl + '/search/patient/result'); - }, - ); - it( 'It searches for a valid patient successfully when the user enters a known nhs number with spaces by a PCSE user', { tags: 'regression' }, () => { + const testPatient = '900 000 0009'; cy.intercept('GET', '/SearchPatient*', { statusCode: 200, body: { @@ -114,6 +67,7 @@ describe('PCSE Workflow: patient search and verify', () => { 'It searches for a valid patient successfully when the user enters a known nhs number with dashes by a PCSE user', { tags: 'regression' }, () => { + const testPatient = '900-000-0009'; cy.intercept('GET', '/SearchPatient*', { statusCode: 200, body: { diff --git a/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js index 2ac919a12..a4232939a 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js @@ -10,7 +10,7 @@ describe('PCSE Workflow: patient search and verify', () => { }); it( - '[Smoke] It redirects to the patient download screen when patient search successfully by a PCSE user', + '[Smoke] It shows the download documents page when download patient is verified by a PCSE user', { tags: 'smoke' }, () => { const activePatient = '9449305552'; From 24970fd5e6861abf6c89b3684567a7fc871e0365 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 14:14:26 +0000 Subject: [PATCH 07/28] Add workspace environment variable --- .github/workflows/ui-smoketest.yml | 4 +- app/cypress.config.ts | 1 + .../patient_search_and_verify_workflow.cy.js | 71 +------------------ .../patient_search_and_verify_workflow.cy.js | 66 ----------------- 4 files changed, 7 insertions(+), 135 deletions(-) delete mode 100644 app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 4fd43f546..9dabf9dd9 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -26,7 +26,6 @@ permissions: contents: read # This is required for actions/checkout jobs: - cypress-run-chrome: runs-on: ubuntu-22.04 environment: ${{ github.event.inputs.environment }} @@ -51,6 +50,7 @@ jobs: env: CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk' CYPRESS_grepTags: 'smoke' + CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} @@ -78,6 +78,7 @@ jobs: env: CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk' CYPRESS_grepTags: 'smoke' + CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} @@ -105,5 +106,6 @@ jobs: env: CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk' CYPRESS_grepTags: 'smoke' + CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} diff --git a/app/cypress.config.ts b/app/cypress.config.ts index 6d8c37e00..2827269b6 100644 --- a/app/cypress.config.ts +++ b/app/cypress.config.ts @@ -14,6 +14,7 @@ export default defineConfig({ env: { USERNAME: process.env.CYPRESS_USERNAME, PASSWORD: process.env.CYPRESS_PASSWORD, + WORKSPACE: process.env.CYPRESS_WORKSPACE ?? 'local', }, component: { devServer: { diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index ef0af50ce..82c4e4392 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -5,82 +5,17 @@ describe('GP Workflow: Patient search and verify', () => { const baseUrl = Cypress.config('baseUrl'); const gpRoles = [Roles.GP_ADMIN, Roles.GP_CLINICAL]; - const testNotFoundPatient = '1000000001'; - const activePatient = '9449305552'; - const inactivePatient = '9449305552'; + const workspace = Cypress.env('WORKSPACE'); + const activePatient = workspace === 'ndr-dev' ? '9730153817' : '9449305552'; gpRoles.forEach((role) => { - beforeEach(() => { - cy.smokeLogin(role); - }); - - it( - `[Smoke] Shows patient upload screen when patient search is used by as a - ${roleName(role)} and patient response is inactive`, - { tags: 'smoke' }, - () => { - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(inactivePatient); - - cy.get('#search-submit').click(); - - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); - cy.get('#gp-message').should('be.visible'); - cy.get('#gp-message').should( - 'have.text', - 'Ensure these patient details match the records and attachments that you upload', - ); - cy.get('#verify-submit').click(); - - cy.url().should('include', 'submit'); - cy.url().should('eq', baseUrl + '/upload/submit'); - }, - ); - - it.only( - `[Smoke] Does not show verify patient view when the search finds no patient as ${roleName( - role, - )}`, - { tags: 'smoke' }, - () => { - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(testNotFoundPatient); - - cy.get('#search-submit').click(); - - cy.get('#nhs-number-input--error-message').should('be.visible'); - cy.get('#nhs-number-input--error-message').should( - 'have.text', - 'Error: Sorry, patient data not found.', - ); - cy.get('#error-box-summary').should('be.visible'); - cy.get('#error-box-summary').should('have.text', 'There is a problem'); - }, - ); - - it( - `[Smoke] Shows the upload documents page when upload patient is verified and inactive as a ${roleName( - role, - )} `, - { tags: 'smoke' }, - () => { - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(inactivePatient); - cy.get('#search-submit').click(); - - cy.get('#verify-submit').click(); - - cy.url().should('include', 'submit'); - cy.url().should('eq', baseUrl + '/upload/submit'); - }, - ); - it( `[Smoke] Shows the Lloyd george view page when upload patient is verified and active as a ${roleName( role, )} `, { tags: 'smoke' }, () => { + cy.smokeLogin(role); cy.get('#nhs-number-input').click(); cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); diff --git a/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js deleted file mode 100644 index a4232939a..000000000 --- a/app/cypress/e2e/1-ndr-smoke-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js +++ /dev/null @@ -1,66 +0,0 @@ -const { Roles } = require('../../../support/roles'); - -describe('PCSE Workflow: patient search and verify', () => { - // env vars - const baseUrl = Cypress.config('baseUrl'); - const homeUrl = '/'; - - beforeEach(() => { - cy.visit(homeUrl); - }); - - it( - '[Smoke] It shows the download documents page when download patient is verified by a PCSE user', - { tags: 'smoke' }, - () => { - const activePatient = '9449305552'; - cy.smokeLogin(Roles.PCSE); - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(activePatient); - - cy.get('#search-submit').click(); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/patient/result'); - cy.get('#gp-message').should('not.exist'); - - cy.get('#verify-submit').click(); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/results'); - }, - ); - - it( - '[Smoke] It searches for a valid patient successfully when the user enters a known nhs number with spaces by a PCSE user', - { tags: 'smoke' }, - () => { - const activePatient = '944 930 5552'; - cy.smokeLogin(Roles.PCSE); - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(activePatient); - - cy.get('#search-submit').click(); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/patient/result'); - cy.get('#gp-message').should('not.exist'); - - cy.get('#verify-submit').click(); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/results'); - }, - ); - - it( - '[Smoke] It searches for a valid patient successfully when the user enters a known nhs number with dashes by a PCSE user', - { tags: 'smoke' }, - () => { - const activePatient = '944-930-5552'; - - cy.smokeLogin(Roles.PCSE); - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(activePatient); - - cy.get('#search-submit').click(); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/patient/result'); - cy.get('#gp-message').should('not.exist'); - - cy.get('#verify-submit').click(); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/results'); - }, - ); -}); From 9ba2a086a09e12a3a97d3334c74a93f8410cad2d Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 14:44:05 +0000 Subject: [PATCH 08/28] Fix typescript errors on cypress configs --- app/cypress/support/aws.commands.ts | 52 ++++++++++++++++------------- app/cypress/support/e2e.ts | 16 +++------ app/package-lock.json | 18 ---------- app/package.json | 2 +- 4 files changed, 34 insertions(+), 54 deletions(-) diff --git a/app/cypress/support/aws.commands.ts b/app/cypress/support/aws.commands.ts index 9184316ff..561657dfa 100644 --- a/app/cypress/support/aws.commands.ts +++ b/app/cypress/support/aws.commands.ts @@ -2,34 +2,40 @@ import AWS from './aws.config'; -Cypress.Commands.add('addFileToS3', (bucketName, fileName, fileContent) => { - const s3 = new AWS.S3(); +Cypress.Commands.add( + 'addFileToS3', + (bucketName: string, fileName: string, fileContent: AWS.S3.Body) => { + const s3 = new AWS.S3(); - const params: AWS.S3.Types.PutObjectRequest = { - Bucket: bucketName, - Key: fileName, - Body: fileContent, - }; + const params: AWS.S3.Types.PutObjectRequest = { + Bucket: bucketName, + Key: fileName, + Body: fileContent, + }; - s3.upload(params, (err, data) => { - if (err) { - console.error('Error uploading file to S3:', err); - } else { - console.log('File uploaded successfully to S3:', data.Location); - } - }); -}); + s3.upload(params, (err, data) => { + if (err) { + console.error('Error uploading file to S3:', err); + } else { + console.log('File uploaded successfully to S3:', data.Location); + } + }); + }, +); -Cypress.Commands.add('addItemToDynamoDb', (tableName, item) => { - const dynamoDB = new AWS.DynamoDB(); +Cypress.Commands.add( + 'addItemToDynamoDb', + (tableName: string, item: AWS.DynamoDB.PutItemInputAttributeMap) => { + const dynamoDB = new AWS.DynamoDB(); - const params = { - TableName: tableName, - Item: AWS.DynamoDB.Converter.marshall(item), - }; + const params: AWS.DynamoDB.PutItemInput = { + TableName: tableName, + Item: AWS.DynamoDB.Converter.marshall(item), + }; - return cy.wrap(dynamoDB.putItem(params).promise(), { timeout: 10000 }); -}); + return cy.wrap(dynamoDB.putItem(params).promise(), { timeout: 10000 }); + }, +); Cypress.Commands.add('deleteFileFromS3', (bucketName: string, fileName: string) => { const s3 = new AWS.S3(); diff --git a/app/cypress/support/e2e.ts b/app/cypress/support/e2e.ts index 2f552eb4b..dc85a27dd 100644 --- a/app/cypress/support/e2e.ts +++ b/app/cypress/support/e2e.ts @@ -18,7 +18,6 @@ import './commands'; import './aws.commands'; import { Roles, roleIds, roleList } from './roles'; - Cypress.Commands.add('getByTestId', (selector, ...args) => { return cy.get(`[data-testid=${selector}]`, ...args); }); @@ -108,32 +107,25 @@ declare global { * @param {string} fileName - Filepath of the file to upload * @param {string} fileContent - Content of the file to upload */ - addFileToS3( - bucketName: string, - fileName: string, - fileContent: string, - ): Chainable; + addFileToS3(bucketName: string, fileName: string, fileContent: AWS.S3.Body); /** * Add dynamoDB entry * @param {string} tableName - Name of the target dynamoDB table * @param {{ [key: string]: any; }} item - dynamoDB item to upload */ - addItemToDynamoDb( - tableName: string, - item: { [key: string]: string }, - ): Chainable; + addItemToDynamoDb(tableName: string, item: AWS.DynamoDB.PutItemInputAttributeMap); /** * Delete file from S3 bucket * @param {string} bucketName - Name of the target S3 bucket * @param {string} fileName - Filepath of the file to delete */ - deleteFileFromS3(bucketName: string, fileName: string): Chainable; + deleteFileFromS3(bucketName: string, fileName: string); /** * Delete item from DynamoDB table * @param {string} tableName - Name of the target DynamoDB table * @param {string} itemId - ID of the item to delete */ - deleteItemFromDynamoDb(tableName: string, itemId: string): Chainable; + deleteItemFromDynamoDb(tableName: string, itemId: string); } } } diff --git a/app/package-lock.json b/app/package-lock.json index 5a3fe060f..5328dbf09 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -13,7 +13,6 @@ "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "axios": "^1.5.0", - "cross-env": "^7.0.3", "dotenv": "^16.3.1", "eslint-plugin-legacy-decorators": "^1.0.0", "fake-progress": "^1.0.4", @@ -11694,23 +11693,6 @@ "node": ">=10" } }, - "node_modules/cross-env": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", - "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", - "dependencies": { - "cross-spawn": "^7.0.1" - }, - "bin": { - "cross-env": "src/bin/cross-env.js", - "cross-env-shell": "src/bin/cross-env-shell.js" - }, - "engines": { - "node": ">=10.14", - "npm": ">=6", - "yarn": ">=1" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/app/package.json b/app/package.json index 97b533d8b..c6ed4e556 100644 --- a/app/package.json +++ b/app/package.json @@ -25,6 +25,7 @@ "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", + "aws-sdk": "^2.1510.0", "axios": "^1.5.0", "dotenv": "^16.3.1", "eslint-plugin-legacy-decorators": "^1.0.0", @@ -47,7 +48,6 @@ "web-vitals": "^2.1.4" }, "devDependencies": { - "aws-sdk": "^2.1510.0", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@storybook/addon-essentials": "^7.4.0", "@storybook/addon-interactions": "^7.4.0", From 8e3447d6fb88379331d875cdcd7baa7bda7e7a9f Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 16:35:28 +0000 Subject: [PATCH 09/28] Add AWS config to github action --- .github/workflows/ui-smoketest.yml | 7 +++++++ app/.env.template | 6 ++++++ app/cypress.config.ts | 4 ++++ app/cypress/support/aws.config.ts | 8 ++++---- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 9dabf9dd9..b6e64178f 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -64,6 +64,13 @@ jobs: repository: 'nhsconnect/national-document-repository' ref: ${{ github.event.inputs.build_branch}} + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} + role-skip-session-tagging: true + aws-region: ${{ vars.AWS_REGION }} + - name: Cypress install run: | npm install --legacy-peer-deps diff --git a/app/.env.template b/app/.env.template index 40d33ddb0..d44b03365 100644 --- a/app/.env.template +++ b/app/.env.template @@ -7,6 +7,12 @@ REACT_APP_IMAGE_VERSION="%IMAGE_VERSION%" CONTAINER_PORT=xx # Port number within the container. Needed for building the docker image HOST_PORT=xxxx # Port number that the docker-compose localhost exposes. Only need this if we run docker-compose PORT=xxxx # Port number of the localhost dev server when we run `make start` + +# Cypress Smoke Testing CYPRESS_BASE_URL=http://localhost:xxxx # Use the port number same as above PORT CYPRESS_USERNAME=xxxx # For Cypress CIS2 Login during smoke tests CYPRESS_PASSWORD=xxxx # For Cypress CIS2 Login during smoke tests +CYPRESS_WORKSPACE=local # Helps find the correct patient data relative to the workspace +AWS_ACCESS_KEY_ID=xxxx # If workspace is a sandbox, data is seeded with these credentials +AWS_SECRET_ACCESS_KEY=xxxx # If workspace is a sandbox, data is seeded with these credentials +AWS_SESSION_TOKEN=xxxx # If workspace is a sandbox, data is seeded with these credentials diff --git a/app/cypress.config.ts b/app/cypress.config.ts index 2827269b6..8584c7436 100644 --- a/app/cypress.config.ts +++ b/app/cypress.config.ts @@ -15,6 +15,10 @@ export default defineConfig({ USERNAME: process.env.CYPRESS_USERNAME, PASSWORD: process.env.CYPRESS_PASSWORD, WORKSPACE: process.env.CYPRESS_WORKSPACE ?? 'local', + AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID, + AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY, + AWS_REGION: process.env.AWS_REGION, + AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN, }, component: { devServer: { diff --git a/app/cypress/support/aws.config.ts b/app/cypress/support/aws.config.ts index 225a34dde..1ec6ca0fe 100644 --- a/app/cypress/support/aws.config.ts +++ b/app/cypress/support/aws.config.ts @@ -2,10 +2,10 @@ import AWS from 'aws-sdk'; // need to get from env vars AWS.config.update({ - accessKeyId: '', - secretAccessKey: '', - region: '', - sessionToken: '', + accessKeyId: Cypress.env('AWS_accessKeyId'), + secretAccessKey: Cypress.env('AWS_secretAccessKey'), + region: Cypress.env('AWS_region'), + sessionToken: Cypress.env('AWS_sessionToken'), }); export default AWS; From c3b5b564973f57c497e504c93ecd6b627e0afe7b Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 16:35:57 +0000 Subject: [PATCH 10/28] Update cypress commands with cy.promise --- app/cypress/support/aws.commands.ts | 71 +++++++++++++++---- app/cypress/support/commands.ts | 39 ---------- .../support/{e2e.ts => e2e.commands.ts} | 49 +++++++------ lambdas/services/bulk_upload_service.py | 2 +- 4 files changed, 81 insertions(+), 80 deletions(-) delete mode 100644 app/cypress/support/commands.ts rename app/cypress/support/{e2e.ts => e2e.commands.ts} (81%) diff --git a/app/cypress/support/aws.commands.ts b/app/cypress/support/aws.commands.ts index 561657dfa..b063449b5 100644 --- a/app/cypress/support/aws.commands.ts +++ b/app/cypress/support/aws.commands.ts @@ -1,7 +1,6 @@ /// import AWS from './aws.config'; - Cypress.Commands.add( 'addFileToS3', (bucketName: string, fileName: string, fileContent: AWS.S3.Body) => { @@ -13,13 +12,20 @@ Cypress.Commands.add( Body: fileContent, }; - s3.upload(params, (err, data) => { - if (err) { - console.error('Error uploading file to S3:', err); - } else { - console.log('File uploaded successfully to S3:', data.Location); - } - }); + return cy.wrap( + new Cypress.Promise((resolve, reject) => { + s3.upload(params, (err, data) => { + if (err) { + const message = 'Error uploading file to S3:' + err; + console.error(message); + reject(message); + } else { + console.log('File uploaded successfully to S3:', data.Location); + resolve(data); + } + }); + }), + ); }, ); @@ -33,7 +39,20 @@ Cypress.Commands.add( Item: AWS.DynamoDB.Converter.marshall(item), }; - return cy.wrap(dynamoDB.putItem(params).promise(), { timeout: 10000 }); + return cy.wrap( + new Cypress.Promise((resolve, reject) => { + dynamoDB.putItem(params, (err, data) => { + if (err) { + const message = 'Error uploading to Dynamo:' + tableName; + console.error(message); + reject(message); + } else { + console.log('Upload to Dynamo success:', tableName); + resolve(data); + } + }); + }), + ); }, ); @@ -45,9 +64,20 @@ Cypress.Commands.add('deleteFileFromS3', (bucketName: string, fileName: string) Key: fileName, }; - return cy.wrap(s3.deleteObject(params).promise(), { timeout: 10000 }).then(() => { - console.log('File deleted successfully from S3:', fileName); - }); + return cy.wrap( + new Cypress.Promise((resolve, reject) => { + s3.deleteObject(params, (err, data) => { + if (err) { + const message = 'Error uploading to S3:' + bucketName; + console.error(message); + reject(message); + } else { + console.log('Upload to S3 success:', bucketName); + resolve(data); + } + }); + }), + ); }); Cypress.Commands.add('deleteItemFromDynamoDb', (tableName: string, itemId: string) => { @@ -60,7 +90,18 @@ Cypress.Commands.add('deleteItemFromDynamoDb', (tableName: string, itemId: strin }, }; - return cy.wrap(dynamoDB.deleteItem(params).promise(), { timeout: 10000 }).then(() => { - console.log('Item deleted successfully from DynamoDB:', itemId); - }); + return cy.wrap( + new Cypress.Promise((resolve, reject) => { + dynamoDB.deleteItem(params, (err, data) => { + if (err) { + const message = 'Error uploading to Dynamo:' + tableName; + console.error(message); + reject(message); + } else { + console.log('Upload to Dynamo success:', tableName); + resolve(data); + } + }); + }), + ); }); diff --git a/app/cypress/support/commands.ts b/app/cypress/support/commands.ts deleted file mode 100644 index 780b9dcbf..000000000 --- a/app/cypress/support/commands.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// -const registerCypressGrep = require('@cypress/grep'); -registerCypressGrep(); -// *********************************************** -// This example commands.ts shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -// -// declare global { -// namespace Cypress { -// interface Chainable { -// login(email: string, password: string): Chainable -// drag(subject: string, options?: Partial): Chainable -// dismiss(subject: string, options?: Partial): Chainable -// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable -// } -// } -// } diff --git a/app/cypress/support/e2e.ts b/app/cypress/support/e2e.commands.ts similarity index 81% rename from app/cypress/support/e2e.ts rename to app/cypress/support/e2e.commands.ts index dc85a27dd..0247024f7 100644 --- a/app/cypress/support/e2e.ts +++ b/app/cypress/support/e2e.commands.ts @@ -1,22 +1,8 @@ -/// -// *********************************************************** -// This example support/e2e.ts is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -import './commands'; -import './aws.commands'; import { Roles, roleIds, roleList } from './roles'; +import Bluebird from 'cypress/types/bluebird'; +/// +const registerCypressGrep = require('@cypress/grep'); +registerCypressGrep(); Cypress.Commands.add('getByTestId', (selector, ...args) => { return cy.get(`[data-testid=${selector}]`, ...args); @@ -90,42 +76,55 @@ declare global { * @param {string} value - The value of the data-testid attribute of the target DOM element. * @return {HTMLElement} - Target DOM element. */ - getByTestId(value: string); + getByTestId(value: string): Chainable>; /** * Mock user login by intercepting the {baseUrl}/auth-callback request * @param {Roles} role - The user role to login with. Must be an enum of Roles */ - login(role: Roles); + login(role: Roles): Chainable; /** * Real user login via CIS2 and redirect back to {baseUrl}/auth-callback. * @param {Roles} role - The user role to login with. Must be an enum of Roles */ - smokeLogin(role: Roles); + smokeLogin(role: Roles): Chainable; /** * Add file to s3 bucket * @param {string} bucketName - Name of the target S3 bucket * @param {string} fileName - Filepath of the file to upload * @param {string} fileContent - Content of the file to upload */ - addFileToS3(bucketName: string, fileName: string, fileContent: AWS.S3.Body); + addFileToS3( + bucketName: string, + fileName: string, + fileContent: AWS.S3.Body, + ): Chainable>; /** * Add dynamoDB entry * @param {string} tableName - Name of the target dynamoDB table * @param {{ [key: string]: any; }} item - dynamoDB item to upload */ - addItemToDynamoDb(tableName: string, item: AWS.DynamoDB.PutItemInputAttributeMap); + addItemToDynamoDb( + tableName: string, + item: AWS.DynamoDB.PutItemInputAttributeMap, + ): Chainable>; /** * Delete file from S3 bucket * @param {string} bucketName - Name of the target S3 bucket * @param {string} fileName - Filepath of the file to delete */ - deleteFileFromS3(bucketName: string, fileName: string); + deleteFileFromS3( + bucketName: string, + fileName: string, + ): Chainable>; /** * Delete item from DynamoDB table * @param {string} tableName - Name of the target DynamoDB table * @param {string} itemId - ID of the item to delete */ - deleteItemFromDynamoDb(tableName: string, itemId: string); + deleteItemFromDynamoDb( + tableName: string, + itemId: string, + ): Chainable>; } } } diff --git a/lambdas/services/bulk_upload_service.py b/lambdas/services/bulk_upload_service.py index edc632d41..82a628367 100644 --- a/lambdas/services/bulk_upload_service.py +++ b/lambdas/services/bulk_upload_service.py @@ -56,7 +56,7 @@ def process_message_queue(self, records: list): "All remaining messages in this batch will be returned to sqs queue to retry later." ) - all_unprocessed_message = records[index - 1:] + all_unprocessed_message = records[index - 1 :] for unprocessed_message in all_unprocessed_message: self.sqs_repository.put_sqs_message_back_to_queue( unprocessed_message From 2ecc9b5d6e7b6d92c51b52acb6f58162f5bdb4cd Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 16:43:17 +0000 Subject: [PATCH 11/28] Extend documentation for custom commands --- app/cypress/support/e2e.commands.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/cypress/support/e2e.commands.ts b/app/cypress/support/e2e.commands.ts index 0247024f7..8ad8cbf3b 100644 --- a/app/cypress/support/e2e.commands.ts +++ b/app/cypress/support/e2e.commands.ts @@ -92,6 +92,7 @@ declare global { * @param {string} bucketName - Name of the target S3 bucket * @param {string} fileName - Filepath of the file to upload * @param {string} fileContent - Content of the file to upload + * @return {Promise} - S3 response for s3.upload */ addFileToS3( bucketName: string, @@ -102,6 +103,7 @@ declare global { * Add dynamoDB entry * @param {string} tableName - Name of the target dynamoDB table * @param {{ [key: string]: any; }} item - dynamoDB item to upload + * @return {Promise} - Dynamo response for dynamoDB.putItem */ addItemToDynamoDb( tableName: string, @@ -111,6 +113,7 @@ declare global { * Delete file from S3 bucket * @param {string} bucketName - Name of the target S3 bucket * @param {string} fileName - Filepath of the file to delete + * @return {Promise} - S3 response for s3.deleteObject */ deleteFileFromS3( bucketName: string, @@ -120,6 +123,7 @@ declare global { * Delete item from DynamoDB table * @param {string} tableName - Name of the target DynamoDB table * @param {string} itemId - ID of the item to delete + * @return {Promise} - Dynamo response for dynamoDB.deleteItem */ deleteItemFromDynamoDb( tableName: string, From 9a446ef23d770aa637c2f526f8abf7a33d642af0 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 3 Jan 2024 16:50:10 +0000 Subject: [PATCH 12/28] Restore e2e file --- app/cypress/support/{e2e.commands.ts => e2e.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/cypress/support/{e2e.commands.ts => e2e.ts} (100%) diff --git a/app/cypress/support/e2e.commands.ts b/app/cypress/support/e2e.ts similarity index 100% rename from app/cypress/support/e2e.commands.ts rename to app/cypress/support/e2e.ts From 524ff6aa5b6eae26259bd1d4ce46849a58b23d6e Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 10:48:25 +0000 Subject: [PATCH 13/28] Add cypress artefacts to smoke action --- .github/workflows/ui-smoketest.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index b6e64178f..15985922d 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -53,6 +53,18 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-screenshots + path: cypress/screenshots + if-no-files-found: ignore + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-videos + path: cypress/videos + if-no-files-found: ignore cypress-run-firefox: runs-on: ubuntu-22.04 @@ -88,6 +100,18 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-screenshots + path: cypress/screenshots + if-no-files-found: ignore + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-videos + path: cypress/videos + if-no-files-found: ignore cypress-run-edge: runs-on: ubuntu-22.04 @@ -116,3 +140,15 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-screenshots + path: cypress/screenshots + if-no-files-found: ignore + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: cypress-videos + path: cypress/videos + if-no-files-found: ignore From 0f0543ccb321a5b839d443e834823bf9a07dc930 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 10:56:38 +0000 Subject: [PATCH 14/28] Update cypress artefact workflow --- .github/workflows/ui-smoketest.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 15985922d..2cd0c2ca7 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -57,13 +57,13 @@ jobs: if: failure() with: name: cypress-screenshots - path: cypress/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-videos - path: cypress/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos if-no-files-found: ignore cypress-run-firefox: @@ -104,13 +104,13 @@ jobs: if: failure() with: name: cypress-screenshots - path: cypress/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-videos - path: cypress/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots/videos if-no-files-found: ignore cypress-run-edge: @@ -144,11 +144,11 @@ jobs: if: failure() with: name: cypress-screenshots - path: cypress/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos if-no-files-found: ignore - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-videos - path: cypress/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots/videos if-no-files-found: ignore From 8b2a920d46df3a5a3a7e699490959e8969f856f5 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 11:16:30 +0000 Subject: [PATCH 15/28] Add artifact ids --- .github/workflows/ui-smoketest.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 2cd0c2ca7..00fdedbd3 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -54,12 +54,14 @@ jobs: CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} - uses: actions/upload-artifact@v4 + id: cypress-screenshots-chrome if: failure() with: name: cypress-screenshots path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 + id: cypress-videos-chrome if: failure() with: name: cypress-videos @@ -101,16 +103,18 @@ jobs: CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} - uses: actions/upload-artifact@v4 + id: cypress-screenshots-firefox if: failure() with: name: cypress-screenshots path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 + id: cypress-videos-firefox if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos if-no-files-found: ignore cypress-run-edge: @@ -141,14 +145,16 @@ jobs: CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} - uses: actions/upload-artifact@v4 + id: cypress-screenshots-edge if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 + id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos if-no-files-found: ignore From 13bfffb1cac22b3f95b52bb780143a2971f6cae9 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 11:26:16 +0000 Subject: [PATCH 16/28] Add video output to env --- .github/workflows/ui-smoketest.yml | 3 +++ app/cypress.config.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 00fdedbd3..b7839176d 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -53,6 +53,7 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} + CYPRESS_OUTPUT_VIDEO: true - uses: actions/upload-artifact@v4 id: cypress-screenshots-chrome if: failure() @@ -102,6 +103,7 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} + CYPRESS_OUTPUT_VIDEO: true - uses: actions/upload-artifact@v4 id: cypress-screenshots-firefox if: failure() @@ -144,6 +146,7 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} + CYPRESS_OUTPUT_VIDEO: true - uses: actions/upload-artifact@v4 id: cypress-screenshots-edge if: failure() diff --git a/app/cypress.config.ts b/app/cypress.config.ts index 8584c7436..117fc6c53 100644 --- a/app/cypress.config.ts +++ b/app/cypress.config.ts @@ -33,4 +33,5 @@ export default defineConfig({ html: false, json: true, }, + video: process.env.CYPRESS_OUTPUT_VIDEO ? true : false, }); From e7f6825b1ef57b4f912c93a9c79a7dbb47a04718 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 12:27:43 +0000 Subject: [PATCH 17/28] Update timeout lengths on smoke tests --- .../patient_search_and_verify_workflow.cy.js | 7 +++++-- app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index 82c4e4392..fdb081cf1 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -20,10 +20,13 @@ describe('GP Workflow: Patient search and verify', () => { cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); cy.get('#verify-submit').click(); - cy.url().should('include', 'lloyd-george-record'); - cy.url().should('eq', baseUrl + '/search/patient/lloyd-george-record'); + cy.url({ timeout: 10000 }).should( + 'eq', + baseUrl + '/search/patient/lloyd-george-record', + ); }, ); }); diff --git a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js index 342d55729..1480057a1 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js @@ -70,7 +70,7 @@ describe('Home Page', () => { cy.getByTestId('logout-btn').should('exist'); cy.getByTestId('logout-btn').click(); - cy.url({ timeout: 10000 }).should('contain', baseUrl + homeUrl); + cy.url({ timeout: 20000 }).should('contain', baseUrl + homeUrl); cy.get('.nhsuk-header__navigation').should('not.exist'); cy.get('.nhsuk-header__navigation-list').should('not.exist'); From d483004a3a088863196189569d7b53dec0b9adf1 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 14:14:38 +0000 Subject: [PATCH 18/28] Change 'contain' to 'eq' on logout url --- app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js index 1480057a1..207198e86 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/homepage.cy.js @@ -70,7 +70,7 @@ describe('Home Page', () => { cy.getByTestId('logout-btn').should('exist'); cy.getByTestId('logout-btn').click(); - cy.url({ timeout: 20000 }).should('contain', baseUrl + homeUrl); + cy.url({ timeout: 10000 }).should('eq', baseUrl + homeUrl); cy.get('.nhsuk-header__navigation').should('not.exist'); cy.get('.nhsuk-header__navigation-list').should('not.exist'); From 73b640661c0f0775c90a527034afdc157ae84748 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 14:47:24 +0000 Subject: [PATCH 19/28] Update patient number --- .../patient_search_and_verify_workflow.cy.js | 2 +- app/cypress/support/aws.commands.ts | 1 + app/cypress/support/e2e.ts | 13 +++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index fdb081cf1..ef982f42c 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -6,7 +6,7 @@ describe('GP Workflow: Patient search and verify', () => { const gpRoles = [Roles.GP_ADMIN, Roles.GP_CLINICAL]; const workspace = Cypress.env('WORKSPACE'); - const activePatient = workspace === 'ndr-dev' ? '9730153817' : '9449305552'; + const activePatient = workspace === 'ndr-dev' ? '9730153817' : '9000000002'; gpRoles.forEach((role) => { it( diff --git a/app/cypress/support/aws.commands.ts b/app/cypress/support/aws.commands.ts index b063449b5..3b80ac47b 100644 --- a/app/cypress/support/aws.commands.ts +++ b/app/cypress/support/aws.commands.ts @@ -1,6 +1,7 @@ /// import AWS from './aws.config'; + Cypress.Commands.add( 'addFileToS3', (bucketName: string, fileName: string, fileContent: AWS.S3.Body) => { diff --git a/app/cypress/support/e2e.ts b/app/cypress/support/e2e.ts index 8ad8cbf3b..5f186e92e 100644 --- a/app/cypress/support/e2e.ts +++ b/app/cypress/support/e2e.ts @@ -1,3 +1,4 @@ +import { DynamoDB, S3 } from 'aws-sdk'; import { Roles, roleIds, roleList } from './roles'; import Bluebird from 'cypress/types/bluebird'; /// @@ -97,8 +98,8 @@ declare global { addFileToS3( bucketName: string, fileName: string, - fileContent: AWS.S3.Body, - ): Chainable>; + fileContent: S3.Body, + ): Chainable>; /** * Add dynamoDB entry * @param {string} tableName - Name of the target dynamoDB table @@ -107,8 +108,8 @@ declare global { */ addItemToDynamoDb( tableName: string, - item: AWS.DynamoDB.PutItemInputAttributeMap, - ): Chainable>; + item: DynamoDB.PutItemInputAttributeMap, + ): Chainable>; /** * Delete file from S3 bucket * @param {string} bucketName - Name of the target S3 bucket @@ -118,7 +119,7 @@ declare global { deleteFileFromS3( bucketName: string, fileName: string, - ): Chainable>; + ): Chainable>; /** * Delete item from DynamoDB table * @param {string} tableName - Name of the target DynamoDB table @@ -128,7 +129,7 @@ declare global { deleteItemFromDynamoDb( tableName: string, itemId: string, - ): Chainable>; + ): Chainable>; } } } From 94625ad269748188426007c43dabd37474d0ed3e Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 14:57:16 +0000 Subject: [PATCH 20/28] Use fake failure to test artifacts --- .github/workflows/ui-smoketest.yml | 12 ++++++------ .../patient_search_and_verify_workflow.cy.js | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index b7839176d..352a08e4b 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -59,14 +59,14 @@ jobs: if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 id: cypress-videos-chrome if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome/videos if-no-files-found: ignore cypress-run-firefox: @@ -109,14 +109,14 @@ jobs: if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 id: cypress-videos-firefox if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox/videos if-no-files-found: ignore cypress-run-edge: @@ -152,12 +152,12 @@ jobs: if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge/videos if-no-files-found: ignore diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index ef982f42c..5dea2ed10 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -19,8 +19,9 @@ describe('GP Workflow: Patient search and verify', () => { cy.get('#nhs-number-input').click(); cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); + cy.url().should('eq', baseUrl + '/fakeUrl'); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); + // cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); cy.get('#verify-submit').click(); cy.url({ timeout: 10000 }).should( From 5a231c88e2427e7ff97a79af528fdd281b9780de Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 15:21:54 +0000 Subject: [PATCH 21/28] Modify action for artifacts --- .github/workflows/ui-smoketest.yml | 35 +++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 352a08e4b..7d232859d 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -54,19 +54,24 @@ jobs: CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} CYPRESS_OUTPUT_VIDEO: true + + - name: Cypress artifacts + run: | + mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-screenshots \ + mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-videos - uses: actions/upload-artifact@v4 - id: cypress-screenshots-chrome + id: cypress-screenshots-edge if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 - id: cypress-videos-chrome + id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-videos if-no-files-found: ignore cypress-run-firefox: @@ -104,19 +109,24 @@ jobs: CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} CYPRESS_OUTPUT_VIDEO: true + + - name: Cypress artifacts + run: | + mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-screenshots \ + mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-videos - uses: actions/upload-artifact@v4 - id: cypress-screenshots-firefox + id: cypress-screenshots-edge if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 - id: cypress-videos-firefox + id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-videos if-no-files-found: ignore cypress-run-edge: @@ -147,17 +157,22 @@ jobs: CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} CYPRESS_OUTPUT_VIDEO: true + + - name: Cypress artifacts + run: | + mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-screenshots \ + mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-videos - uses: actions/upload-artifact@v4 id: cypress-screenshots-edge if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge/screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge/videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-videos if-no-files-found: ignore From 5ac14aca5f4295972a6d29e25e09e397b27a20b1 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 15:36:00 +0000 Subject: [PATCH 22/28] Modify artifact mv command --- .github/workflows/ui-smoketest.yml | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 7d232859d..5368938d2 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -57,21 +57,21 @@ jobs: - name: Cypress artifacts run: | - mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-screenshots \ - mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-videos + cd /home/runner/work/national-document-repository/national-document-repository/app/cypress + mkdir chrome \ + mv /screenshots /chrome/chrome-screenshots \ + mv /videos /chrome/chrome-videos \ - uses: actions/upload-artifact@v4 - id: cypress-screenshots-edge if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome if-no-files-found: ignore - uses: actions/upload-artifact@v4 - id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome-videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome if-no-files-found: ignore cypress-run-firefox: @@ -112,21 +112,21 @@ jobs: - name: Cypress artifacts run: | - mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-screenshots \ - mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-videos + cd /home/runner/work/national-document-repository/national-document-repository/app/cypress \ + mkdir firefox \ + mv /screenshots /firefox/firefox-screenshots \ + mv /videos /firefox/firefox-videos \ - uses: actions/upload-artifact@v4 - id: cypress-screenshots-edge if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox if-no-files-found: ignore - uses: actions/upload-artifact@v4 - id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox-videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox if-no-files-found: ignore cypress-run-edge: @@ -160,8 +160,10 @@ jobs: - name: Cypress artifacts run: | - mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-screenshots \ - mv /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-videos + cd /home/runner/work/national-document-repository/national-document-repository/app/cypress \ + mkdir edge \ + mv /screenshots /edge/edge-screenshots \ + mv /videos /edge/edge-videos \ - uses: actions/upload-artifact@v4 id: cypress-screenshots-edge if: failure() @@ -170,9 +172,8 @@ jobs: path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 - id: cypress-videos-edge if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-videos + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge if-no-files-found: ignore From f488016573ebbbb250e91caf0306676399b91cc4 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 15:44:42 +0000 Subject: [PATCH 23/28] Add compression tag --- app/cypress.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/cypress.config.ts b/app/cypress.config.ts index 117fc6c53..c6ac7b536 100644 --- a/app/cypress.config.ts +++ b/app/cypress.config.ts @@ -34,4 +34,5 @@ export default defineConfig({ json: true, }, video: process.env.CYPRESS_OUTPUT_VIDEO ? true : false, + videoCompression: 15, }); From be15e456b6d24549de60078f1f9a69d12dc6fb60 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Fri, 5 Jan 2024 15:58:14 +0000 Subject: [PATCH 24/28] Edit artifact actions: --- .github/workflows/ui-smoketest.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 5368938d2..5671f61bf 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -57,7 +57,7 @@ jobs: - name: Cypress artifacts run: | - cd /home/runner/work/national-document-repository/national-document-repository/app/cypress + cd /home/runner/work/national-document-repository/national-document-repository/app/cypress \ mkdir chrome \ mv /screenshots /chrome/chrome-screenshots \ mv /videos /chrome/chrome-videos \ @@ -111,18 +111,22 @@ jobs: CYPRESS_OUTPUT_VIDEO: true - name: Cypress artifacts + working-directory: ./app/cypress run: | - cd /home/runner/work/national-document-repository/national-document-repository/app/cypress \ - mkdir firefox \ + mkdir firefox \ mv /screenshots /firefox/firefox-screenshots \ mv /videos /firefox/firefox-videos \ - - uses: actions/upload-artifact@v4 + + - name: Cypress screenshots + uses: actions/upload-artifact@v4 if: failure() with: name: cypress-screenshots path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox if-no-files-found: ignore - - uses: actions/upload-artifact@v4 + + - name: Cypress videos + uses: actions/upload-artifact@v4 if: failure() with: name: cypress-videos @@ -159,19 +163,22 @@ jobs: CYPRESS_OUTPUT_VIDEO: true - name: Cypress artifacts + working-directory: ./app/cypress run: | - cd /home/runner/work/national-document-repository/national-document-repository/app/cypress \ - mkdir edge \ + mkdir edge \ mv /screenshots /edge/edge-screenshots \ mv /videos /edge/edge-videos \ - - uses: actions/upload-artifact@v4 - id: cypress-screenshots-edge + + - name: Cypress screenshots + uses: actions/upload-artifact@v4 if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge-screenshots + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge if-no-files-found: ignore - - uses: actions/upload-artifact@v4 + + - name: Cypress videos + uses: actions/upload-artifact@v4 if: failure() with: name: cypress-videos From c8dae858347e58ddd4e8efdf5e80ebf3272b8dae Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Mon, 8 Jan 2024 10:00:11 +0000 Subject: [PATCH 25/28] Update yml for only chrome artifact --- .github/workflows/ui-smoketest.yml | 60 ++----------------- .../patient_search_and_verify_workflow.cy.js | 3 +- 2 files changed, 5 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ui-smoketest.yml b/.github/workflows/ui-smoketest.yml index 5671f61bf..34af264f6 100644 --- a/.github/workflows/ui-smoketest.yml +++ b/.github/workflows/ui-smoketest.yml @@ -55,23 +55,17 @@ jobs: CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} CYPRESS_OUTPUT_VIDEO: true - - name: Cypress artifacts - run: | - cd /home/runner/work/national-document-repository/national-document-repository/app/cypress \ - mkdir chrome \ - mv /screenshots /chrome/chrome-screenshots \ - mv /videos /chrome/chrome-videos \ - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots if-no-files-found: ignore - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/chrome + path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos if-no-files-found: ignore cypress-run-firefox: @@ -108,30 +102,7 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} - CYPRESS_OUTPUT_VIDEO: true - - - name: Cypress artifacts - working-directory: ./app/cypress - run: | - mkdir firefox \ - mv /screenshots /firefox/firefox-screenshots \ - mv /videos /firefox/firefox-videos \ - - - name: Cypress screenshots - uses: actions/upload-artifact@v4 - if: failure() - with: - name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox - if-no-files-found: ignore - - - name: Cypress videos - uses: actions/upload-artifact@v4 - if: failure() - with: - name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/firefox - if-no-files-found: ignore + CYPRESS_OUTPUT_VIDEO: false cypress-run-edge: runs-on: ubuntu-22.04 @@ -160,27 +131,4 @@ jobs: CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }} CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }} CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }} - CYPRESS_OUTPUT_VIDEO: true - - - name: Cypress artifacts - working-directory: ./app/cypress - run: | - mkdir edge \ - mv /screenshots /edge/edge-screenshots \ - mv /videos /edge/edge-videos \ - - - name: Cypress screenshots - uses: actions/upload-artifact@v4 - if: failure() - with: - name: cypress-screenshots - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge - if-no-files-found: ignore - - - name: Cypress videos - uses: actions/upload-artifact@v4 - if: failure() - with: - name: cypress-videos - path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/edge - if-no-files-found: ignore + CYPRESS_OUTPUT_VIDEO: false diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index 5dea2ed10..ef982f42c 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -19,9 +19,8 @@ describe('GP Workflow: Patient search and verify', () => { cy.get('#nhs-number-input').click(); cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); - cy.url().should('eq', baseUrl + '/fakeUrl'); - // cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); cy.get('#verify-submit').click(); cy.url({ timeout: 10000 }).should( From 38a5247cb2b6d9a7e13b9d318ae7da06c1abf3da Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Mon, 8 Jan 2024 12:27:42 +0000 Subject: [PATCH 26/28] Test output of failure for artifact --- .../gp_user_workflows/patient_search_and_verify_workflow.cy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index ef982f42c..a57d68c08 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -19,8 +19,9 @@ describe('GP Workflow: Patient search and verify', () => { cy.get('#nhs-number-input').click(); cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/fake/test/output'); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); + // cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); cy.get('#verify-submit').click(); cy.url({ timeout: 10000 }).should( From cfe5dbfa80c89e462ac1216f7673e4832827dceb Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Mon, 8 Jan 2024 12:37:09 +0000 Subject: [PATCH 27/28] Restore working test --- .../gp_user_workflows/patient_search_and_verify_workflow.cy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index a57d68c08..ef982f42c 100644 --- a/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -19,9 +19,8 @@ describe('GP Workflow: Patient search and verify', () => { cy.get('#nhs-number-input').click(); cy.get('#nhs-number-input').type(activePatient); cy.get('#search-submit').click(); - cy.url({ timeout: 10000 }).should('eq', baseUrl + '/fake/test/output'); - // cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); + cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result'); cy.get('#verify-submit').click(); cy.url({ timeout: 10000 }).should( From f2e806a013c459ea8632c34b4b56b8ef511191e5 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Mon, 8 Jan 2024 16:15:32 +0000 Subject: [PATCH 28/28] Add logout stub for homepage test --- app/cypress/e2e/0-ndr-core-tests/homepage.cy.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js b/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js index 871490d4c..88803fecd 100644 --- a/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js @@ -86,8 +86,14 @@ describe('Home Page', () => { cy.get('.nhsuk-header__navigation').should('exist'); cy.get('.nhsuk-header__navigation-list').should('exist'); + cy.intercept('GET', '/Auth/Logout', { + statusCode: 200, + }).as('logout'); + cy.getByTestId('logout-btn').should('exist'); cy.getByTestId('logout-btn').click(); + + cy.wait('@logout'); cy.url({ timeout: 10000 }).should('contain', baseUrl + homeUrl); cy.get('.nhsuk-header__navigation').should('not.exist');