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 15, 2024
1 parent 747c1fb commit a886c0f
Show file tree
Hide file tree
Showing 20 changed files with 213 additions and 102 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- "Publish release" pipeline now correctly uses the "Branch to build from" value as the branch to be tagged. Previously it tried tagging "master". "Release tag" is also now used as the release version as is instead of it being read from `package.json`.
- Backup process now doesn't require internet connection to download docker images thus working more reliably when internet connections are unreliable. Previously non-active images were cleaned nightly, now we only do it as part of deployment. [#7896](https://github.com/opencrvs/opencrvs-core/issues/7896)
- We make sure that the automatic cleanup job only runs before deployment (instead of cron schedule cleanup).
- Fix failing e2e tests that were broken by allowing countries to customise the order of their full name, this has been fixed by retaining the old logic for the screen that not using the customised full name [#6830](https://github.com/opencrvs/opencrvs-core/issues/6830)

### Breaking changes

Expand Down
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
26 changes: 17 additions & 9 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 Expand Up @@ -985,8 +991,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 @@ -1060,14 +1066,16 @@ test.describe.serial('Correct record - 2', () => {
await page.getByRole('button', { name: 'Ready to print' }).click()

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

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

Expand Down
26 changes: 17 additions & 9 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 Expand Up @@ -870,7 +873,9 @@ test.describe.serial(' Correct record - 3', () => {
await expectOutboxToBeEmpty(page)
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 @@ -912,7 +917,10 @@ test.describe.serial(' Correct record - 3', () => {
await expect(page.getByText('Submitter' + 'Felix Katongo')).toBeVisible()

await expect(
page.getByText('Requested by' + formatName(declaration.child.name[0]))
page.getByText(
'Requested by' +
formatNameWithFirstNameFirst(declaration.child.name[0])
)
).toBeVisible()
await expect(
page.getByText(
Expand Down Expand Up @@ -956,8 +964,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
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
Loading

0 comments on commit a886c0f

Please sign in to comment.