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 3874e9e
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 19 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
13 changes: 9 additions & 4 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
5 changes: 3 additions & 2 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
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,7 +146,9 @@ 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()
})

Expand Down
5 changes: 3 additions & 2 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
5 changes: 3 additions & 2 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
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,7 +131,9 @@ 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
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
5 changes: 3 additions & 2 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
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,7 +131,9 @@ 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
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 3874e9e

Please sign in to comment.