Skip to content

Commit 5475d28

Browse files
[PRMP-860] Refactor upload components to link doc types
1 parent 37ddf23 commit 5475d28

File tree

28 files changed

+820
-518
lines changed

28 files changed

+820
-518
lines changed

app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/upload_lloyd_george_is_bsol_gp_admin_workflow.cy.js

Lines changed: 109 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ const workspace = Cypress.env('WORKSPACE');
66
const baseUrl = Cypress.config('baseUrl');
77

88
const uploadedFilePathNames = [
9-
'cypress/fixtures/lg-files/zenia_lees/1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
10-
'cypress/fixtures/lg-files/zenia_lees/2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
11-
'cypress/fixtures/lg-files/zenia_lees/3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
9+
'cypress/fixtures/lg-files/zenia_lees/1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
10+
'cypress/fixtures/lg-files/zenia_lees/2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
11+
'cypress/fixtures/lg-files/zenia_lees/3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
1212
];
1313
const uploadedFileNames = [
14-
'1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
15-
'2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
16-
'3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
14+
'1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
15+
'2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
16+
'3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
1717
];
1818

1919
const bucketName = `${workspace}-lloyd-george-store`;
@@ -28,108 +28,111 @@ const confirmationUrl = '/patient/document-upload/confirmation';
2828
const activePatient = pdsPatients.activeNoUpload;
2929

