Skip to content

Commit 7059802

Browse files
authored
Merge branch 'develop' into ocrvs-11148
2 parents fbd99c2 + a5fd298 commit 7059802

37 files changed

+1285
-1505
lines changed

e2e/helpers.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export async function ensureLoginPageReady(page: Page) {
163163
*/
164164
await page.waitForSelector('#Box img', { state: 'attached' })
165165
await page.waitForFunction(() => {
166+
// eslint-disable-next-line no-undef
166167
const img = document.querySelector<HTMLImageElement>('#Box img')!
167168
return img && img.src && img.src.trim() !== ''
168169
})
@@ -590,7 +591,13 @@ export async function switchEventTab(page: Page, tab: 'Audit' | 'Record') {
590591
/** Assert whether a button on the action menu exists and is enabled/disabled */
591592
export async function validateActionMenuButton(
592593
page: Page,
593-
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',
594601
isEnabled = true
595602
) {
596603
await page.getByRole('button', { name: 'Action', exact: true }).click()
@@ -615,13 +622,30 @@ export async function selectDeclarationAction(
615622
| 'Register'
616623
| 'Reject'
617624
| 'Delete declaration'
618-
| 'Save & Exit',
625+
| 'Save & Exit'
626+
| 'Declare with edits'
627+
| 'Register with edits',
619628
confirm = true
620629
) {
621630
await page.getByRole('button', { name: 'Action', exact: true }).click()
622631
await page.getByText(action, { exact: true }).click()
623632

624633
if (confirm) {
625-
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+
}
626641
}
627642
}
643+
644+
export async function searchFromSearchBar(page: Page, searchText: string) {
645+
const searchResultRegex = /Search result for ([^]+)/
646+
await page.locator('#searchText').fill(searchText)
647+
await page.locator('#searchIconButton').click()
648+
const searchResult = await page.locator('#content-name').textContent()
649+
expect(searchResult).toMatch(searchResultRegex)
650+
await page.getByText(searchText, { exact: true }).click()
651+
}

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

Lines changed: 37 additions & 10 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,27 +44,46 @@ 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 () => {
5164
await login(page, CREDENTIALS.LOCAL_REGISTRAR)
5265
await page.getByRole('button', { name: 'Ready for review' }).click()
5366
const options = await getActionMenuOptions(page, declaration)
54-
expect(options).toStrictEqual(['Assign', 'Register', 'Archive', 'Reject'])
67+
expect(options).toStrictEqual([
68+
'Assign',
69+
'Register',
70+
'Archive',
71+
'Reject',
72+
'Edit',
73+
'Escalate'
74+
])
5575
})
5676
})
5777

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

6181
test.beforeAll(async () => {
6282
const token = await getToken(
6383
CREDENTIALS.LOCAL_REGISTRAR.USERNAME,
6484
CREDENTIALS.LOCAL_REGISTRAR.PASSWORD
6585
)
66-
const res = await createDeclaration(token, undefined, ActionType.VALIDATE)
86+
const res = await createDeclaration(token, undefined, ActionType.DECLARE)
6787
declaration = res.declaration
6888
})
6989

@@ -72,10 +92,12 @@ test.describe('Action menu options', () => {
7292
await page.getByRole('button', { name: 'Ready for review' }).click()
7393
const options = await getActionMenuOptions(page, declaration)
7494
expect(options).toStrictEqual([
75-
'Unassign',
95+
'Assign',
7696
'Register',
7797
'Archive',
78-
'Reject'
98+
'Reject',
99+
'Edit',
100+
'Escalate'
79101
])
80102
})
81103
})
@@ -96,7 +118,12 @@ test.describe('Action menu options', () => {
96118
await login(page, CREDENTIALS.LOCAL_REGISTRAR)
97119
await page.getByRole('button', { name: 'Ready to print' }).click()
98120
const options = await getActionMenuOptions(page, declaration)
99-
expect(options).toStrictEqual(['Assign', 'Print', 'Correct record'])
121+
expect(options).toStrictEqual([
122+
'Assign',
123+
'Print',
124+
'Correct record',
125+
'Escalate'
126+
])
100127
})
101128
})
102129
})

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)