Skip to content

Commit

Permalink
Prmp 920 - Disable the BSOL Journey check to allow all users to acces…
Browse files Browse the repository at this point in the history
…s the NDR (#431)

* [PRMP-920] return true for isbsol logic

* [PRMP-920] - remove failing test as the logic has been removed

* [PRMP-920] - fix broken test

* [PRMP-920] - fix/skip broken cypress tests

* [PRMP-920] - skip failing smoketest as result of this change

* update smoke tests to pass with non-BSOL flow

---------

Co-authored-by: Abid <abdur.abid@madetech.com>
Co-authored-by: bethany-kish-nhs <beth.kish1@nhs.net>
  • Loading branch information
3 people authored Oct 10, 2024
1 parent 09f8582 commit 4fcc50b
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const arfDownloadUrl = '/patient/arf';

const forbiddenRoutes = [arfDownloadUrl];

const bsolOptions = [true, false];
const bsolOptions = [true];

describe('GP Admin user role has access to the expected GP_ADMIN workflow paths', () => {
bsolOptions.forEach((isBSOL) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const lloydGeorgeViewUrl = '/patient/lloyd-george-record';
const arfDownloadUrl = '/patient/arf';
const forbiddenRoutes = [arfDownloadUrl];

const bsolOptions = [true, false];
const bsolOptions = [true];

describe('GP Clinical user role has access to the expected GP_CLINICAL workflow paths', () => {
bsolOptions.forEach((isBSOL) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('GP Workflow: View Lloyd George record', () => {
context(
`View Lloyd George document for ${roleName(role)} role and download warning is present`,
() => {
it(
it.skip(
roleName(role) + ' can view a Lloyd George document of an active patient',
{ tags: 'regression' },
() => {
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('GP Workflow: View Lloyd George record', () => {
},
);

it(
it.skip(
`It displays an empty Lloyd George card when no Lloyd George record exists for the patient for a ${roleName(
role,
)}`,
Expand All @@ -124,7 +124,7 @@ describe('GP Workflow: View Lloyd George record', () => {
assertEmptyLloydGeorgeCard();
},
);
it(
it.skip(
`It displays an waiting message when uploading Lloyd George record is in progress for the patient for a ${roleName(
role,
)}`,
Expand All @@ -144,7 +144,7 @@ describe('GP Workflow: View Lloyd George record', () => {
);
},
);
it(
it.skip(
`It displays an error when the Lloyd George Stitch API call fails for a ${roleName(
role,
)}`,
Expand All @@ -162,7 +162,7 @@ describe('GP Workflow: View Lloyd George record', () => {
},
);

it(
it.skip(
'Routes to download page when safety checkbox is checked',
{ tags: 'regression' },
() => {
Expand All @@ -182,7 +182,7 @@ describe('GP Workflow: View Lloyd George record', () => {
},
);

it(
it.skip(
'It displays warning when safety checkbox is not checked',
{ tags: 'regression' },
() => {
Expand All @@ -201,7 +201,7 @@ describe('GP Workflow: View Lloyd George record', () => {
},
);

it(
it.skip(
'No download option or menu exists when no Lloyd George record exists for the patient',
{ tags: 'regression' },
() => {
Expand All @@ -218,84 +218,92 @@ describe('GP Workflow: View Lloyd George record', () => {
},
);

it('Confirm download and delete of Lloyd George', { tags: 'regression' }, () => {
const isBSOL = false;
cy.login(role, isBSOL);
cy.getByTestId('search-patient-btn').click();

// search patient
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: searchPatientPayload,
}).as('search');
it.skip(
'Confirm download and delete of Lloyd George',
{ tags: 'regression' },
() => {
const isBSOL = false;
cy.login(role, isBSOL);
cy.getByTestId('search-patient-btn').click();

cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 200,
body: viewLloydGeorgePayload,
}).as('lloydGeorgeStitch');
// search patient
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: searchPatientPayload,
}).as('search');

cy.intercept('POST', '/DocumentManifest*', (req) => {
req.reply({
cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 200,
body: { jobId: 'test-jobId' },
delay: 500,
});
}).as('documentManifestPost');
body: viewLloydGeorgePayload,
}).as('lloydGeorgeStitch');

cy.intercept('GET', '/DocumentManifest*', (req) => {
req.reply({
cy.intercept('POST', '/DocumentManifest*', (req) => {
req.reply({
statusCode: 200,
body: { jobId: 'test-jobId' },
delay: 500,
});
}).as('documentManifestPost');

cy.intercept('GET', '/DocumentManifest*', (req) => {
req.reply({
statusCode: 200,
body: {
jobStatus: 'Completed',
url: baseUrl + '/browserconfig.xml',
}, // uses public served file in place of a ZIP file
delay: 500,
});
}).as('documentManifest');

cy.intercept('DELETE', '/DocumentDelete*', {
statusCode: 200,
body: { jobStatus: 'Completed', url: baseUrl + '/browserconfig.xml' }, // uses public served file in place of a ZIP file
delay: 500,
});
}).as('documentManifest');

cy.intercept('DELETE', '/DocumentDelete*', {
statusCode: 200,
}).as('documentDelete');

cy.getByTestId('nhs-number-input').type(searchPatientPayload.nhsNumber);
cy.getByTestId('search-submit-btn').click();
cy.wait('@search');

cy.get('#verify-submit').click();
cy.wait('@lloydGeorgeStitch', { timeout: 20000 });

cy.getByTestId('download-and-remove-record-btn').click();
cy.getByTestId('confirm-download-and-remove-checkbox').should('exist');
cy.getByTestId('confirm-download-and-remove-checkbox').click();
cy.getByTestId('confirm-download-and-remove-btn').click();
cy.getByTestId('lloydgeorge_downloadall-stage').should('exist');

// Assert contents of page when downloading
cy.contains('Downloading documents').should('be.visible');
cy.getByTestId(
'download-file-header-' + viewLloydGeorgePayload.number_of_files + '-files',
).should('be.visible');
cy.contains('Compressing record into a zip file').should('be.visible');
cy.contains('Cancel').should('be.visible');

cy.wait('@documentManifest');
// Assert contents of page after download
cy.getByTestId('downloaded-record-card-header').should('be.visible');
cy.contains(
`${searchPatientPayload.givenName} ${searchPatientPayload.familyName}`,
).should('be.visible');
cy.contains(
`NHS number: ${formatNhsNumber(searchPatientPayload.nhsNumber)}`,
).should('be.visible');

// Assert file has been downloaded
cy.readFile(`${Cypress.config('downloadsFolder')}/browserconfig.xml`);
cy.wait('@documentDelete');
cy.getByTestId('return-btn').should('exist');
cy.contains('This record has been removed from our storage.').should(
'be.visible',
);
cy.contains('Follow the Record Management Code of Practice').should(
'be.visible',
);
});
}).as('documentDelete');

cy.getByTestId('nhs-number-input').type(searchPatientPayload.nhsNumber);
cy.getByTestId('search-submit-btn').click();
cy.wait('@search');
cy.get('#verify-submit').click();
cy.wait('@lloydGeorgeStitch', { timeout: 20000 });

cy.getByTestId('download-and-remove-record-btn').click();
cy.getByTestId('confirm-download-and-remove-checkbox').should('exist');
cy.getByTestId('confirm-download-and-remove-checkbox').click();
cy.getByTestId('confirm-download-and-remove-btn').click();
cy.getByTestId('lloydgeorge_downloadall-stage').should('exist');

// Assert contents of page when downloading
cy.contains('Downloading documents').should('be.visible');
cy.getByTestId(
'download-file-header-' +
viewLloydGeorgePayload.number_of_files +
'-files',
).should('be.visible');
cy.contains('Compressing record into a zip file').should('be.visible');
cy.contains('Cancel').should('be.visible');

cy.wait('@documentManifest');
// Assert contents of page after download
cy.getByTestId('downloaded-record-card-header').should('be.visible');
cy.contains(
`${searchPatientPayload.givenName} ${searchPatientPayload.familyName}`,
).should('be.visible');
cy.contains(
`NHS number: ${formatNhsNumber(searchPatientPayload.nhsNumber)}`,
).should('be.visible');

// Assert file has been downloaded
cy.readFile(`${Cypress.config('downloadsFolder')}/browserconfig.xml`);
cy.wait('@documentDelete');
cy.getByTestId('return-btn').should('exist');
cy.contains('This record has been removed from our storage.').should(
'be.visible',
);
cy.contains('Follow the Record Management Code of Practice').should(
'be.visible',
);
},
);
},
);
});
Expand Down
2 changes: 1 addition & 1 deletion app/cypress/e2e/0-ndr-core-tests/homepage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Home Page', () => {

const gpRoles = [Roles.GP_ADMIN, Roles.GP_CLINICAL];
gpRoles.forEach((role) => {
it(
it.skip(
`should display non-BSOL landing page when user is ${Roles[role]} role in non-BSOL area`,
{ tags: 'regression' },
() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ describe('GP Workflow: View Lloyd George record', () => {
});

it(
'[Smoke] non-BSOL GP ADMIN user can download and delete the Lloyd George document of an active patient',
'[Smoke] NON-BSOL GP ADMIN user can download the Lloyd George document of an active patient',
{ tags: 'smoke', defaultCommandTimeout: 20000 },
() => {
cy.smokeLogin(Roles.GP_ADMIN);
cy.get('.nhsuk-header__navigation').should('exist');

cy.getByTestId('search-patient-btn').click();

cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(activePatient);
cy.get('#search-submit').click();
Expand All @@ -48,16 +46,15 @@ describe('GP Workflow: View Lloyd George record', () => {

cy.getByTestId('pdf-viewer').should('be.visible');

cy.getByTestId('download-and-remove-record-btn').click();
cy.getByTestId('confirm-download-and-remove-checkbox').should('exist');
cy.getByTestId('confirm-download-and-remove-checkbox').click();
cy.getByTestId('download-all-files-link').click();

cy.getByTestId('available-files-table-title').should('exist');
cy.getByTestId('download-file-btn').click();

cy.downloadIframeReplace();

cy.intercept('POST', '**/DocumentManifest*').as('postDocumentManifest');

cy.getByTestId('confirm-download-and-remove-btn').click();

// Assert contents of page when downloading
cy.getByTestId('lloydgeorge_downloadall-stage', { timeout: 10000 }).should('exist');
cy.contains('Downloading documents').should('be.visible');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('GP Workflow: GP Role rejected from accessing a non mating ODS patient

const workspace = Cypress.env('WORKSPACE');
const activePatient = workspace === 'ndr-dev' ? '9730153817' : '9000000002';
const homeUrl = '/home';
const homeUrl = '/patient/search';

gpRoles.forEach((role) => {
it(
Expand All @@ -19,8 +19,6 @@ describe('GP Workflow: GP Role rejected from accessing a non mating ODS patient
cy.smokeLogin(role);

cy.url({ timeout: 10000 }).should('eq', baseUrl + homeUrl);
cy.getByTestId('search-patient-btn').should('exist');
cy.getByTestId('search-patient-btn').click();

cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(activePatient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('GP Workflow: Patient search and verify', () => {
const workspace = Cypress.env('WORKSPACE');
const activePatient =
workspace === 'ndr-dev' ? pdsPatients.activeUpload : stubPatients.activeUpload;
const homeUrl = '/home';
const homeUrl = '/patient/search';
const patientVerifyUrl = '/patient/verify';
const lloydGeorgeRecordUrl = '/patient/lloyd-george-record';

Expand All @@ -23,8 +23,6 @@ describe('GP Workflow: Patient search and verify', () => {
cy.smokeLogin(role);

cy.url({ timeout: 10000 }).should('eq', baseUrl + homeUrl);
cy.getByTestId('search-patient-btn').should('exist');
cy.getByTestId('search-patient-btn').click();

cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(activePatient);
Expand Down
5 changes: 0 additions & 5 deletions app/src/helpers/hooks/useIsBSOL.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ describe('useIsBSOL', () => {
renderHook(true);
expect(screen.getByText(`isBSOL: true`)).toBeInTheDocument();
});

it('returns null when there is no session', () => {
renderHook();
expect(screen.getByText(`isBSOL: false`)).toBeInTheDocument();
});
});

const TestApp = () => {
Expand Down
7 changes: 1 addition & 6 deletions app/src/helpers/hooks/useIsBSOL.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { useSessionContext } from '../../providers/sessionProvider/SessionProvider';

function useIsBSOL() {
const [session] = useSessionContext();

const isBSOL = session.auth ? session.auth.isBSOL : null;
return !!isBSOL;
return true;
}

export default useIsBSOL;
2 changes: 1 addition & 1 deletion lambdas/services/login_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def generate_session(self, state, auth_code) -> dict:
user_id,
)

is_bsol = permitted_orgs_details["is_BSOL"]
is_bsol = True

logger.info("Returning authentication details")
response = {
Expand Down
2 changes: 1 addition & 1 deletion lambdas/tests/unit/services/test_login_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_exchange_token_respond_with_auth_token_and_repo_role(

expected_jwt = "mock_ndr_auth_token"
expected_role = RepositoryRole.PCSE
expected_is_bsol = False
expected_is_bsol = True

mocker.patch.object(
LoginService,
Expand Down

0 comments on commit 4fcc50b

Please sign in to comment.