Skip to content

Commit 4d24dae

Browse files
authored
Merge pull request #1874 from opencrvs/ocrvs-10939
Add e2e tests for edit action
2 parents b0a22f4 + 2ecca1c commit 4d24dae

31 files changed

+692
-183
lines changed

e2e/helpers.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,13 @@ export async function switchEventTab(page: Page, tab: 'Audit' | 'Record') {
591591
/** Assert whether a button on the action menu exists and is enabled/disabled */
592592
export async function validateActionMenuButton(
593593
page: Page,
594-
action: 'Declare' | 'Notify' | 'Approve declaration' | 'Register',
594+
action:
595+
| 'Declare'
596+
| 'Notify'
597+
| 'Approve declaration'
598+
| 'Register'
599+
| 'Declare with edits'
600+
| 'Register with edits',
595601
isEnabled = true
596602
) {
597603
await page.getByRole('button', { name: 'Action', exact: true }).click()
@@ -616,14 +622,22 @@ export async function selectDeclarationAction(
616622
| 'Register'
617623
| 'Reject'
618624
| 'Delete declaration'
619-
| 'Save & Exit',
625+
| 'Save & Exit'
626+
| 'Declare with edits'
627+
| 'Register with edits',
620628
confirm = true
621629
) {
622630
await page.getByRole('button', { name: 'Action', exact: true }).click()
623631
await page.getByText(action, { exact: true }).click()
624632

625633
if (confirm) {
626-
await page.getByRole('button', { name: action, exact: true }).click()
634+
const confirmBtn = page.getByRole('button', { name: 'Confirm' })
635+
636+
if ((await confirmBtn.count()) > 0) {
637+
await confirmBtn.click()
638+
} else {
639+
await page.getByRole('button', { name: action, exact: true }).click()
640+
}
627641
}
628642
}
629643

e2e/testcases/action-menu/action-menu-options.spec.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { login, getToken } from '../../helpers'
44
import { CREDENTIALS } from '../../constants'
55
import { createDeclaration, Declaration } from '../test-data/birth-declaration'
66
import { ActionType } from '@opencrvs/toolkit/events'
7+
import { selectAction } from '../../utils'
78

89
async function getActionMenuOptions(page: Page, declaration: Declaration) {
910
const childName = `${declaration['child.name'].firstname} ${declaration['child.name'].surname}`
@@ -32,8 +33,8 @@ test.describe('Action menu options', () => {
3233

3334
test.beforeAll(async () => {
3435
const token = await getToken(
35-
CREDENTIALS.LOCAL_REGISTRAR.USERNAME,
36-
CREDENTIALS.LOCAL_REGISTRAR.PASSWORD
36+
CREDENTIALS.FIELD_AGENT.USERNAME,
37+
CREDENTIALS.FIELD_AGENT.PASSWORD
3738
)
3839
const res = await createDeclaration(token, undefined, ActionType.DECLARE)
3940
declaration = res.declaration
@@ -43,8 +44,20 @@ test.describe('Action menu options', () => {
4344
await login(page, CREDENTIALS.REGISTRATION_AGENT)
4445
await page.getByRole('button', { name: 'Ready for review' }).click()
4546
const options = await getActionMenuOptions(page, declaration)
46-
expect(options).toStrictEqual(['Assign', 'Validate', 'Archive', 'Reject'])
47-
expect(options).toStrictEqual(['Assign', 'Validate', 'Archive', 'Reject'])
47+
expect(options).toStrictEqual([
48+
'Assign',
49+
'Validate',
50+
'Archive',
51+
'Reject',
52+
'Edit'
53+
])
54+
expect(options).toStrictEqual([
55+
'Assign',
56+
'Validate',
57+
'Archive',
58+
'Reject',
59+
'Edit'
60+
])
4861
})
4962

5063
test('Local Registrar', async () => {
@@ -56,20 +69,21 @@ test.describe('Action menu options', () => {
5669
'Register',
5770
'Archive',
5871
'Reject',
72+
'Edit',
5973
'Escalate'
6074
])
6175
})
6276
})
6377

64-
test.describe('Event status: VALIDATED', async () => {
78+
test.describe('Declared and validated', async () => {
6579
let declaration: Declaration
6680

6781
test.beforeAll(async () => {
6882
const token = await getToken(
6983
CREDENTIALS.LOCAL_REGISTRAR.USERNAME,
7084
CREDENTIALS.LOCAL_REGISTRAR.PASSWORD
7185
)
72-
const res = await createDeclaration(token, undefined, ActionType.VALIDATE)
86+
const res = await createDeclaration(token, undefined, ActionType.DECLARE)
7387
declaration = res.declaration
7488
})
7589

@@ -78,10 +92,11 @@ test.describe('Action menu options', () => {
7892
await page.getByRole('button', { name: 'Ready for review' }).click()
7993
const options = await getActionMenuOptions(page, declaration)
8094
expect(options).toStrictEqual([
81-
'Unassign',
95+
'Assign',
8296
'Register',
8397
'Archive',
8498
'Reject',
99+
'Edit',
85100
'Escalate'
86101
])
87102
})

e2e/testcases/application/4a-validate-require-update-FA.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,15 @@ test.describe
9898

9999
const row = getRowByTitle(page, formatV2ChildName(declaration))
100100

101-
await row.getByRole('button', { name: 'Review' }).click()
101+
await row.getByRole('button', { name: 'Edit' }).click()
102102

103-
await selectDeclarationAction(page, 'Declare')
103+
await page.getByTestId('change-button-child.name').click()
104+
await page
105+
.getByTestId('text__surname')
106+
.fill(faker.person.lastName('female'))
107+
await page.getByRole('button', { name: 'Back to review' }).click()
108+
109+
await selectDeclarationAction(page, 'Declare with edits')
104110

105111
// Should redirect back to requires update workqueue
106112
await expect(page.locator('#content-name')).toHaveText('Requires updates')

e2e/testcases/application/4b-validate-require-update-RA.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test.describe
2525
CREDENTIALS.REGISTRATION_AGENT.USERNAME,
2626
CREDENTIALS.REGISTRATION_AGENT.PASSWORD
2727
)
28-
const res = await createDeclaration(token, undefined, ActionType.VALIDATE)
28+
const res = await createDeclaration(token, undefined, ActionType.DECLARE)
2929
declaration = res.declaration
3030
eventId = res.eventId
3131

@@ -101,13 +101,17 @@ test.describe
101101
)
102102
})
103103

104-
test('4.4 Click Review -action', async () => {
104+
test('4.4 Click Edit -action', async () => {
105105
await ensureAssigned(page)
106-
await selectAction(page, 'Review')
106+
await selectAction(page, 'Edit')
107107
})
108108

109-
test('4.5 Complete validate action', async () => {
110-
await selectDeclarationAction(page, 'Validate')
109+
test('4.5 Complete declare with edits action', async () => {
110+
await page.getByTestId('change-button-child.weightAtBirth').click()
111+
await page.getByTestId('number__child____weightAtBirth').fill('2.6')
112+
await page.getByRole('button', { name: 'Back to review' }).click()
113+
114+
await selectDeclarationAction(page, 'Declare with edits')
111115

112116
// Should redirect back to requires update workqueue
113117
await expect(page.locator('#content-name')).toHaveText('Requires updates')

e2e/testcases/application/6-validate-ready-to-print.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { login, getToken } from '../../helpers'
44
import { CREDENTIALS, SAFE_WORKQUEUE_TIMEOUT_MS } from '../../constants'
55
import { createDeclaration, Declaration } from '../test-data/birth-declaration'
66
import { formatV2ChildName } from '../birth/helpers'
7-
import { ensureAssigned, expectInUrl, selectAction } from '../../utils'
7+
import { expectInUrl, selectAction } from '../../utils'
88

99
test.describe.serial('6 Validate Ready to print tab', () => {
1010
let page: Page

e2e/testcases/application/7-validate-sent-for-approval.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test.describe.serial('7 Validate Sent for approval tab', () => {
1818
CREDENTIALS.REGISTRATION_AGENT.USERNAME,
1919
CREDENTIALS.REGISTRATION_AGENT.PASSWORD
2020
)
21-
const res = await createDeclaration(token, undefined, ActionType.VALIDATE)
21+
const res = await createDeclaration(token, undefined, ActionType.DECLARE)
2222
declaration = res.declaration
2323
eventId = res.eventId
2424

e2e/testcases/application/workqueue-flow-1.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { assertRecordInWorkqueue, fillDate } from '../birth/helpers'
2020
import { getRowByTitle } from '../print-certificate/birth/helpers'
2121

2222
// FA Notifies => RA Validates => LR Registers => LR Prints
23-
2423
test.describe.serial('1. Workqueue flow - 1', () => {
2524
let page: Page
2625
const declaration = {
@@ -148,7 +147,7 @@ test.describe.serial('1. Workqueue flow - 1', () => {
148147
})
149148
})
150149

151-
test.describe('1.2 Validate by RA', async () => {
150+
test.describe('1.2 Declare and validate by RA', async () => {
152151
test('1.2.1 Verify workqueue', async () => {
153152
await login(page, CREDENTIALS.REGISTRATION_AGENT)
154153

@@ -262,8 +261,8 @@ test.describe.serial('1. Workqueue flow - 1', () => {
262261
await page.getByRole('button', { name: 'Back to review' }).click()
263262
})
264263

265-
test('1.2.6 Validate', async () => {
266-
await selectDeclarationAction(page, 'Validate')
264+
test('1.2.6 Declare', async () => {
265+
await selectDeclarationAction(page, 'Declare')
267266

268267
await ensureOutboxIsEmpty(page)
269268

e2e/testcases/application/workqueue-flow-3.spec.ts

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,16 @@ test.describe.serial('3. Workqueue flow - 3', () => {
217217
})
218218
.click()
219219

220+
await expect(page.getByText('Rejected')).toBeVisible()
221+
220222
await ensureAssigned(page)
221-
await selectAction(page, 'Review')
222223
await page.getByRole('button', { name: 'Action' }).click()
223-
await expect(page.getByText('Reject')).not.toBeVisible()
224+
await expect(page.getByText('Reject', { exact: true })).not.toBeVisible()
225+
await expect(page.getByText('Review', { exact: true })).not.toBeVisible()
226+
await page.getByRole('button', { name: 'Action' }).click()
224227
})
225228

226229
test('3.2.4 Unassign', async () => {
227-
await page.goBack()
228230
await selectAction(page, 'Unassign')
229231
await page.getByRole('button', { name: 'Unassign', exact: true }).click()
230232
await expect(page.getByText('Not assigned')).toBeVisible()
@@ -245,11 +247,11 @@ test.describe.serial('3. Workqueue flow - 3', () => {
245247
]
246248
})
247249
})
248-
test('3.3.2 Go to review', async () => {
250+
test('3.3.2 Go to edit', async () => {
249251
await assignFromWorkqueue(page, childName)
250252

251253
await getRowByTitle(page, childName)
252-
.getByRole('button', { name: 'Review' })
254+
.getByRole('button', { name: 'Edit' })
253255
.click()
254256
})
255257

@@ -259,8 +261,6 @@ test.describe.serial('3. Workqueue flow - 3', () => {
259261
.getByRole('button', { name: 'Change all' })
260262
.click()
261263

262-
await page.getByRole('button', { name: 'Continue' }).click()
263-
264264
await page.locator('#informant____relation').click()
265265
await page
266266
.getByText(declaration.informantType, {
@@ -336,12 +336,19 @@ test.describe.serial('3. Workqueue flow - 3', () => {
336336
await page.locator('#father____addressSameAs_YES').click()
337337
})
338338

339-
test('3.3.6 Declare', async () => {
339+
test('3.3.6 Fill up informant comment & signature', async () => {
340340
await continueForm(page, 'Back to review')
341-
await expect(page.getByRole('dialog')).not.toBeVisible()
342-
343-
await selectDeclarationAction(page, 'Declare')
341+
await page.locator('#review____comment').fill(faker.lorem.sentence())
342+
await page.getByRole('button', { name: 'Sign', exact: true }).click()
343+
await drawSignature(page, 'review____signature_canvas_element', false)
344+
await page
345+
.locator('#review____signature_modal')
346+
.getByRole('button', { name: 'Apply' })
347+
.click()
348+
})
344349

350+
test('3.3.6 Declare with edits', async () => {
351+
await selectDeclarationAction(page, 'Declare with edits')
345352
await ensureOutboxIsEmpty(page)
346353
})
347354

@@ -453,7 +460,7 @@ test.describe.serial('3. Workqueue flow - 3', () => {
453460
})
454461
})
455462
})
456-
test.describe('3.6 Re-validate by RA', async () => {
463+
test.describe('3.6 Re-declare with edits by RA', async () => {
457464
test('3.6.1 Login with RA', async () => {
458465
await login(page, CREDENTIALS.REGISTRATION_AGENT, true)
459466

@@ -473,16 +480,29 @@ test.describe.serial('3. Workqueue flow - 3', () => {
473480
})
474481
})
475482

476-
test('3.6.2 Re-validate', async () => {
483+
test('3.6.2 Go to edit', async () => {
477484
await page.getByText('Requires updates').click()
478-
479485
await assignFromWorkqueue(page, childName)
480486
await getRowByTitle(page, childName)
481-
.getByRole('button', { name: 'Review' })
487+
.getByRole('button', { name: 'Edit' })
482488
.click()
489+
})
483490

484-
await selectAction(page, 'Validate')
485-
await page.getByRole('button', { name: 'Validate' }).click()
491+
test('3.6.3 Change informant email', async () => {
492+
await page
493+
.getByTestId('accordion-Accordion_informant')
494+
.getByRole('button', { name: 'Change all' })
495+
.click()
496+
497+
await page.locator('#informant____email').fill(faker.internet.email())
498+
499+
await page
500+
.getByRole('button', { name: 'Back to review', exact: true })
501+
.click()
502+
})
503+
504+
test('3.6.4 Re-declare with edits', async () => {
505+
await selectDeclarationAction(page, 'Declare with edits')
486506

487507
await assertRecordInWorkqueue({
488508
page,

0 commit comments

Comments
 (0)