Skip to content

Commit

Permalink
refactor: retain original formatName functionility 4 other places
Browse files Browse the repository at this point in the history
There were some screens that were not using the new customised formatName() so the refactor to formatName broke thier e2e tests, the temporary solution is to add a new function formatNameWithFirstNameFirst() which uses the old logic until the screen are updated

opencrvs/opencrvs-core#6830
  • Loading branch information
Siyasanga committed Nov 14, 2024
1 parent 747c1fb commit 2d54f9e
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 80 deletions.
4 changes: 4 additions & 0 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ export const formatName = (name: PersonOrName) => {
return joinValuesWith([name.familyName, name.firstNames])
}

export const formatNameWithFirstNameFirst = (name: PersonOrName) => {
return joinValuesWith([name.firstNames, name.familyName])
}

export const drawSignature = async (page: Page) => {
const canvas = page.locator('#informantSignature_modal canvas')
const rect = await canvas.boundingBox()
Expand Down
26 changes: 17 additions & 9 deletions e2e/testcases/correction-birth/correct-birth-record-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
formatDateTo_ddMMMMyyyy,
formatDateTo_yyyyMMdd,
formatName,
formatNameWithFirstNameFirst,
getAction,
getLocationNameFromFhirId,
getToken,
Expand Down Expand Up @@ -712,8 +713,8 @@ test.describe('1. Correct record - 1', () => {
await expect(
page.getByText(
'Full name (Child)' +
formatName(declaration.child.name[0]) +
formatName(updatedChildDetails)
formatNameWithFirstNameFirst(declaration.child.name[0]) +
formatNameWithFirstNameFirst(updatedChildDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -768,7 +769,9 @@ test.describe('1. Correct record - 1', () => {
).toBeVisible()

await expect(
page.getByText(formatName(declaration.mother.name[0]))
page.getByText(
formatNameWithFirstNameFirst(declaration.mother.name[0])
)
).toBeVisible()
await expect(page.getByText('Verified')).toBeVisible()
await expect(
Expand Down Expand Up @@ -802,7 +805,9 @@ test.describe('1. Correct record - 1', () => {
await page.getByRole('button', { name: 'Sent for approval' }).click()

await expect(
page.getByText(formatName(declaration.child.name[0])).first()
page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
).toBeVisible()
})
})
Expand Down Expand Up @@ -847,7 +852,8 @@ test.describe('1. Correct record - 1', () => {

await expect(
page.getByText(
'Requested by' + formatName(declaration.mother.name[0])
'Requested by' +
formatNameWithFirstNameFirst(declaration.mother.name[0])
)
).toBeVisible()

Expand All @@ -866,8 +872,8 @@ test.describe('1. Correct record - 1', () => {
await expect(
page.getByText(
'Full name (Child)' +
formatName(declaration.child.name[0]) +
formatName(updatedChildDetails)
formatNameWithFirstNameFirst(declaration.child.name[0]) +
formatNameWithFirstNameFirst(updatedChildDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -936,12 +942,14 @@ test.describe('1. Correct record - 1', () => {
await expectOutboxToBeEmpty(page)
await page.getByRole('button', { name: 'Ready to print' }).click()
await expect(
page.getByText(formatName(updatedChildDetails))
page.getByText(formatNameWithFirstNameFirst(updatedChildDetails))
).toBeVisible()
})
test.describe('1.2.6.4 Validate history in record audit', async () => {
test('1.2.6.4.1 Validate entries in record audit', async () => {
await page.getByText(formatName(updatedChildDetails)).click()
await page
.getByText(formatNameWithFirstNameFirst(updatedChildDetails))
.click()

await assignRecord(page)

Expand Down
16 changes: 11 additions & 5 deletions e2e/testcases/correction-birth/correct-birth-record-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
formatDateTo_ddMMMMyyyy,
formatDateTo_yyyyMMdd,
formatName,
formatNameWithFirstNameFirst,
getAction,
getToken,
goBackToReview,
Expand Down Expand Up @@ -806,8 +807,8 @@ test.describe.serial('Correct record - 2', () => {
await expect(
page.getByText(
'Full name (informant)' +
formatName(declaration.informant.name[0]) +
formatName(updatedInformantDetails)
formatNameWithFirstNameFirst(declaration.informant.name[0]) +
formatNameWithFirstNameFirst(updatedInformantDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -868,7 +869,7 @@ test.describe.serial('Correct record - 2', () => {
).toBeVisible()

await expect(
page.getByText(formatName(declaration.father.name[0]))
page.getByText(formatNameWithFirstNameFirst(declaration.father.name[0]))
).toBeVisible()
await expect(page.getByText('Identity does not match')).toBeVisible()
await expect(
Expand Down Expand Up @@ -896,7 +897,9 @@ test.describe.serial('Correct record - 2', () => {
await page.getByRole('button', { name: 'Sent for approval' }).click()

await expect(
page.getByText(formatName(declaration.child.name[0])).first()
page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
).toBeVisible()
})
test.describe('2.8 Correction Approval', async () => {
Expand Down Expand Up @@ -937,7 +940,10 @@ test.describe.serial('Correct record - 2', () => {
await expect(page.getByText('Submitter' + 'Felix Katongo')).toBeVisible()

await expect(
page.getByText('Requested by' + formatName(declaration.father.name[0]))
page.getByText(
'Requested by' +
formatNameWithFirstNameFirst(declaration.father.name[0])
)
).toBeVisible()

await expect(
Expand Down
13 changes: 8 additions & 5 deletions e2e/testcases/correction-birth/correct-birth-record-3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
expectOutboxToBeEmpty,
formatDateTo_ddMMMMyyyy,
formatName,
formatNameWithFirstNameFirst,
getAction,
getToken,
goBackToReview,
Expand Down Expand Up @@ -145,13 +146,15 @@ test.describe.serial(' Correct record - 3', () => {
await expectOutboxToBeEmpty(page)
await page.getByRole('button', { name: 'Ready to issue' }).click()
await expect(
page.getByText(formatName(declaration.child.name[0])).first()
page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
).toBeVisible()
})

test('3.1.3 Record audit', async () => {
await page
.getByText(formatName(declaration.child.name[0]))
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
.click()
await assignRecord(page)
Expand Down Expand Up @@ -772,8 +775,8 @@ test.describe.serial(' Correct record - 3', () => {
await expect(
page.getByText(
'Full name (mother)' +
formatName(declaration.mother.name[0]) +
formatName(updatedMotherDetails)
formatNameWithFirstNameFirst(declaration.mother.name[0]) +
formatNameWithFirstNameFirst(updatedMotherDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -840,7 +843,7 @@ test.describe.serial(' Correct record - 3', () => {
).toBeVisible()

await expect(
page.getByText(formatName(declaration.child.name[0]))
page.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
).toBeVisible()
await expect(page.getByText('Verified')).toBeVisible()
await expect(
Expand Down
14 changes: 10 additions & 4 deletions e2e/testcases/correction-birth/correct-birth-record-4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
formatDateTo_ddMMMMyyyy,
formatDateTo_yyyyMMdd,
formatName,
formatNameWithFirstNameFirst,
getAction,
getToken,
goBackToReview,
Expand Down Expand Up @@ -674,8 +675,8 @@ test.describe.serial(' Correct record - 4', () => {
await expect(
page.getByText(
'Full name (father)' +
formatName(declaration.father.name[0]) +
formatName(updatedFatherDetails)
formatNameWithFirstNameFirst(declaration.father.name[0]) +
formatNameWithFirstNameFirst(updatedFatherDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -765,11 +766,16 @@ test.describe.serial(' Correct record - 4', () => {
*/

await expect(
page.getByText(formatName(declaration.child.name[0])).first()
page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
).toBeVisible()
})
test('4.8 Validate history in record audit', async () => {
await page.getByText(formatName(declaration.child.name[0])).first().click()
await page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
.click()

await assignRecord(page)

Expand Down
13 changes: 9 additions & 4 deletions e2e/testcases/correction-birth/correct-birth-record-5.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
expectOutboxToBeEmpty,
formatDateTo_ddMMMMyyyy,
formatName,
formatNameWithFirstNameFirst,
getAction,
getToken,
goBackToReview,
Expand Down Expand Up @@ -565,8 +566,8 @@ test.describe.serial(' Correct record - 5', () => {
await expect(
page.getByText(
'Full name (Child)' +
formatName(declaration.child.name[0]) +
formatName(updatedChildDetails)
formatNameWithFirstNameFirst(declaration.child.name[0]) +
formatNameWithFirstNameFirst(updatedChildDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -654,10 +655,14 @@ test.describe.serial(' Correct record - 5', () => {
* - include the declaration in this tab
*/

await expect(page.getByText(formatName(updatedChildDetails))).toBeVisible()
await expect(
page.getByText(formatNameWithFirstNameFirst(updatedChildDetails))
).toBeVisible()
})
test('5.8 Validate history in record audit', async () => {
await page.getByText(formatName(updatedChildDetails)).click()
await page
.getByText(formatNameWithFirstNameFirst(updatedChildDetails))
.click()

await assignRecord(page)

Expand Down
17 changes: 11 additions & 6 deletions e2e/testcases/correction-birth/correct-birth-record-6.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
expectOutboxToBeEmpty,
formatDateTo_ddMMMMyyyy,
formatName,
formatNameWithFirstNameFirst,
getAction,
getToken,
goBackToReview,
Expand Down Expand Up @@ -130,11 +131,13 @@ test.describe.serial(' Correct record - 6', () => {
await expectOutboxToBeEmpty(page)

await expect(
page.getByText(formatName(declaration.child.name[0])).first()
page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
).toBeVisible()

await page
.getByText(formatName(declaration.child.name[0]))
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
.click()
})
Expand Down Expand Up @@ -622,8 +625,8 @@ test.describe.serial(' Correct record - 6', () => {
await expect(
page.getByText(
'Full name (informant)' +
formatName(declaration.informant.name[0]) +
formatName(updatedInformantDetails)
formatNameWithFirstNameFirst(declaration.informant.name[0]) +
formatNameWithFirstNameFirst(updatedInformantDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -704,11 +707,13 @@ test.describe.serial(' Correct record - 6', () => {
*/

await expect(
page.getByText(formatName(declaration.child.name[0]))
page.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
).toBeVisible()
})
test('6.8 Validate history in record audit', async () => {
await page.getByText(formatName(declaration.child.name[0])).click()
await page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.click()

await assignRecord(page)

Expand Down
14 changes: 10 additions & 4 deletions e2e/testcases/correction-birth/correct-birth-record-7.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
expectAddress,
expectOutboxToBeEmpty,
formatName,
formatNameWithFirstNameFirst,
getAction,
getToken,
goBackToReview,
Expand Down Expand Up @@ -455,8 +456,8 @@ test.describe.serial(' Correct record - 7', () => {
await expect(
page.getByText(
'Full name (mother)' +
formatName(declaration.mother.name[0]) +
formatName(updatedMotherDetails)
formatNameWithFirstNameFirst(declaration.mother.name[0]) +
formatNameWithFirstNameFirst(updatedMotherDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -553,11 +554,16 @@ test.describe.serial(' Correct record - 7', () => {
*/

await expect(
page.getByText(formatName(declaration.child.name[0])).first()
page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
).toBeVisible()
})
test('7.8 Validate history in record audit', async () => {
await page.getByText(formatName(declaration.child.name[0])).first().click()
await page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
.click()

await assignRecord(page)

Expand Down
14 changes: 10 additions & 4 deletions e2e/testcases/correction-birth/correct-birth-record-8.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
expectOutboxToBeEmpty,
formatDateTo_ddMMMMyyyy,
formatName,
formatNameWithFirstNameFirst,
getAction,
getToken,
goBackToReview,
Expand Down Expand Up @@ -430,8 +431,8 @@ test.describe.serial(' Correct record - 8', () => {
await expect(
page.getByText(
'Full name (father)' +
formatName(declaration.father.name[0]) +
formatName(updatedFatherDetails)
formatNameWithFirstNameFirst(declaration.father.name[0]) +
formatNameWithFirstNameFirst(updatedFatherDetails)
)
).toBeVisible()

Expand Down Expand Up @@ -516,12 +517,17 @@ test.describe.serial(' Correct record - 8', () => {
*/

await expect(
page.getByText(formatName(declaration.child.name[0])).first()
page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
).toBeVisible()
})

test('8.8 Validate history in record audit', async () => {
await page.getByText(formatName(declaration.child.name[0])).first().click()
await page
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
.click()

await assignRecord(page)

Expand Down
Loading

0 comments on commit 2d54f9e

Please sign in to comment.