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 3be87d1
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 27 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
16 changes: 11 additions & 5 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 Down
7 changes: 4 additions & 3 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
7 changes: 5 additions & 2 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
9 changes: 6 additions & 3 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,7 +766,9 @@ 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 () => {
Expand Down
9 changes: 6 additions & 3 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,7 +655,9 @@ 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()
Expand Down
7 changes: 5 additions & 2 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
5 changes: 3 additions & 2 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
9 changes: 6 additions & 3 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,7 +517,9 @@ 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()
})

Expand Down
7 changes: 5 additions & 2 deletions e2e/testcases/correction-birth/correct-birth-record-9.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 - 9', () => {
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()

await page
.getByText(formatName(declaration.child.name[0]))
.getByText(formatNameWithFirstNameFirst(declaration.child.name[0]))
.first()
.click()
})
Expand Down
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 @@ -800,8 +801,8 @@ test.describe('10. Correct record - 10', () => {
await expect(
page.getByText(
'Full name (Deceased)' +
formatName(declaration.deceased.name[0]) +
formatName(updatedDeceasedDetails)
formatNameWithFirstNameFirst(declaration.deceased.name[0]) +
formatNameWithFirstNameFirst(updatedDeceasedDetails)
)
).toBeVisible()

Expand Down

0 comments on commit 3be87d1

Please sign in to comment.