From 3874e9ec5e2cb90dfe456ceb0f01e990d3a193ee Mon Sep 17 00:00:00 2001 From: Siyasanga Date: Thu, 14 Nov 2024 23:40:02 +0200 Subject: [PATCH] refactor: retain original formatName functionility 4 other places 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 https://github.com/opencrvs/opencrvs-core/issues/6830 --- e2e/helpers.ts | 4 ++++ .../correction-birth/correct-birth-record-1.spec.ts | 13 +++++++++---- .../correction-birth/correct-birth-record-2.spec.ts | 5 +++-- .../correction-birth/correct-birth-record-3.spec.ts | 5 ++++- .../correction-birth/correct-birth-record-4.spec.ts | 5 +++-- .../correction-birth/correct-birth-record-5.spec.ts | 5 +++-- .../correction-birth/correct-birth-record-6.spec.ts | 5 ++++- .../correction-birth/correct-birth-record-7.spec.ts | 5 +++-- .../correction-birth/correct-birth-record-8.spec.ts | 5 +++-- .../correction-birth/correct-birth-record-9.spec.ts | 5 ++++- .../correct-death-record-10.spec.ts | 5 +++-- 11 files changed, 43 insertions(+), 19 deletions(-) diff --git a/e2e/helpers.ts b/e2e/helpers.ts index 737d54059..c283ff4c0 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -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() diff --git a/e2e/testcases/correction-birth/correct-birth-record-1.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-1.spec.ts index e3c2be7a7..60a7c7e90 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-1.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-1.spec.ts @@ -6,6 +6,7 @@ import { formatDateTo_ddMMMMyyyy, formatDateTo_yyyyMMdd, formatName, + formatNameWithFirstNameFirst, getAction, getLocationNameFromFhirId, getToken, @@ -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() @@ -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( @@ -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() }) }) diff --git a/e2e/testcases/correction-birth/correct-birth-record-2.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-2.spec.ts index 55c174979..0a4effbd5 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-2.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-2.spec.ts @@ -7,6 +7,7 @@ import { formatDateTo_ddMMMMyyyy, formatDateTo_yyyyMMdd, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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() diff --git a/e2e/testcases/correction-birth/correct-birth-record-3.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-3.spec.ts index e3782a59e..e0f9226bc 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-3.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-3.spec.ts @@ -6,6 +6,7 @@ import { expectOutboxToBeEmpty, formatDateTo_ddMMMMyyyy, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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() }) diff --git a/e2e/testcases/correction-birth/correct-birth-record-4.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-4.spec.ts index 462ced7ed..7483520a0 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-4.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-4.spec.ts @@ -7,6 +7,7 @@ import { formatDateTo_ddMMMMyyyy, formatDateTo_yyyyMMdd, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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() diff --git a/e2e/testcases/correction-birth/correct-birth-record-5.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-5.spec.ts index 862ddc1da..e8c40e540 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-5.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-5.spec.ts @@ -6,6 +6,7 @@ import { expectOutboxToBeEmpty, formatDateTo_ddMMMMyyyy, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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() diff --git a/e2e/testcases/correction-birth/correct-birth-record-6.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-6.spec.ts index 892bc3ce3..83d3b91c0 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-6.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-6.spec.ts @@ -6,6 +6,7 @@ import { expectOutboxToBeEmpty, formatDateTo_ddMMMMyyyy, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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 diff --git a/e2e/testcases/correction-birth/correct-birth-record-7.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-7.spec.ts index 41502a21a..10d022181 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-7.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-7.spec.ts @@ -5,6 +5,7 @@ import { expectAddress, expectOutboxToBeEmpty, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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() diff --git a/e2e/testcases/correction-birth/correct-birth-record-8.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-8.spec.ts index 40cc78e8e..a8623c916 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-8.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-8.spec.ts @@ -6,6 +6,7 @@ import { expectOutboxToBeEmpty, formatDateTo_ddMMMMyyyy, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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() diff --git a/e2e/testcases/correction-birth/correct-birth-record-9.spec.ts b/e2e/testcases/correction-birth/correct-birth-record-9.spec.ts index 7b7748570..9d99f9620 100644 --- a/e2e/testcases/correction-birth/correct-birth-record-9.spec.ts +++ b/e2e/testcases/correction-birth/correct-birth-record-9.spec.ts @@ -6,6 +6,7 @@ import { expectOutboxToBeEmpty, formatDateTo_ddMMMMyyyy, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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 diff --git a/e2e/testcases/correction-death/correct-death-record-10.spec.ts b/e2e/testcases/correction-death/correct-death-record-10.spec.ts index 8f2053535..0dda34f1e 100644 --- a/e2e/testcases/correction-death/correct-death-record-10.spec.ts +++ b/e2e/testcases/correction-death/correct-death-record-10.spec.ts @@ -6,6 +6,7 @@ import { expectOutboxToBeEmpty, formatDateTo_ddMMMMyyyy, formatName, + formatNameWithFirstNameFirst, getAction, getToken, goBackToReview, @@ -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()