3030
describe('GP Workflow: Upload Lloyd George record', () => {
31-
context('Upload a Lloyd George document', () => {
32-
beforeEach(() => {
33-
//delete any records present for the active patient
34-
cy.deleteItemsBySecondaryKeyFromDynamoDb(
35-
referenceTableName,
36-
'NhsNumberIndex',
37-
'NhsNumber',
38-
activePatient.toString(),
39-
);
40-
cy.deleteItemsBySecondaryKeyFromDynamoDb(
41-
stitchTableName,
42-
'NhsNumberIndex',
43-
'NhsNumber',
44-
activePatient.toString()
45-
);
46-
uploadedFileNames.forEach((file) => {
47-
cy.deleteFileFromS3(bucketName, file);
48-
});
49-
});
50-
51-
afterEach(() => {
52-
//clean up any records present for the active patient
53-
cy.deleteItemsBySecondaryKeyFromDynamoDb(
54-
referenceTableName,
55-
'NhsNumberIndex',
56-
'NhsNumber',
57-
activePatient.toString(),
58-
);
59-
cy.deleteItemsBySecondaryKeyFromDynamoDb(
60-
stitchTableName,
61-
'NhsNumberIndex',
62-
'NhsNumber',
63-
activePatient.toString()
64-
);
65-
uploadedFileNames.forEach((file) => {
66-
cy.deleteFileFromS3(bucketName, file);
67-
});
68-
});
69-
70-
it(
71-
'[Smoke] GP ADMIN can upload multiple files and then view a Lloyd George record for an active patient with no record',
72-
{ tags: 'smoke', defaultCommandTimeout: 20000 },
73-
() => {
74-
cy.smokeLogin(Roles.SMOKE_GP_ADMIN);
75-
76-
cy.navigateToPatientSearchPage();
77-
78-
cy.get('#nhs-number-input').should('exist');
79-
cy.get('#nhs-number-input').click();
80-
cy.get('#nhs-number-input').type(activePatient);
81-
cy.getByTestId('search-submit-btn').should('exist');
82-
cy.getByTestId('search-submit-btn').click();
83-
84-
cy.url({ timeout: 15000 }).should('contain', patientVerifyUrl);
85-
86-
cy.get('#verify-submit').should('exist');
87-
cy.get('#verify-submit').click();
88-
89-
cy.url().should('contain', lloydGeorgeRecordUrl);
90-
cy.getByTestId('no-records-title').should(
91-
'include.text',
92-
'This patient does not have a Lloyd George record',
93-
);
94-
cy.getByTestId('upload-patient-record-button').should('exist');
95-
cy.getByTestId('upload-patient-record-button').click();
96-
uploadedFilePathNames.forEach((file) => {
97-
cy.getByTestId('button-input').selectFile(file, { force: true });
98-
var index = uploadedFilePathNames.indexOf(file);
99-
cy.get('#selected-documents-table').should('contain', uploadedFileNames[index]);
31+
context('Upload a Lloyd George document', () => {
32+
beforeEach(() => {
33+
//delete any records present for the active patient
34+
cy.deleteItemsBySecondaryKeyFromDynamoDb(
35+
referenceTableName,
36+
'NhsNumberIndex',
37+
'NhsNumber',
38+
activePatient.toString(),
39+
);
40+
cy.deleteItemsBySecondaryKeyFromDynamoDb(
41+
stitchTableName,
42+
'NhsNumberIndex',
43+
'NhsNumber',
44+
activePatient.toString(),
45+
);
46+
uploadedFileNames.forEach((file) => {
47+
cy.deleteFileFromS3(bucketName, file);
48+
});
10049
});
101-
cy.get('#continue-button').click();
10250

103-
cy.url().should('contain', selectOrderUrl);
104-
cy.get('#selected-documents-table').should('exist');
105-
uploadedFileNames.forEach((name) => {
106-
cy.get('#selected-documents-table').should('contain', name);
51+
afterEach(() => {
52+
//clean up any records present for the active patient
53+
cy.deleteItemsBySecondaryKeyFromDynamoDb(
54+
referenceTableName,
55+
'NhsNumberIndex',
56+
'NhsNumber',
57+
activePatient.toString(),
58+
);
59+
cy.deleteItemsBySecondaryKeyFromDynamoDb(
60+
stitchTableName,
61+
'NhsNumberIndex',
62+
'NhsNumber',
63+
activePatient.toString(),
64+
);
65+
uploadedFileNames.forEach((file) => {
66+
cy.deleteFileFromS3(bucketName, file);
67+
});
10768
});
108-
cy.getByTestId('form-submit-button').click();
10969

110-
cy.url().should('contain', confirmationUrl);
111-
uploadedFileNames.forEach((name) => {
112-
cy.get('#selected-documents-table').should('contain', name);
113-
});
114-
cy.getByTestId('confirm-button').click();
115-
116-
cy.getByTestId('upload-complete-page', { timeout: 25000 }).should('exist');
117-
cy.getByTestId('upload-complete-page')
118-
.should('include.text', 'You have successfully uploaded a digital Lloyd George record for');
119-
120-
cy.getByTestId('upload-complete-card').should('be.visible');
121-
122-
cy.getByTestId('home-btn').eq(1).click();
123-
124-
cy.navigateToPatientSearchPage();
125-
126-
cy.get('#nhs-number-input').type(activePatient);
127-
cy.get('#search-submit').click();
128-
cy.wait(5000)
129-
130-
cy.get('.patient-results-form').submit();
131-
132-
cy.get("#pdf-viewer", {timeout: 20000}).should('exist');
133-
});
134-
});
70+
it(
71+
'[Smoke] GP ADMIN can upload multiple files and then view a Lloyd George record for an active patient with no record',
72+
{ tags: 'smoke', defaultCommandTimeout: 20000 },
73+
() => {
74+
cy.smokeLogin(Roles.SMOKE_GP_ADMIN);
75+
76+
cy.navigateToPatientSearchPage();
77+
78+
cy.get('#nhs-number-input').should('exist');
79+
cy.get('#nhs-number-input').click();
80+
cy.get('#nhs-number-input').type(activePatient);
81+
cy.getByTestId('search-submit-btn').should('exist');
82+
cy.getByTestId('search-submit-btn').click();
83+
84+
cy.url({ timeout: 15000 }).should('contain', patientVerifyUrl);
85+
86+
cy.get('#verify-submit').should('exist');
87+
cy.get('#verify-submit').click();
88+
89+
cy.url().should('contain', lloydGeorgeRecordUrl);
90+
cy.getByTestId('no-records-title').should(
91+
'include.text',
92+
'This patient does not have a Lloyd George record',
93+
);
94+
cy.getByTestId('upload-patient-record-button').should('exist');
95+
cy.getByTestId('upload-patient-record-button').click();
96+
uploadedFilePathNames.forEach((file) => {
97+
cy.getByTestId('button-input').selectFile(file, { force: true });
98+
var index = uploadedFilePathNames.indexOf(file);
99+
cy.get('#selected-documents-table').should('contain', uploadedFileNames[index]);
100+
});
101+
cy.get('#continue-button').click();
102+
103+
cy.url().should('contain', selectOrderUrl);
104+
cy.get('#selected-documents-table').should('exist');
105+
uploadedFileNames.forEach((name) => {
106+
cy.get('#selected-documents-table').should('contain', name);
107+
});
108+
cy.getByTestId('form-submit-button').click();
109+
110+
cy.url().should('contain', confirmationUrl);
111+
uploadedFileNames.forEach((name) => {
112+
cy.get('#selected-documents-table').should('contain', name);
113+
});
114+
cy.getByTestId('confirm-button').click();
115+
116+
cy.getByTestId('upload-complete-page', { timeout: 25000 }).should('exist');
117+
cy.getByTestId('upload-complete-page').should(
118+
'include.text',
119+
'You have successfully uploaded a digital Lloyd George record for',
120+
);
121+
122+
cy.getByTestId('upload-complete-card').should('be.visible');
123+
124+
cy.getByTestId('home-btn').eq(1).click();
125+
126+
cy.navigateToPatientSearchPage();
127+
128+
cy.get('#nhs-number-input').type(activePatient);
129+
cy.get('#search-submit').click();
130+
cy.wait(5000);
131+
132+
cy.get('.patient-results-form').submit();
133+
134+
cy.get('#pdf-viewer', { timeout: 20000 }).should('exist');
135+
},
136+
);
137+
});
135138
});

app/cypress/support/patients.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const pdsPatients = {
2-
activeUpload: 9730153817,
3-
activeNoUpload: 9730153930,
2+
activeUpload: 9730153817,
3+
activeNoUpload: 9730153930,
44
};
55
export const stubPatients = {
6-
activeUpload: 9730153817,
7-
activeNoUpload: 9000000068,
6+
activeUpload: 9730153817,
7+
activeNoUpload: 9000000068,
88
};

app/src/components/blocks/_documentUpload/documentSelectOrderStage/DocumentSelectOrderStage.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ const DocumentSelectOrderStage = ({
166166

167167
if (docToRemove.position) {
168168
updatedDocList = updatedDocList.map((doc) => {
169+
if (doc.docType !== docToRemove.docType) {
170+
return doc;
171+
}
172+
169173
if (doc.position && +doc.position > +docToRemove.position!) {
170174
doc.position = +doc.position - 1;
171175
}
@@ -185,7 +189,12 @@ const DocumentSelectOrderStage = ({
185189
position: fieldValues[documentPositionKey(doc.id)]!,
186190
}));
187191

188-
setDocuments(updatedDocuments);
192+
setDocuments((previousState) => {
193+
return previousState.map((doc) => {
194+
const updatedDoc = updatedDocuments.find((d) => d.id === doc.id);
195+
return updatedDoc ? updatedDoc : doc;
196+
});
197+
});
189198
};
190199

191200
const submitDocuments = (): void => {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.document-select-stage {
2+
.action-buttons {
3+
display: flex;
4+
align-items: center;
5+
6+
.continue-button {
7+
margin-bottom: 0;
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)