diff --git a/e2e/helpers.ts b/e2e/helpers.ts index 0c266d2ed..77072a113 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -54,6 +54,11 @@ export const goToSection = async ( } } +/* + Generates a random past date + at least 'minAge' years ago + and up to an additional 'range' days earlier +*/ export const getRandomDate = (minAge: number, range: number) => { const randomDate = new Date() randomDate.setDate( diff --git a/e2e/testcases/death/.gitkeep b/e2e/testcases/death/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/e2e/testcases/death/1-death-event-declaration.spec.ts b/e2e/testcases/death/1-death-event-declaration.spec.ts new file mode 100644 index 000000000..98c4bf2ac --- /dev/null +++ b/e2e/testcases/death/1-death-event-declaration.spec.ts @@ -0,0 +1,516 @@ +import { expect, test, type Page } from '@playwright/test' +import { createPIN, getToken, login } from '../../helpers' +import { createDeathDeclaration } from './helpers' + +test.describe('1. Death event declaration', () => { + test.describe.serial('Fill all form sections. Save & Exit', () => { + let page: Page + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test('1.1. Navigate to the death event declaration page', async () => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.click('#header_new_event') + await expect(page.getByText('New Declaration')).toBeVisible() + await expect(page.getByText('Event type')).toBeVisible() + }) + + test.describe('1.2. Validate event selection page', async () => { + test('1.2.1 Validate the contents of the event type page', async () => { + /* + * Expected result: should show + * - Radio buttons of the events + * - Continue button + * - Exit button + */ + await expect(page.getByLabel('Birth')).toBeVisible() + await expect(page.getByLabel('Death')).toBeVisible() + await expect(page.getByLabel('Marriage')).toBeVisible() + await expect( + page.getByRole('button', { name: 'Continue' }) + ).toBeVisible() + await expect(page.getByRole('button', { name: 'Exit' })).toBeVisible() + }) + + test('1.2.2 Click the "Continue" button without selecting any event', async () => { + await page.getByRole('button', { name: 'Continue' }).click() + /* + * Expected result: should throw an error as below: + * "Please select the type of event" + */ + await expect( + page.getByText('Please select the type of event') + ).toBeVisible() + }) + + test('1.2.3 Select the "Death" event and click "Continue" button', async () => { + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + + /* + * Expected result: User should navigate to the "Introduction" page + */ + }) + }) + + test.describe('1.3 Validate "Introduction" page', async () => { + test('1.3.1 Validate the contents of introduction page', async () => { + /* + * Expected result: should show + * - verbiage of death event introduction + * - Continue Button + * - Exit Button + * - Save and exit button + * - 3dot menu (delete option) + */ + // await expect(page.getByLabel('Continue')).toBeVisible() + await expect( + page.getByText( + 'Introduce the death registration process to the informant' + ) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Continue' }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Exit', exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Save & Exit' }) + ).toBeVisible() + + await page.locator('#eventToggleMenuToggleButton').click() + await expect( + page.getByRole('button', { name: 'Delete declaration' }) + ).toBeVisible() + }) + + test('1.3.2 Verify the verbiage of introduction page of death event', async () => { + /* + * Expected result: should show + * - I am going to help you make a declaration of death. + * - As the legal Informant it is important that all the information provided by you is accurate. + * - Once the declaration is processed you will receive you will receive an email to tell you + * when to visit the office to collect the certificate - Take your ID with you. + * - Make sure you collect the certificate. A death certificate is critical to support with + * inheritance claims and to resolve the affairs of the deceased e.g. closing bank accounts and setting loans. + */ + await expect( + page.getByText('I am going to help you make a declaration of death.') + ).toBeVisible() + await expect( + page.getByText( + 'As the legal Informant it is important that all the information provided by you is accurate.' + ) + ).toBeVisible() + await expect( + page.getByText( + 'Once the declaration is processed you will receive you will receive an email to tell you when to visit the office to collect the certificate - Take your ID with you.' + ) + ).toBeVisible() + await expect( + page.getByText( + 'Make sure you collect the certificate. A death certificate is critical to support with inheritance claims and to resolve the affairs of the deceased e.g. closing bank accounts and setting loans.' + ) + ).toBeVisible() + }) + + test('1.3.3 Click the "continue" button', async () => { + await page.getByRole('button', { name: 'Continue' }).click() + /* + * Expected result: should navigate to the "Deceased details" page + */ + await expect(page.getByText("Deceased's details")).toBeVisible() + }) + }) + + test.describe('1.4 Validate "Deceased Details" page', async () => { + test('1.4.1 Validate the contents of Deceased details page', async () => { + /* + * Expected result: should see + * - Deceased details block + * - Continue Button + * - Exit Button + * - Save and exit button + * - 3dot menu (delete option) + */ + await expect( + page.getByRole('button', { name: 'Continue' }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Exit', exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Save & Exit' }) + ).toBeVisible() + + await page.locator('#eventToggleMenuToggleButton').click() + await expect( + page.getByRole('button', { name: 'Delete declaration' }) + ).toBeVisible() + }) + + test.skip('1.4.2 Validate Deceased details block', async () => {}) + + test('1.4.3 Click "continue"', async () => { + await page.getByRole('button', { name: 'Continue' }).click() + + /* + * Expected result: should navigate to 'event details' page + */ + await expect(page.getByText('Event details')).toBeVisible() + }) + }) + + test.describe('1.5 Validate "Event Details" page', async () => { + test('1.5.1 Validate the contents of Event details page', async () => { + /* + * Expected result: should see + * - Event details block + * - Continue Button + * - Exit Button + * - Save and exit button + * - 3dot menu (delete option) + */ + await expect( + page.getByRole('button', { name: 'Continue' }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Exit', exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Save & Exit' }) + ).toBeVisible() + + await page.locator('#eventToggleMenuToggleButton').click() + await expect( + page.getByRole('button', { name: 'Delete declaration' }) + ).toBeVisible() + }) + + test.skip('1.5.2 Validate Event details block', async () => {}) + + test('1.5.3 Click "continue"', async () => { + await page.getByRole('button', { name: 'Continue' }).click() + + /* + * Expected result: should navigate to 'informant details' page + */ + await expect(page.getByText("Informant's details")).toBeVisible() + }) + }) + + test.describe('1.6 Validate "Informant details" page', async () => { + test('1.6.1 Validate the contents of informant details page', async () => { + /* + * Expected result: should see + * - Relationship to deceased dropdown + * - Phone number field + * - Email address field + * - Continue button + * - Exit button + * - Save &exit button + * - 3dot menu (delete option) + */ + await expect(page.getByText('Informant Type')).toBeVisible() + await expect(page.getByText('Phone number')).toBeVisible() + await expect(page.getByText('Email')).toBeVisible() + await expect( + page.getByRole('button', { name: 'Continue' }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Exit', exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Save & Exit' }) + ).toBeVisible() + await page.locator('#eventToggleMenuToggleButton').click() + await expect( + page.getByRole('button', { name: 'Delete declaration' }) + ).toBeVisible() + }) + + test.skip('1.6.2 Click the "continue" button without selecting any relationship to deceased', async () => {}) + + test('1.6.3 Select eny option in relatinship to deceased and click the "continue" button', async () => { + await page.getByText('Select').click() + await page.getByText('Son', { exact: true }).click() + await page.getByRole('button', { name: 'Continue' }).click() + + /* + * Expected result: should navigate to "sposue details" page + */ + await expect( + page.getByText('Spouse details', { exact: true }) + ).toBeVisible() + }) + }) + + test.describe('1.7 Validate "Spouse Details" page', async () => { + test('1.7.1 validate the contents of spouse details page', async () => { + /* + * Expected result: should see + * - Spouse details block + * - Continue button + * - Exit button + * - Save & exit button + * - 3dot menu (delete option) + */ + + await expect( + page.getByText('Spouse details', { exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Continue' }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Exit', exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Save & Exit' }) + ).toBeVisible() + await page.locator('#eventToggleMenuToggleButton').click() + await expect( + page.getByRole('button', { name: 'Delete declaration' }) + ).toBeVisible() + }) + + test.skip('1.7.2 Validate Spouse details block', async () => {}) + + test('1.7.3 click continue', async () => { + await page.getByRole('button', { name: 'Continue' }).click() + + /* + * Expected result: should navigate to "Supporting documents" page + */ + await expect( + page.getByText('Upload supporting documents', { exact: true }) + ).toBeVisible() + }) + }) + + test.describe('1.8 Validate "Supporting Document" page', async () => { + test('1.8.1 validate the contents of Supporting Document page', async () => { + /* + * Expected result: should see + * - Supporting Document block + * - Continue button + * - Exit button + * - Save & exit button + * - 3dot menu (delete option) + */ + + await expect( + page.getByText('Upload supporting documents', { exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Continue' }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Exit', exact: true }) + ).toBeVisible() + await expect( + page.getByRole('button', { name: 'Save & Exit' }) + ).toBeVisible() + await page.locator('#eventToggleMenuToggleButton').click() + await expect( + page.getByRole('button', { name: 'Delete declaration' }) + ).toBeVisible() + }) + + test.skip('1.8.2 Validate Supporting Document block', async () => {}) + + test('1.8.3 click continue', async () => { + await page.getByRole('button', { name: 'Continue' }).click() + + /* + * Expected result: should navigate to "Review" page + */ + await expect( + page + .getByRole('button', { name: 'Send for review' }) + .or(page.getByRole('button', { name: 'Register' })) + ).toBeVisible() + }) + }) + + test.describe('1.9 Validate "Save & Exit" Button ', async () => { + test('1.9.1 Click the "Save & Exit" button from any page', async () => { + await page.getByRole('button', { name: 'Save & Exit' }).click() + + /* + * Expected result: should open modal with: + * - Title: Save & Exit + * - Helper text: All inputted data will be kept secure for future editing. + * Are you ready to save any changes to this declaration form? + * - Cancel Button + * - Confirm Button + */ + await expect( + page.getByRole('heading', { name: 'Save & exit?' }) + ).toBeVisible() + await expect( + page.getByText( + 'All inputted data will be kept secure for future editing. Are you ready to save any changes to this declaration form?' + ) + ).toBeVisible() + await expect(page.getByRole('button', { name: 'Cancel' })).toBeVisible() + await expect( + page.getByRole('button', { name: 'Confirm' }) + ).toBeVisible() + }) + + test('1.9.2 Click Cancel', async () => { + await page.getByRole('button', { name: 'Cancel' }).click() + + /* + * Expected result: should close the modal + */ + await expect( + page.getByRole('heading', { name: 'Save & exit?' }) + ).toBeHidden() + }) + + test('1.9.3 Click Confirm', async () => { + await page.getByRole('button', { name: 'Save & Exit' }).click() + await page.getByRole('button', { name: 'Confirm' }).click() + + /* + * Expected result: should + * - be navigated to "in-progress" tab + * - find the declared death event record on this page list with saved data + */ + await expect(page.locator('#content-name')).toHaveText('In progress') + await expect(page.getByText('0 seconds ago')).toBeVisible() + }) + }) + }) + test.describe('1.10 Validate "Exit" Button', async () => { + test.beforeEach(async ({ page }) => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + + await page.getByRole('button', { name: 'Exit', exact: true }).click() + }) + + test('1.10.1 Click the "Exit" button from any page', async ({ page }) => { + /* + * Expected result: should open modal with: + * - Title: Exit without saving changes? + * - Helper text: You have unsaved changes on your declaration form. Are you sure you want to exit without saving? + * - Cancel Button + * - Confirm Button + */ + await expect( + page.getByRole('heading', { name: 'Exit without saving changes?' }) + ).toBeVisible() + await expect( + page.getByText( + 'You have unsaved changes on your declaration form. Are you sure you want to exit without saving?' + ) + ).toBeVisible() + await expect(page.getByRole('button', { name: 'Cancel' })).toBeVisible() + await expect(page.getByRole('button', { name: 'Confirm' })).toBeVisible() + }) + + test('1.10.2 Click Cancel', async ({ page }) => { + await page.getByRole('button', { name: 'Cancel' }).click() + + /* + * Expected result: should close the modal + */ + await expect( + page.getByRole('heading', { name: 'Exit without saving changes?' }) + ).toBeHidden() + }) + + test('1.10.3 Click Confirm', async ({ page }) => { + await page.getByRole('button', { name: 'Confirm' }).click() + /* + * Expected result: should be navigated to "in-progress" tab but no draft will be saved + */ + expect(page.locator('#content-name', { hasText: 'In progress' })) + await expect(page.getByText('0 seconds ago')).toBeHidden() + }) + }) + + test.describe('1.11 Validate "Delete Declaration" Button ', async () => { + test.beforeEach(async ({ page }) => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + + await page.locator('#eventToggleMenuToggleButton').click() + await page + .getByRole('button', { name: 'Delete declaration', exact: true }) + .click() + }) + + test('1.11.1 Click the "Delete Declaration" button from any page', async ({ + page + }) => { + /* + * Expected result: should open modal with: + * - Title: Delete draft? + * - Helper text: Are you certain you want to delete this draft declaration form? Please note, this action cant be undone. + * - Cancel Button + * - Confirm Button + */ + await expect( + page.getByRole('heading', { name: 'Delete draft?' }) + ).toBeVisible() + await expect( + page.getByText( + 'Are you certain you want to delete this draft declaration form? Please note, this action cant be undone.' + ) + ).toBeVisible() + await expect(page.getByRole('button', { name: 'Cancel' })).toBeVisible() + await expect(page.getByRole('button', { name: 'Confirm' })).toBeVisible() + }) + + test('1.11.2 Click Cancel', async ({ page }) => { + await page.getByRole('button', { name: 'Cancel' }).click() + + /* + * Expected result: should close the modal + */ + await expect( + page.getByRole('heading', { name: 'Exit without saving changes?' }) + ).toBeHidden() + }) + + test('1.11.3 Click Confirm', async ({ page }) => { + await page.getByRole('button', { name: 'Confirm' }).click() + + /* + * Expected result: should be navigated to "in-progress" tab but no draft will be saved + */ + expect(page.locator('#content-name', { hasText: 'In progress' })) + await expect(page.getByText('0 seconds ago')).toBeHidden() + }) + }) + + test.describe('1.12 Technical test for shortcuts', () => { + test('Shortcut for quickly creating declarations', async ({ page }) => { + const token = await getToken('k.mweene', 'test') + const res = await createDeathDeclaration(token) + expect(res).toStrictEqual({ + trackingId: expect.any(String), + compositionId: expect.any(String), + isPotentiallyDuplicate: false, + __typename: 'CreatedIds' + }) + }) + }) +}) diff --git a/e2e/testcases/death/8-validate-declaration-review-page.spec.ts b/e2e/testcases/death/8-validate-declaration-review-page.spec.ts new file mode 100644 index 000000000..472eac5ab --- /dev/null +++ b/e2e/testcases/death/8-validate-declaration-review-page.spec.ts @@ -0,0 +1,1514 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('8. Validate declaration review page', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + gender: 'Male', + birthDate: getRandomDate(75, 200), + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'National ID' + }, + address: { + Country: 'Farajaland', + Province: 'Pualula', + District: 'Pili' + } + }, + event: { + date: getRandomDate(0, 20), + cause: { + established: false, + details: '' + }, + place: "Deceased's usual place of residence" + }, + informantType: 'Spouse', + informantEmail: faker.internet.email(), + spouse: { + name: { + firstNames: faker.name.firstName('female'), + familyName: faker.name.lastName('female') + }, + birthDate: getRandomDate(50, 200), + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'National ID' + }, + address: { + sameAsDeceased: true + } + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + await login(page, 'k.bwalya', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('8.1 Field agent actions', async () => { + test.describe('8.1.0 Fill up death registration form', async () => { + test('8.1.0.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page + .getByText(declaration.deceased.gender, { exact: true }) + .click() + + await page + .getByPlaceholder('dd') + .fill(declaration.deceased.birthDate.dd) + await page + .getByPlaceholder('mm') + .fill(declaration.deceased.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.deceased.birthDate.yyyy) + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + + await page + .locator('#deceasedNationalId') + .fill(declaration.deceased.identifier.id) + + await page.locator('#statePrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.Province, { exact: true }) + .click() + await page.locator('#districtPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.District, { exact: true }) + .click() + + // waiting for 500ms before continuing, + // otherwise some data entered in the page are lost + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('8.1.0.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place).click() + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('8.1.0.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page + .locator('#registrationEmail') + .fill(declaration.informantEmail) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('8.1.0.4 Fill spouse details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.spouse.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.spouse.name.familyName) + + await page.getByPlaceholder('dd').fill(declaration.spouse.birthDate.dd) + await page.getByPlaceholder('mm').fill(declaration.spouse.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.spouse.birthDate.yyyy) + + await page.locator('#spouseIdType').click() + await page + .getByText(declaration.spouse.identifier.type, { exact: true }) + .click() + + await page + .locator('#spouseNationalId') + .fill(declaration.spouse.identifier.id) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + }) + + test.describe('8.1.1 Navigate to declaration preview page', async () => { + test('8.1.1.1 Verify informations added in previous pages', async () => { + goToSection(page, 'preview') + + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's date of death + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.District + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + declaration.event.cause.established ? 'Yes' : 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect( + page.locator('#informant-content #Informant') + ).toContainText(declaration.informantType) + await expect( + page.locator('#informant-content #Informant') + ).toContainText('Change') + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's date of death + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect( + page.locator('#spouse-content #Nationality') + ).toContainText(declaration.spouse.nationality) + await expect( + page.locator('#spouse-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText( + 'Yes' + ) + }) + }) + + test.describe('8.1.2 Click any "Change" link', async () => { + test("8.1.2.1 Change deceased's name", async () => { + await page + .locator('#deceased-content #Full') + .getByText('Change') + .click() + declaration.deceased.name = { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + } + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's name + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + }) + + test("8.1.2.2 Change deceased's gender", async () => { + await page.locator('#deceased-content #Sex').getByText('Change').click() + declaration.deceased.gender = 'Female' + await page.locator('#gender').click() + await page + .getByText(declaration.deceased.gender, { exact: true }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's gender + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + }) + + test("8.1.2.3 Change deceased's birthday", async () => { + await page + .locator('#deceased-content #Date') + .getByText('Change') + .click() + declaration.deceased.birthDate = getRandomDate(5, 200) + await page + .getByPlaceholder('dd') + .fill(declaration.deceased.birthDate.dd) + await page + .getByPlaceholder('mm') + .fill(declaration.deceased.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.deceased.birthDate.yyyy) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's birthday + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + }) + + test("8.1.2.4 Change deceased's ID type", async () => { + await page + .locator('#deceased-content #Type') + .getByText('Change') + .click() + declaration.deceased.identifier.type = 'Passport' + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's ID type + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + }) + test("8.1.2.5 Change deceased's ID", async () => { + await page.locator('#deceased-content #ID').getByText('Change').click() + declaration.deceased.identifier.id = faker.random.numeric(10) + await page + .locator('#deceasedPassport') + .fill(declaration.deceased.identifier.id) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's ID + */ + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + }) + + test("8.1.2.6 Change deceased's address", async () => { + await page + .locator('#deceased-content #Usual') + .getByText('Change') + .click() + declaration.deceased.address.Province = 'Sulaka' + declaration.deceased.address.District = 'Afue' + await page.locator('#statePrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.Province, { exact: true }) + .click() + await page.locator('#districtPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.District, { exact: true }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's address + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.District + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Province + ) + }) + + test.skip('8.1.2.7 Change informant type', async () => { + await page + .locator('#informant-content #Informant') + .getByText('Change') + .click() + declaration.informantType = 'Father' + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change informant type + */ + await expect( + page.locator('#informant-content #Informant') + ).toContainText(declaration.informantType) + }) + + test('8.1.2.8 Change registration email', async () => { + await page + .locator('#informant-content #Email') + .getByText('Change') + .click() + declaration.informantEmail = faker.internet.email() + await page + .locator('#registrationEmail') + .fill(declaration.informantEmail) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change registration email + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + }) + + test("8.1.2.9 Change spouse's name", async () => { + await page.locator('#spouse-content #Full').getByText('Change').click() + declaration.spouse.name.firstNames = faker.name.firstName('female') + declaration.spouse.name.familyName = faker.name.lastName('female') + await page + .locator('#firstNamesEng') + .fill(declaration.spouse.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.spouse.name.familyName) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's name + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + }) + test("8.1.2.10 Change spouse's birthday", async () => { + await page.locator('#spouse-content #Date').getByText('Change').click() + declaration.spouse.birthDate = getRandomDate(19, 200) + await page.getByPlaceholder('dd').fill(declaration.spouse.birthDate.dd) + await page.getByPlaceholder('mm').fill(declaration.spouse.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.spouse.birthDate.yyyy) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's birthday + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + }) + test("8.1.2.11 Change spouse's nationality", async () => { + await page + .locator('#spouse-content #Nationality') + .getByText('Change') + .click() + declaration.spouse.nationality = 'Holy See' + await page.locator('#nationality').click() + await page + .getByText(declaration.spouse.nationality, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's nationality + */ + await expect( + page.locator('#spouse-content #Nationality') + ).toContainText(declaration.spouse.nationality) + }) + test("8.1.2.12 Change spouse's ID type", async () => { + await page.locator('#spouse-content #Type').getByText('Change').click() + declaration.spouse.identifier.type = 'Passport' + await page.locator('#spouseIdType').click() + await page + .getByText(declaration.spouse.identifier.type, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's ID type + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + }) + test("8.1.2.13 Change spouse's ID", async () => { + await page.locator('#spouse-content #ID').getByText('Change').click() + declaration.spouse.identifier.id = faker.random.numeric(10) + await page + .locator('#spousePassport') + .fill(declaration.spouse.identifier.id) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's ID + */ + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + }) + }) + + test.describe('8.1.3 Validate supporting document', async () => { + test.skip('Skipped for now', async () => {}) + }) + test.describe('8.1.4 Validate additional comments box', async () => { + test.skip('Skipped for now', async () => {}) + }) + test.describe('8.1.5 Validate the declaration send button', async () => { + test.skip('Skipped for now', async () => {}) + }) + + test('8.1.6 Click send button', async () => { + await page.getByRole('button', { name: 'Send for review' }).click() + await expect(page.getByText('Send for review?')).toBeVisible() + }) + + test('8.1.7 Confirm the declaration to send for review', async () => { + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await page.getByRole('button', { name: 'Sent for review' }).click() + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + /* + * Expected result: The declaration should be in sent for review + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('8.2 Registration agent actions', async () => { + test('8.2.1 Navigate to the declaration preview page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready for review' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Review', exact: true }).click() + }) + test('8.2.1.1 Verify informations added in previous pages', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's date of death + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.District + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's date of death + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + + test.describe('8.2.2 Click any "Change" link', async () => { + test("8.2.2.1 Change deceased's name", async () => { + await page + .locator('#deceased-content #Full') + .getByText('Change') + .click() + await page.getByRole('button', { name: 'Continue' }).click() + + declaration.deceased.name = { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + } + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's name + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + }) + + test("8.2.2.2 Change deceased's gender", async () => { + await page.locator('#deceased-content #Sex').getByText('Change').click() + await page.getByRole('button', { name: 'Continue' }).click() + declaration.deceased.gender = 'Male' + await page.locator('#gender').click() + await page + .getByText(declaration.deceased.gender, { exact: true }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's gender + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + }) + + test("8.2.2.3 Change deceased's birthday", async () => { + await page + .locator('#deceased-content #Date') + .getByText('Change') + .click() + await page.getByRole('button', { name: 'Continue' }).click() + + declaration.deceased.birthDate = getRandomDate(5, 200) + await page + .getByPlaceholder('dd') + .fill(declaration.deceased.birthDate.dd) + await page + .getByPlaceholder('mm') + .fill(declaration.deceased.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.deceased.birthDate.yyyy) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's birthday + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + }) + + test("8.2.2.4 Change deceased's ID type", async () => { + await page + .locator('#deceased-content #Type') + .getByText('Change') + .click() + await page.getByRole('button', { name: 'Continue' }).click() + + declaration.deceased.identifier.type = 'Birth Registration Number' + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's ID type + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + }) + test("8.2.2.5 Change deceased's ID", async () => { + await page.locator('#deceased-content #ID').getByText('Change').click() + await page.getByRole('button', { name: 'Continue' }).click() + declaration.deceased.identifier.id = faker.random.numeric(10) + await page + .locator('#deceasedBirthRegistrationNumber') + .fill(declaration.deceased.identifier.id) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's ID + */ + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + }) + + test("8.2.2.6 Change deceased's address", async () => { + await page + .locator('#deceased-content #Usual') + .getByText('Change') + .click() + await page.getByRole('button', { name: 'Continue' }).click() + + declaration.deceased.address.Province = 'Central' + declaration.deceased.address.District = 'Itambo' + await page.locator('#statePrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.Province, { exact: true }) + .click() + await page.locator('#districtPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.District, { exact: true }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change deceased's address + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.District + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Province + ) + }) + + test.skip('8.2.2.7 Change informant type', async () => { + await page + .locator('#informant-content #Informant') + .getByText('Change') + .click() + await page.getByRole('button', { name: 'Continue' }).click() + + declaration.informantType = 'Father' + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change informant type + */ + await expect( + page.locator('#informant-content #Informant') + ).toContainText(declaration.informantType) + }) + + test('8.2.2.8 Change registration email', async () => { + await page + .locator('#informant-content #Email') + .getByText('Change') + .click() + await page.getByRole('button', { name: 'Continue' }).click() + + declaration.informantEmail = faker.internet.email() + await page + .locator('#registrationEmail') + .fill(declaration.informantEmail) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change registration email + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + }) + + test("8.2.2.9 Change spouse's name", async () => { + await page.locator('#spouse-content #Full').getByText('Change').click() + await page.getByRole('button', { name: 'Continue' }).click() + declaration.spouse.name.firstNames = faker.name.firstName('female') + declaration.spouse.name.familyName = faker.name.lastName('female') + await page + .locator('#firstNamesEng') + .fill(declaration.spouse.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.spouse.name.familyName) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's name + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + }) + test("8.2.2.10 Change spouse's birthday", async () => { + await page.locator('#spouse-content #Date').getByText('Change').click() + await page.getByRole('button', { name: 'Continue' }).click() + declaration.spouse.birthDate = getRandomDate(19, 200) + await page.getByPlaceholder('dd').fill(declaration.spouse.birthDate.dd) + await page.getByPlaceholder('mm').fill(declaration.spouse.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.spouse.birthDate.yyyy) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's birthday + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + }) + test("8.2.2.11 Change spouse's nationality", async () => { + await page + .locator('#spouse-content #Nationality') + .getByText('Change') + .click() + await page.getByRole('button', { name: 'Continue' }).click() + + declaration.spouse.nationality = 'Japan' + await page.locator('#nationality').click() + await page + .getByText(declaration.spouse.nationality, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's nationality + */ + await expect( + page.locator('#spouse-content #Nationality') + ).toContainText(declaration.spouse.nationality) + }) + test("8.2.2.12 Change spouse's ID type", async () => { + await page.locator('#spouse-content #Type').getByText('Change').click() + await page.getByRole('button', { name: 'Continue' }).click() + declaration.spouse.identifier.type = 'Birth Registration Number' + await page.locator('#spouseIdType').click() + await page + .getByText(declaration.spouse.identifier.type, { + exact: true + }) + .click() + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's ID type + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + }) + test("8.2.2.13 Change spouse's ID", async () => { + await page.locator('#spouse-content #ID').getByText('Change').click() + await page.getByRole('button', { name: 'Continue' }).click() + declaration.spouse.identifier.id = faker.random.numeric(10) + await page + .locator('#spouseBirthRegistrationNumber') + .fill(declaration.spouse.identifier.id) + await page.getByRole('button', { name: 'Back to review' }).click() + /* + * Expected result: should change spouse's ID + */ + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + }) + }) + test.describe('8.2.3 Validate supporting document', async () => { + test.skip('Skipped for now', async () => {}) + }) + test.describe('8.2.4 Validate additional comments box', async () => { + test.skip('Skipped for now', async () => {}) + }) + test.describe('8.2.5 Validate the declaration send button', async () => { + test.skip('Skipped for now', async () => {}) + }) + + test('8.2.6 Click send button', async () => { + await page.getByRole('button', { name: 'Send for approval' }).click() + await expect(page.getByText('Send for approval?')).toBeVisible() + }) + + test('8.2.7 Confirm the declaration to send for approval', async () => { + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await page.getByRole('button', { name: 'Sent for approval' }).click() + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + /* + * Expected result: The declaration should be in sent for approval + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('8.3 Local registrar actions', async () => { + test('8.3.1 Navigate to the declaration preview page', async () => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready for review' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Review', exact: true }).click() + }) + test('8.3.1.1 Verify informations added in previous pages', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's date of death + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.District + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.Province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's date of death + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + + test.describe('8.3.2 Click any "Change" link', async () => { + test.skip('Skipped for now', async () => {}) + }) + test.describe('8.3.3 Validate supporting document', async () => { + test.skip('Skipped for now', async () => {}) + }) + test.describe('8.3.4 Validate additional comments box', async () => { + test.skip('Skipped for now', async () => {}) + }) + test.describe('8.3.5 Validate the register button', async () => { + test.skip('Skipped for now', async () => {}) + }) + + test('8.3.6 Click send button', async () => { + await page.getByRole('button', { name: 'Register' }).click() + await expect(page.getByText('Register the death?')).toBeVisible() + }) + + test('8.3.7 Confirm the declaration to ready for print', async () => { + await page.locator('#submit_confirm').click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await page.getByRole('button', { name: 'Ready to print' }).click() + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + /* + * Expected result: The declaration should be in Ready to print + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) +}) diff --git a/e2e/testcases/death/data/assets/528KB-random.png b/e2e/testcases/death/data/assets/528KB-random.png new file mode 100644 index 000000000..02bd69017 Binary files /dev/null and b/e2e/testcases/death/data/assets/528KB-random.png differ diff --git a/e2e/testcases/death/declaration/death-declaration-1.spec.ts b/e2e/testcases/death/declaration/death-declaration-1.spec.ts new file mode 100644 index 000000000..2144f47ed --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-1.spec.ts @@ -0,0 +1,846 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('1. Death declaration case - 1', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + gender: 'Male', + birthDate: getRandomDate(75, 200), + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'National ID' + }, + maritalStatus: 'Single', + dependants: 3, + address: { + country: 'Farajaland', + province: 'Sulaka', + district: 'Zobwe', + urbanOrRural: 'Urban', + town: faker.address.city(), + residentialArea: faker.address.county(), + street: faker.address.streetName(), + number: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + event: { + manner: 'Natural causes', + date: getRandomDate(0, 20), + cause: { + established: true, + source: 'Physician' + }, + place: "Deceased's usual place of residence" + }, + informantType: 'Spouse', + informantEmail: faker.internet.email(), + spouse: { + name: { + firstNames: faker.name.firstName('female'), + familyName: faker.name.lastName('female') + }, + birthDate: getRandomDate(50, 200), + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'National ID' + }, + address: { + sameAsDeceased: true + } + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('1.1 Declaratin started by FA', async () => { + test.beforeAll(async () => { + await login(page, 'k.bwalya', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('1.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page.getByText(declaration.deceased.gender, { exact: true }).click() + + await page.getByPlaceholder('dd').fill(declaration.deceased.birthDate.dd) + await page.getByPlaceholder('mm').fill(declaration.deceased.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.deceased.birthDate.yyyy) + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + await page + .locator('#deceasedNationalId') + .fill(declaration.deceased.identifier.id) + + await page.locator('#maritalStatus').click() + await page + .getByText(declaration.deceased.maritalStatus, { exact: true }) + .click() + + await page + .locator('#numberOfDependants') + .fill(declaration.deceased.dependants.toString()) + + await page.locator('#statePrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.province, { exact: true }) + .click() + await page.locator('#districtPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.district, { exact: true }) + .click() + + await page + .locator('#cityPrimaryDeceased') + .fill(declaration.deceased.address.town) + await page + .locator('#addressLine1UrbanOptionPrimaryDeceased') + .fill(declaration.deceased.address.residentialArea) + await page + .locator('#addressLine2UrbanOptionPrimaryDeceased') + .fill(declaration.deceased.address.street) + await page + .locator('#addressLine3UrbanOptionPrimaryDeceased') + .fill(declaration.deceased.address.number) + await page + .locator('#postalCodePrimaryDeceased') + .fill(declaration.deceased.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('1.1.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#mannerOfDeath').click() + await page.getByText(declaration.event.manner, { exact: true }).click() + + page.getByLabel('Cause of death has been established').check() + + await page.locator('#causeOfDeathMethod').click() + await page + .getByText(declaration.event.cause.source, { exact: true }) + .click() + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place, { exact: true }).click() + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('1.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page.locator('#registrationEmail').fill(declaration.informantEmail) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('1.1.4 Fill spouse details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.spouse.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.spouse.name.familyName) + + await page.getByPlaceholder('dd').fill(declaration.spouse.birthDate.dd) + await page.getByPlaceholder('mm').fill(declaration.spouse.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.spouse.birthDate.yyyy) + + await page.locator('#spouseIdType').click() + await page + .getByText(declaration.spouse.identifier.type, { exact: true }) + .click() + + await page + .locator('#spouseNationalId') + .fill(declaration.spouse.identifier.id) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('1.1.5 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('1.1.6 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's date of death + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Number of Deceased's Dependants + */ + await expect(page.locator('#deceased-content')).toContainText( + 'No. of dependants' + declaration.deceased.dependants.toString() + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.residentialArea + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.street + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.number + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's date of death + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + + test('1.1.7 Send for review', async () => { + await page.getByRole('button', { name: 'Send for review' }).click() + await expect(page.getByText('Send for review?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Sent for review' }).click() + + /* + * Expected result: The declaration should be in sent for review + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('1.2 Declaration Review by RA', async () => { + test('1.2.1 Navigate to the declaration review page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready for review' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Review', exact: true }).click() + }) + + test('1.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's date of death + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Number of Deceased's Dependants + * - Change button + */ + await expect(page.locator('#deceased-content')).toContainText( + 'No. of dependants' + declaration.deceased.dependants.toString() + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.residentialArea + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.street + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.number + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's date of death + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-10.spec.ts b/e2e/testcases/death/declaration/death-declaration-10.spec.ts new file mode 100644 index 000000000..e072fa8e0 --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-10.spec.ts @@ -0,0 +1,499 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, goToSection, login } from '../../../helpers' + +test.describe.serial('10. Death declaration case - 10', () => { + let page: Page + const REQUIRED = 'Required for registration' + const declaration = { + deceased: { + address: { + country: 'Farajaland', + province: 'Central', + district: 'Ibombo' + }, + nationality: 'Farajaland' + }, + informantType: 'Grandson' + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('10.1 Declaratin started by FA', async () => { + test.beforeAll(async () => { + await login(page, 'k.bwalya', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('10.1.1 Fill deceased details', async () => { + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('10.1.2 Fill event details', async () => { + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('10.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('10.1.4 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('10.1.5 Verify informations in preview page', async () => { + /* + * Expected result: should require + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's date of birth + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should require + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Must be a valid date of death' + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + REQUIRED + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + 'Must be a valid email address' + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + + await expect(page.locator('#spouse-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's date of birth + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Farajaland' + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + + test('10.1.6 Send for review', async () => { + await page.getByRole('button', { name: 'Send for review' }).click() + await expect(page.getByText('Send for review?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + }) + }) + + test.describe('10.2 Declaration Review by RA', async () => { + test('10.2.1 Navigate to the declaration review page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'In Progress' }).click() + await page.getByRole('button', { name: 'Field Agents' }).click() + + await expect(page.locator('#name_0')).toBeVisible() + const [firstButton] = await page + .getByRole('button', { + name: 'No name provided' + }) + .all() + await firstButton.click() + + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Update', exact: true }).click() + }) + + test('10.2.2 Verify informations in review page', async () => { + /* + * Expected result: should require + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's date of birth + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should require + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Must be a valid date of death' + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + REQUIRED + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + 'Must be a valid email address' + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + + await expect(page.locator('#spouse-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's date of birth + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Farajaland' + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-2.spec.ts b/e2e/testcases/death/declaration/death-declaration-2.spec.ts new file mode 100644 index 000000000..8120b0987 --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-2.spec.ts @@ -0,0 +1,1066 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('2. Death declaration case - 2', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('female'), + familyName: faker.name.lastName('female') + }, + gender: 'Female', + age: 65, + nationality: 'Guernsey', + identifier: { + id: faker.random.numeric(10), + type: 'Passport' + }, + maritalStatus: 'Married', + address: { + country: 'Farajaland', + province: 'Sulaka', + district: 'Zobwe', + urbanOrRural: 'Rural', + village: faker.address.county() + } + }, + event: { + manner: 'Accident', + date: getRandomDate(0, 20), + cause: { + established: true, + source: 'Lay reported', + description: "T'was an accident sire" + }, + place: "Deceased's usual place of residence" + }, + informantType: 'Son', + informantEmail: faker.internet.email(), + informant: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + birthDate: getRandomDate(50, 200), + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'National ID' + }, + address: { + sameAsDeceased: true + } + }, + spouse: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + age: 68, + nationality: 'Canada', + identifier: { + id: faker.random.numeric(10), + type: 'Passport' + }, + address: { + sameAsDeceased: false, + country: 'Farajaland', + province: 'Chuminga', + district: 'Nsali', + urbanOrRural: 'Urban', + town: faker.address.city(), + residentialArea: faker.address.county(), + street: faker.address.streetName(), + number: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('2.1 Declaratin started by FA', async () => { + test.beforeAll(async () => { + await login(page, 'k.bwalya', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('2.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page.getByText(declaration.deceased.gender, { exact: true }).click() + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.deceased.age.toString()) + + await page.locator('#nationality').click() + await page + .getByText(declaration.deceased.nationality, { exact: true }) + .click() + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + + await page + .locator('#deceasedPassport') + .fill(declaration.deceased.identifier.id) + + await page.locator('#maritalStatus').click() + await page + .getByText(declaration.deceased.maritalStatus, { exact: true }) + .click() + + await page.locator('#statePrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.province, { exact: true }) + .click() + await page.locator('#districtPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.district, { exact: true }) + .click() + + await page.getByLabel('Rural').check() + + await page + .locator('#addressLine1RuralOptionPrimaryDeceased') + .fill(declaration.deceased.address.village) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('2.1.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#mannerOfDeath').click() + await page.getByText(declaration.event.manner, { exact: true }).click() + + page.getByLabel('Cause of death has been established').check() + + await page.locator('#causeOfDeathMethod').click() + await page + .getByText(declaration.event.cause.source, { exact: true }) + .click() + await page + .locator('#deathDescription') + .fill(declaration.event.cause.description) + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place, { exact: true }).click() + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('2.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page.locator('#registrationEmail').fill(declaration.informantEmail) + + await page + .locator('#firstNamesEng') + .fill(declaration.informant.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.informant.name.familyName) + + await page.getByPlaceholder('dd').fill(declaration.informant.birthDate.dd) + await page.getByPlaceholder('mm').fill(declaration.informant.birthDate.mm) + await page + .getByPlaceholder('yyyy') + .fill(declaration.informant.birthDate.yyyy) + + await page.locator('#informantIdType').click() + await page + .getByText(declaration.informant.identifier.type, { exact: true }) + .click() + + await page + .locator('#informantNationalId') + .fill(declaration.informant.identifier.id) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('2.1.4 Fill spouse details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.spouse.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.spouse.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.spouse.age.toString()) + + await page.locator('#nationality').click() + await page + .getByText(declaration.spouse.nationality, { exact: true }) + .click() + + await page.locator('#spouseIdType').click() + await page + .getByText(declaration.spouse.identifier.type, { exact: true }) + .click() + + await page + .locator('#spousePassport') + .fill(declaration.spouse.identifier.id) + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#statePrimarySpouse').click() + await page + .getByText(declaration.spouse.address.province, { exact: true }) + .click() + await page.locator('#districtPrimarySpouse').click() + await page + .getByText(declaration.spouse.address.district, { exact: true }) + .click() + + await page + .locator('#cityPrimarySpouse') + .fill(declaration.spouse.address.town) + await page + .locator('#addressLine1UrbanOptionPrimarySpouse') + .fill(declaration.spouse.address.residentialArea) + await page + .locator('#addressLine2UrbanOptionPrimarySpouse') + .fill(declaration.spouse.address.street) + await page + .locator('#addressLine3UrbanOptionPrimarySpouse') + .fill(declaration.spouse.address.number) + await page + .locator('#postalCodePrimarySpouse') + .fill(declaration.spouse.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('2.1.5 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('2.1.6 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.village + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Description cause of death + * - Change button + */ + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText(declaration.event.cause.description) + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText('Change') + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's date of birth + * - Change button + */ + await expect(page.locator('#informant-content #Date')).toContainText( + format( + new Date( + Number(declaration.informant.birthDate.yyyy), + Number(declaration.informant.birthDate.mm) - 1, + Number(declaration.informant.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#informant-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - informant's Id Number + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#informant-content #ID')).toContainText( + declaration.informant.identifier.id + ) + await expect(page.locator('#informant-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Yes' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's age + * - Change button + */ + await expect(page.locator('#spouse-content #Age')).toContainText( + declaration.spouse.age + ' years' + ) + await expect(page.locator('#spouse-content #Age')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.country + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.district + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.province + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.town + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.residentialArea + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.street + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.number + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.postcodeOrZip + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + 'Change' + ) + }) + + test('2.1.7 Send for review', async () => { + await page.getByRole('button', { name: 'Send for review' }).click() + await expect(page.getByText('Send for review?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Sent for review' }).click() + + /* + * Expected result: The declaration should be in sent for review + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('2.2 Declaration Review by RA', async () => { + test('2.2.1 Navigate to the declaration review page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready for review' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Review', exact: true }).click() + }) + + test('2.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.village + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Description cause of death + * - Change button + */ + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText(declaration.event.cause.description) + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText('Change') + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's date of birth + * - Change button + */ + await expect(page.locator('#informant-content #Date')).toContainText( + format( + new Date( + Number(declaration.informant.birthDate.yyyy), + Number(declaration.informant.birthDate.mm) - 1, + Number(declaration.informant.birthDate.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#informant-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - informant's Id Number + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#informant-content #ID')).toContainText( + declaration.informant.identifier.id + ) + await expect(page.locator('#informant-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Yes' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's age + * - Change button + */ + await expect(page.locator('#spouse-content #Age')).toContainText( + declaration.spouse.age + ' years' + ) + await expect(page.locator('#spouse-content #Age')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.country + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.district + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.province + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.town + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.residentialArea + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.street + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.number + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.postcodeOrZip + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + 'Change' + ) + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-3.spec.ts b/e2e/testcases/death/declaration/death-declaration-3.spec.ts new file mode 100644 index 000000000..6e5882d5b --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-3.spec.ts @@ -0,0 +1,1137 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('3. Death declaration case - 3', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('male') + ' the 2nd', + familyName: faker.name.lastName('male') + }, + gender: 'Unknown', + age: 45, + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'Birth Registration Number' + }, + maritalStatus: 'Widowed', + address: { + country: 'Guam', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + event: { + manner: 'Suicide', + date: getRandomDate(0, 20), + cause: { + established: true, + source: 'Verbal autopsy', + description: 'Hanging from ceiling' + }, + place: "Deceased's usual place of residence" + }, + informantType: 'Daughter', + informantEmail: faker.internet.email(), + informant: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + age: 17, + nationality: 'Malawi', + identifier: { + id: faker.random.numeric(10), + type: 'Passport' + }, + address: { + sameAsDeceased: false, + country: 'Farajaland', + province: 'Chuminga', + district: 'Nsali', + urbanOrRural: 'Urban', + town: faker.address.city(), + residentialArea: faker.address.county(), + street: faker.address.streetName(), + number: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + spouse: { + name: { + firstNames: faker.name.firstName('female'), + familyName: faker.name.lastName('female') + }, + age: 42, + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'Birth Registration Number' + }, + address: { + sameAsDeceased: false, + country: 'Farajaland', + province: 'Chuminga', + district: 'Nsali', + urbanOrRural: 'Rural', + village: faker.address.county() + } + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('3.1 Declaratin started by FA', async () => { + test.beforeAll(async () => { + await login(page, 'k.bwalya', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('3.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page.getByText(declaration.deceased.gender, { exact: true }).click() + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.deceased.age.toString()) + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + + await page + .locator('#deceasedBirthRegistrationNumber') + .fill(declaration.deceased.identifier.id) + + await page.locator('#maritalStatus').click() + await page + .getByText(declaration.deceased.maritalStatus, { exact: true }) + .click() + + await page.locator('#countryPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryDeceased') + .fill(declaration.deceased.address.state) + await page + .locator('#internationalDistrictPrimaryDeceased') + .fill(declaration.deceased.address.district) + await page + .locator('#internationalCityPrimaryDeceased') + .fill(declaration.deceased.address.town) + await page + .locator('#internationalAddressLine1PrimaryDeceased') + .fill(declaration.deceased.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryDeceased') + .fill(declaration.deceased.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryDeceased') + .fill(declaration.deceased.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryDeceased') + .fill(declaration.deceased.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('3.1.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#mannerOfDeath').click() + await page.getByText(declaration.event.manner, { exact: true }).click() + + page.getByLabel('Cause of death has been established').check() + + await page.locator('#causeOfDeathMethod').click() + await page + .getByText(declaration.event.cause.source, { exact: true }) + .click() + await page + .locator('#deathDescription') + .fill(declaration.event.cause.description) + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place, { exact: true }).click() + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('3.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page.locator('#registrationEmail').fill(declaration.informantEmail) + + await page + .locator('#firstNamesEng') + .fill(declaration.informant.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.informant.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.informant.age.toString()) + + await page.locator('#nationality').click() + await page + .getByText(declaration.informant.nationality, { exact: true }) + .click() + + await page.locator('#informantIdType').click() + await page + .getByText(declaration.informant.identifier.type, { exact: true }) + .click() + + await page + .locator('#informantPassport') + .fill(declaration.informant.identifier.id) + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#statePrimaryInformant').click() + await page + .getByText(declaration.informant.address.province, { exact: true }) + .click() + await page.locator('#districtPrimaryInformant').click() + await page + .getByText(declaration.informant.address.district, { exact: true }) + .click() + + await page + .locator('#cityPrimaryInformant') + .fill(declaration.informant.address.town) + await page + .locator('#addressLine1UrbanOptionPrimaryInformant') + .fill(declaration.informant.address.residentialArea) + await page + .locator('#addressLine2UrbanOptionPrimaryInformant') + .fill(declaration.informant.address.street) + await page + .locator('#addressLine3UrbanOptionPrimaryInformant') + .fill(declaration.informant.address.number) + await page + .locator('#postalCodePrimaryInformant') + .fill(declaration.informant.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('3.1.4 Fill spouse details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.spouse.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.spouse.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.spouse.age.toString()) + + await page.locator('#spouseIdType').click() + await page + .getByText(declaration.spouse.identifier.type, { exact: true }) + .click() + + await page + .locator('#spouseBirthRegistrationNumber') + .fill(declaration.spouse.identifier.id) + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#statePrimarySpouse').click() + await page + .getByText(declaration.spouse.address.province, { exact: true }) + .click() + await page.locator('#districtPrimarySpouse').click() + await page + .getByText(declaration.spouse.address.district, { exact: true }) + .click() + + await page.getByLabel('Rural').check() + + await page + .locator('#addressLine1RuralOptionPrimarySpouse') + .fill(declaration.spouse.address.village) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('3.1.5 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('3.1.6 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Description cause of death + * - Change button + */ + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText(declaration.event.cause.description) + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText('Change') + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - informant's Id Number + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#informant-content #ID')).toContainText( + declaration.informant.identifier.id + ) + await expect(page.locator('#informant-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.province + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.residentialArea + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.street + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.number + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's age + * - Change button + */ + await expect(page.locator('#spouse-content #Age')).toContainText( + declaration.spouse.age + ' years' + ) + await expect(page.locator('#spouse-content #Age')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.country + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.district + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.province + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.village + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + 'Change' + ) + }) + + test('3.1.7 Send for review', async () => { + await page.getByRole('button', { name: 'Send for review' }).click() + await expect(page.getByText('Send for review?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Sent for review' }).click() + + /* + * Expected result: The declaration should be in sent for review + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('3.2 Declaration Review by RA', async () => { + test('3.2.1 Navigate to the declaration review page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready for review' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Review', exact: true }).click() + }) + + test('3.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Deceased's Id Number + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + declaration.deceased.identifier.id + ) + await expect(page.locator('#deceased-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Description cause of death + * - Change button + */ + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText(declaration.event.cause.description) + await expect( + page.locator('#deathEvent-content #Description') + ).toContainText('Change') + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - informant's Id Number + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#informant-content #ID')).toContainText( + declaration.informant.identifier.id + ) + await expect(page.locator('#informant-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.province + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.residentialArea + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.street + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.number + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's age + * - Change button + */ + await expect(page.locator('#spouse-content #Age')).toContainText( + declaration.spouse.age + ' years' + ) + await expect(page.locator('#spouse-content #Age')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Spouse's Id Number + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#spouse-content #ID')).toContainText( + declaration.spouse.identifier.id + ) + await expect(page.locator('#spouse-content #ID')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.country + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.district + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.province + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.village + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + 'Change' + ) + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-4.spec.ts b/e2e/testcases/death/declaration/death-declaration-4.spec.ts new file mode 100644 index 000000000..4f9d91416 --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-4.spec.ts @@ -0,0 +1,1091 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('4. Death declaration case - 4', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('female') + '_Nolas', + familyName: faker.name.lastName('female') + }, + gender: 'Female', + age: 45, + nationality: 'Farajaland', + identifier: { + type: 'None' + }, + maritalStatus: 'Divorced', + address: { + country: 'Guam', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + event: { + manner: 'Homicide', + date: getRandomDate(0, 20), + cause: { + established: true, + source: 'Medically Certified Cause of Death' + }, + place: 'Health Institution', + deathLocation: 'Railway GRZ Urban Health Centre' + }, + informantType: 'Son in law', + informantEmail: faker.internet.email(), + informant: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + age: 17, + nationality: 'Malawi', + identifier: { + id: faker.random.numeric(10), + type: 'Birth Registration Number' + }, + address: { + sameAsDeceased: false, + country: 'Farajaland', + province: 'Chuminga', + district: 'Nsali', + urbanOrRural: 'Rural', + village: faker.address.county() + } + }, + spouse: { + name: { + firstNames: faker.name.firstName('female'), + familyName: faker.name.lastName('female') + }, + age: 42, + nationality: 'Farajaland', + identifier: { + type: 'None' + }, + address: { + sameAsDeceased: false, + country: 'Guam', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('4.1 Declaratin started by RA', async () => { + test.beforeAll(async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('4.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page.getByText(declaration.deceased.gender, { exact: true }).click() + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.deceased.age.toString()) + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + + await page.locator('#maritalStatus').click() + await page + .getByText(declaration.deceased.maritalStatus, { exact: true }) + .click() + + await page.locator('#countryPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryDeceased') + .fill(declaration.deceased.address.state) + await page + .locator('#internationalDistrictPrimaryDeceased') + .fill(declaration.deceased.address.district) + await page + .locator('#internationalCityPrimaryDeceased') + .fill(declaration.deceased.address.town) + await page + .locator('#internationalAddressLine1PrimaryDeceased') + .fill(declaration.deceased.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryDeceased') + .fill(declaration.deceased.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryDeceased') + .fill(declaration.deceased.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryDeceased') + .fill(declaration.deceased.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('4.1.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#mannerOfDeath').click() + await page.getByText(declaration.event.manner, { exact: true }).click() + + page.getByLabel('Cause of death has been established').check() + + await page.locator('#causeOfDeathMethod').click() + await page + .getByText(declaration.event.cause.source, { exact: true }) + .click() + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place, { exact: true }).click() + + await page + .locator('#deathLocation') + .fill(declaration.event.deathLocation.slice(0, 3)) + + await page + .getByText(declaration.event.deathLocation, { exact: true }) + .click() + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('4.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page.locator('#registrationEmail').fill(declaration.informantEmail) + + await page + .locator('#firstNamesEng') + .fill(declaration.informant.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.informant.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.informant.age.toString()) + + await page.locator('#nationality').click() + await page + .getByText(declaration.informant.nationality, { exact: true }) + .click() + + await page.locator('#informantIdType').click() + await page + .getByText(declaration.informant.identifier.type, { exact: true }) + .click() + + await page + .locator('#informantBirthRegistrationNumber') + .fill(declaration.informant.identifier.id) + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#statePrimaryInformant').click() + await page + .getByText(declaration.informant.address.province, { exact: true }) + .click() + await page.locator('#districtPrimaryInformant').click() + await page + .getByText(declaration.informant.address.district, { exact: true }) + .click() + + await page.getByText('Rural', { exact: true }).click() + + await page + .locator('#addressLine1RuralOptionPrimaryInformant') + .fill(declaration.informant.address.village) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('4.1.4 Fill spouse details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.spouse.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.spouse.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.spouse.age.toString()) + + await page.locator('#spouseIdType').click() + await page + .getByText(declaration.spouse.identifier.type, { exact: true }) + .click() + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#countryPrimarySpouse').click() + await page + .getByText(declaration.spouse.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimarySpouse') + .fill(declaration.spouse.address.state) + await page + .locator('#internationalDistrictPrimarySpouse') + .fill(declaration.spouse.address.district) + await page + .locator('#internationalCityPrimarySpouse') + .fill(declaration.spouse.address.town) + await page + .locator('#internationalAddressLine1PrimarySpouse') + .fill(declaration.spouse.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimarySpouse') + .fill(declaration.spouse.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimarySpouse') + .fill(declaration.spouse.address.addressLine3) + await page + .locator('#internationalPostalCodePrimarySpouse') + .fill(declaration.spouse.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('4.1.5 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('4.1.6 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - informant's Id Number + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#informant-content #ID')).toContainText( + declaration.informant.identifier.id + ) + await expect(page.locator('#informant-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.province + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.village + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's age + * - Change button + */ + await expect(page.locator('#spouse-content #Age')).toContainText( + declaration.spouse.age + ' years' + ) + await expect(page.locator('#spouse-content #Age')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.country + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.district + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.state + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.town + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.addressLine1 + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.addressLine2 + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.addressLine3 + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.postcodeOrZip + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + 'Change' + ) + }) + + test('4.1.7 Send for approval', async () => { + await page.getByRole('button', { name: 'Send for approval' }).click() + await expect(page.getByText('Send for approval?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Sent for approval' }).click() + + /* + * Expected result: The declaration should be in sent for approval + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('4.2 Declaration Review by Local Registrar', async () => { + test('4.2.1 Navigate to the declaration review page', async () => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready for review' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Review', exact: true }).click() + }) + + test('4.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Yes' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Source cause of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Source')).toContainText( + declaration.event.cause.source + ) + await expect(page.locator('#deathEvent-content #Source')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - informant's Id Number + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + await expect(page.locator('#informant-content #ID')).toContainText( + declaration.informant.identifier.id + ) + await expect(page.locator('#informant-content #ID')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.province + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.village + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.firstNames + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + declaration.spouse.name.familyName + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's age + * - Change button + */ + await expect(page.locator('#spouse-content #Age')).toContainText( + declaration.spouse.age + ' years' + ) + await expect(page.locator('#spouse-content #Age')).toContainText('Change') + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + declaration.spouse.nationality + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + declaration.spouse.identifier.type + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.country + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.district + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.state + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.town + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.addressLine1 + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.addressLine2 + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.addressLine3 + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + declaration.spouse.address.postcodeOrZip + ) + await expect(page.locator('#spouse-content #Usual')).toContainText( + 'Change' + ) + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-5.spec.ts b/e2e/testcases/death/declaration/death-declaration-5.spec.ts new file mode 100644 index 000000000..907be3773 --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-5.spec.ts @@ -0,0 +1,954 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('5. Death declaration case - 5', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('female') + '-Peter', + familyName: faker.name.lastName('female') + }, + gender: 'Female', + age: 45, + nationality: 'Farajaland', + identifier: { + type: 'None' + }, + maritalStatus: 'Separated', + address: { + country: 'Guam', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + event: { + manner: 'Manner undetermined', + date: getRandomDate(0, 20), + cause: { + established: false + }, + place: 'Other', + deathLocation: { + country: 'Farajaland', + province: 'Chuminga', + district: 'Nsali', + urbanOrRural: 'Urban', + town: faker.address.city(), + residentialArea: faker.address.county(), + street: faker.address.streetName(), + number: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + informantType: 'Daughter in law', + informantEmail: faker.internet.email(), + informant: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + age: 17, + nationality: 'Malawi', + identifier: { + type: 'None' + }, + address: { + sameAsDeceased: false, + country: 'Comoros', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + spouse: { + detailsAvailable: false, + reason: 'Spouse ran away' + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('5.1 Declaratin started by RA', async () => { + test.beforeAll(async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('5.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page.getByText(declaration.deceased.gender, { exact: true }).click() + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.deceased.age.toString()) + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + + await page.locator('#maritalStatus').click() + await page + .getByText(declaration.deceased.maritalStatus, { exact: true }) + .click() + + await page.locator('#countryPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryDeceased') + .fill(declaration.deceased.address.state) + await page + .locator('#internationalDistrictPrimaryDeceased') + .fill(declaration.deceased.address.district) + await page + .locator('#internationalCityPrimaryDeceased') + .fill(declaration.deceased.address.town) + await page + .locator('#internationalAddressLine1PrimaryDeceased') + .fill(declaration.deceased.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryDeceased') + .fill(declaration.deceased.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryDeceased') + .fill(declaration.deceased.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryDeceased') + .fill(declaration.deceased.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('5.1.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#mannerOfDeath').click() + await page.getByText(declaration.event.manner, { exact: true }).click() + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place, { exact: true }).click() + + await page.locator('#statePlaceofdeath').click() + await page + .getByText(declaration.event.deathLocation.province, { exact: true }) + .click() + await page.locator('#districtPlaceofdeath').click() + await page + .getByText(declaration.event.deathLocation.district, { exact: true }) + .click() + + await page + .locator('#cityPlaceofdeath') + .fill(declaration.event.deathLocation.town) + await page + .locator('#addressLine1UrbanOptionPlaceofdeath') + .fill(declaration.event.deathLocation.residentialArea) + await page + .locator('#addressLine2UrbanOptionPlaceofdeath') + .fill(declaration.event.deathLocation.street) + await page + .locator('#addressLine3UrbanOptionPlaceofdeath') + .fill(declaration.event.deathLocation.number) + await page + .locator('#postalCodePlaceofdeath') + .fill(declaration.event.deathLocation.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('5.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page.locator('#registrationEmail').fill(declaration.informantEmail) + + await page + .locator('#firstNamesEng') + .fill(declaration.informant.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.informant.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.informant.age.toString()) + + await page.locator('#nationality').click() + await page + .getByText(declaration.informant.nationality, { exact: true }) + .click() + + await page.locator('#informantIdType').click() + await page + .getByText(declaration.informant.identifier.type, { exact: true }) + .click() + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#countryPrimaryInformant').click() + await page + .getByText(declaration.informant.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryInformant') + .fill(declaration.informant.address.state) + await page + .locator('#internationalDistrictPrimaryInformant') + .fill(declaration.informant.address.district) + await page + .locator('#internationalCityPrimaryInformant') + .fill(declaration.informant.address.town) + await page + .locator('#internationalAddressLine1PrimaryInformant') + .fill(declaration.informant.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryInformant') + .fill(declaration.informant.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryInformant') + .fill(declaration.informant.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryInformant') + .fill(declaration.informant.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('5.1.4 Fill spouse details', async () => { + await page.getByLabel("Spouse's details are not available").check() + + await page.locator('#reasonNotApplying').fill(declaration.spouse.reason) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('5.1.5 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('5.1.6 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.country + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.province + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.district + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.town + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.residentialArea + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.street + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.number + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.postcodeOrZip + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.state + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine1 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine2 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine3 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's details not available + * - Reason + * - Change button + */ + await expect(page.locator('#spouse-content')).toContainText( + "Spouse's details are not availableYes" + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + declaration.spouse.reason + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + 'Change' + ) + }) + + test('5.1.7 Send for approval', async () => { + await page.getByRole('button', { name: 'Send for approval' }).click() + await expect(page.getByText('Send for approval?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Sent for approval' }).click() + + /* + * Expected result: The declaration should be in sent for approval + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('5.2 Declaration Review by Local Registrar', async () => { + test('5.2.1 Navigate to the declaration review page', async () => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready for review' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Review', exact: true }).click() + }) + + test('5.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.country + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.province + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.district + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.town + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.residentialArea + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.street + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.number + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.postcodeOrZip + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.state + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine1 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine2 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine3 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's details not available + * - Reason + * - Change button + */ + await expect(page.locator('#spouse-content')).toContainText( + "Spouse's details are not availableYes" + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + declaration.spouse.reason + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + 'Change' + ) + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-6.spec.ts b/e2e/testcases/death/declaration/death-declaration-6.spec.ts new file mode 100644 index 000000000..243909b6d --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-6.spec.ts @@ -0,0 +1,840 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('6. Death declaration case - 6', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('female') + " O'Nila", + familyName: faker.name.lastName('female') + }, + gender: 'Female', + age: 45, + nationality: 'Farajaland', + identifier: { + type: 'None' + }, + maritalStatus: 'Not stated', + address: { + country: 'Guam', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + event: { + manner: 'Manner undetermined', + date: getRandomDate(0, 20), + cause: { + established: false + }, + place: 'Other', + deathLocation: { + country: 'Farajaland', + province: 'Chuminga', + district: 'Nsali', + urbanOrRural: 'Rural', + village: faker.address.county() + } + }, + informantType: 'Mother', + informantEmail: faker.internet.email(), + informant: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + age: 17, + nationality: 'Malawi', + identifier: { + type: 'None' + }, + address: { + sameAsDeceased: false, + country: 'Comoros', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + spouse: { + detailsAvailable: false, + reason: 'Spouse ran away' + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('6.1 Declaratin started by Local Registrar', async () => { + test.beforeAll(async () => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('6.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page.getByText(declaration.deceased.gender, { exact: true }).click() + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.deceased.age.toString()) + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + + await page.locator('#maritalStatus').click() + await page + .getByText(declaration.deceased.maritalStatus, { exact: true }) + .click() + + await page.locator('#countryPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryDeceased') + .fill(declaration.deceased.address.state) + await page + .locator('#internationalDistrictPrimaryDeceased') + .fill(declaration.deceased.address.district) + await page + .locator('#internationalCityPrimaryDeceased') + .fill(declaration.deceased.address.town) + await page + .locator('#internationalAddressLine1PrimaryDeceased') + .fill(declaration.deceased.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryDeceased') + .fill(declaration.deceased.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryDeceased') + .fill(declaration.deceased.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryDeceased') + .fill(declaration.deceased.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('6.1.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#mannerOfDeath').click() + await page.getByText(declaration.event.manner, { exact: true }).click() + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place, { exact: true }).click() + + await page.locator('#statePlaceofdeath').click() + await page + .getByText(declaration.event.deathLocation.province, { exact: true }) + .click() + await page.locator('#districtPlaceofdeath').click() + await page + .getByText(declaration.event.deathLocation.district, { exact: true }) + .click() + + await page.getByLabel('Rural').check() + + await page + .locator('#addressLine1RuralOptionPlaceofdeath') + .fill(declaration.event.deathLocation.village) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('6.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page.locator('#registrationEmail').fill(declaration.informantEmail) + + await page + .locator('#firstNamesEng') + .fill(declaration.informant.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.informant.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.informant.age.toString()) + + await page.locator('#nationality').click() + await page + .getByText(declaration.informant.nationality, { exact: true }) + .click() + + await page.locator('#informantIdType').click() + await page + .getByText(declaration.informant.identifier.type, { exact: true }) + .click() + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#countryPrimaryInformant').click() + await page + .getByText(declaration.informant.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryInformant') + .fill(declaration.informant.address.state) + await page + .locator('#internationalDistrictPrimaryInformant') + .fill(declaration.informant.address.district) + await page + .locator('#internationalCityPrimaryInformant') + .fill(declaration.informant.address.town) + await page + .locator('#internationalAddressLine1PrimaryInformant') + .fill(declaration.informant.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryInformant') + .fill(declaration.informant.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryInformant') + .fill(declaration.informant.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryInformant') + .fill(declaration.informant.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('6.1.4 Fill spouse details', async () => { + await page.getByLabel("Spouse's details are not available").check() + + await page.locator('#reasonNotApplying').fill(declaration.spouse.reason) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('6.1.5 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('6.1.6 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.country + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.province + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.district + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.village + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.state + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine1 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine2 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine3 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's details not available + * - Reason + * - Change button + */ + await expect(page.locator('#spouse-content')).toContainText( + "Spouse's details are not availableYes" + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + declaration.spouse.reason + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + 'Change' + ) + }) + + test('6.1.7 Register', async () => { + await page.getByRole('button', { name: 'Register' }).click() + await expect(page.getByText('Register the death?')).toBeVisible() + await page.locator('#submit_confirm').click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Ready to print' }).click() + + /* + * Expected result: The declaration should be in Ready to print + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('6.2 Declaration Review by Registration Agent', async () => { + test('6.2.1 Navigate to the declaration review page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'Ready to print' }).click() + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'View', exact: true }).click() + }) + + test('6.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + + /* + * Expected result: should include + * - Deceased's Gender + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + + /* + * Expected result: should include + * - Deceased's age + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + + /* + * Expected result: should include + * - Deceased's Type of Id + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + + /* + * Expected result: should include + * - Deceased's marital status + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + + /* + * Expected result: should include + * - Deceased's address + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + + /* + * Expected result: should include + * - Date of death + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + + /* + * Expected result: should include + * - Manner of death has been established + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + + /* + * Expected result: should include + * - Cause of death has been established + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + + /* + * Expected result: should include + * - Place of death + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.country + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.province + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.district + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.village + ) + + /* + * Expected result: should include + * - Informant type + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + + /* + * Expected result: should include + * - informant's age + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + + /* + * Expected result: should include + * - informant's Nationality + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + + /* + * Expected result: should include + * - informant's Type of Id + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + + /* + * Expected result: should include + * - informant's address + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.state + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine1 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine2 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine3 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + + /* + * Expected result: should include + * - Informant's Email + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + + /* + * Expected result: should include + * - Spouse's details not available + * - Reason + */ + await expect(page.locator('#spouse-content')).toContainText( + "Spouse's details are not availableYes" + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + declaration.spouse.reason + ) + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-7.spec.ts b/e2e/testcases/death/declaration/death-declaration-7.spec.ts new file mode 100644 index 000000000..a63776ced --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-7.spec.ts @@ -0,0 +1,868 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, getRandomDate, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' +import { format } from 'date-fns' + +test.describe.serial('7. Death declaration case - 7', () => { + let page: Page + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('female'), + familyName: faker.name.lastName('female') + }, + gender: 'Female', + age: 45, + nationality: 'Farajaland', + identifier: { + type: 'None' + }, + maritalStatus: 'Not stated', + address: { + country: 'Guam', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + event: { + manner: 'Manner undetermined', + date: getRandomDate(0, 20), + cause: { + established: false + }, + place: 'Other', + deathLocation: { + country: 'Germany', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + informantType: 'Father', + informantEmail: faker.internet.email(), + informant: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + age: 17, + nationality: 'Malawi', + identifier: { + type: 'None' + }, + address: { + sameAsDeceased: false, + country: 'Comoros', + state: faker.address.state(), + district: faker.address.county(), + town: faker.address.city(), + addressLine1: faker.address.county(), + addressLine2: faker.address.streetName(), + addressLine3: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + spouse: { + detailsAvailable: false, + reason: 'Spouse ran away' + } + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('7.1 Declaratin started by National Registrar', async () => { + test.beforeAll(async () => { + await login(page, 'j.musonda', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('7.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.locator('#gender').click() + await page.getByText(declaration.deceased.gender, { exact: true }).click() + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.deceased.age.toString()) + + await page.locator('#deceasedIdType').click() + await page + .getByText(declaration.deceased.identifier.type, { exact: true }) + .click() + + await page.locator('#maritalStatus').click() + await page + .getByText(declaration.deceased.maritalStatus, { exact: true }) + .click() + + await page.locator('#countryPrimaryDeceased').click() + await page + .getByText(declaration.deceased.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryDeceased') + .fill(declaration.deceased.address.state) + await page + .locator('#internationalDistrictPrimaryDeceased') + .fill(declaration.deceased.address.district) + await page + .locator('#internationalCityPrimaryDeceased') + .fill(declaration.deceased.address.town) + await page + .locator('#internationalAddressLine1PrimaryDeceased') + .fill(declaration.deceased.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryDeceased') + .fill(declaration.deceased.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryDeceased') + .fill(declaration.deceased.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryDeceased') + .fill(declaration.deceased.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('7.1.2 Fill event details', async () => { + await page.getByPlaceholder('dd').fill(declaration.event.date.dd) + await page.getByPlaceholder('mm').fill(declaration.event.date.mm) + await page.getByPlaceholder('yyyy').fill(declaration.event.date.yyyy) + + await page.locator('#mannerOfDeath').click() + await page.getByText(declaration.event.manner, { exact: true }).click() + + await page.locator('#placeOfDeath').click() + await page.getByText(declaration.event.place, { exact: true }).click() + + await page.locator('#countryPlaceofdeath').click() + await page + .getByText(declaration.event.deathLocation.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePlaceofdeath') + .fill(declaration.event.deathLocation.state) + await page + .locator('#internationalDistrictPlaceofdeath') + .fill(declaration.event.deathLocation.district) + await page + .locator('#internationalCityPlaceofdeath') + .fill(declaration.event.deathLocation.town) + await page + .locator('#internationalAddressLine1Placeofdeath') + .fill(declaration.event.deathLocation.addressLine1) + await page + .locator('#internationalAddressLine2Placeofdeath') + .fill(declaration.event.deathLocation.addressLine2) + await page + .locator('#internationalAddressLine3Placeofdeath') + .fill(declaration.event.deathLocation.addressLine3) + await page + .locator('#internationalPostalCodePlaceofdeath') + .fill(declaration.event.deathLocation.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('7.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + + await page.locator('#registrationEmail').fill(declaration.informantEmail) + + await page + .locator('#firstNamesEng') + .fill(declaration.informant.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.informant.name.familyName) + + await page.getByLabel('Exact date of birth unknown').check() + await page + .locator('#ageOfIndividualInYears') + .fill(declaration.informant.age.toString()) + + await page.locator('#nationality').click() + await page + .getByText(declaration.informant.nationality, { exact: true }) + .click() + + await page.locator('#informantIdType').click() + await page + .getByText(declaration.informant.identifier.type, { exact: true }) + .click() + + await page.getByLabel('No', { exact: true }).check() + + await page.locator('#countryPrimaryInformant').click() + await page + .getByText(declaration.informant.address.country, { exact: true }) + .click() + + await page + .locator('#internationalStatePrimaryInformant') + .fill(declaration.informant.address.state) + await page + .locator('#internationalDistrictPrimaryInformant') + .fill(declaration.informant.address.district) + await page + .locator('#internationalCityPrimaryInformant') + .fill(declaration.informant.address.town) + await page + .locator('#internationalAddressLine1PrimaryInformant') + .fill(declaration.informant.address.addressLine1) + await page + .locator('#internationalAddressLine2PrimaryInformant') + .fill(declaration.informant.address.addressLine2) + await page + .locator('#internationalAddressLine3PrimaryInformant') + .fill(declaration.informant.address.addressLine3) + await page + .locator('#internationalPostalCodePrimaryInformant') + .fill(declaration.informant.address.postcodeOrZip) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('7.1.4 Fill spouse details', async () => { + await page.getByLabel("Spouse's details are not available").check() + + await page.locator('#reasonNotApplying').fill(declaration.spouse.reason) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('7.1.5 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('7.1.6 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's age + * - Change button + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + await expect(page.locator('#deceased-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's marital status + * - Change button + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + await expect(page.locator('#deceased-content #Marital')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Manner of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.country + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.state + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.district + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.town + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.addressLine1 + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.addressLine2 + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.addressLine3 + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.postcodeOrZip + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + * - Change button + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + await expect(page.locator('#informant-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's age + * - Change button + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + await expect(page.locator('#informant-content #Age')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's Nationality + * - Change button + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + await expect( + page.locator('#informant-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should include + * - informant's Type of Id + * - Change button + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + await expect(page.locator('#informant-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - informant's address + * - Change button + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.state + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine1 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine2 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine3 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's details not available + * - Reason + * - Change button + */ + await expect(page.locator('#spouse-content')).toContainText( + "Spouse's details are not availableYes" + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + declaration.spouse.reason + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + 'Change' + ) + }) + + test('7.1.7 Register', async () => { + await page.getByRole('button', { name: 'Register' }).click() + await expect(page.getByText('Register the death?')).toBeVisible() + await page.locator('#submit_confirm').click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Ready to print' }).click() + + /* + * Expected result: The declaration should be in Ready to print + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + test('7.1.8 Verify informations in view page', async () => { + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + + await page.getByRole('button', { name: 'View', exact: true }).click() + + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + + /* + * Expected result: should include + * - Deceased's Gender + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + declaration.deceased.gender + ) + + /* + * Expected result: should include + * - Deceased's age + */ + await expect(page.locator('#deceased-content #Age')).toContainText( + declaration.deceased.age + ' years' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + + /* + * Expected result: should include + * - Deceased's Type of Id + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + declaration.deceased.identifier.type + ) + + /* + * Expected result: should include + * - Deceased's marital status + */ + await expect(page.locator('#deceased-content #Marital')).toContainText( + declaration.deceased.maritalStatus + ) + + /* + * Expected result: should include + * - Deceased's address + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.state + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.town + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine1 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine2 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.addressLine3 + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.postcodeOrZip + ) + + /* + * Expected result: should include + * - Date of death + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'dd MMMM yyyy' + ) + ) + + /* + * Expected result: should include + * - Manner of death has been established + */ + await expect(page.locator('#deathEvent-content #Manner')).toContainText( + declaration.event.manner + ) + + /* + * Expected result: should include + * - Cause of death has been established + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + + /* + * Expected result: should include + * - Place of death + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.place + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.country + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.state + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.district + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.town + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.addressLine1 + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.addressLine2 + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + declaration.event.deathLocation.addressLine3 + ) + + // Bug: This should be visible but is not + // await expect(page.locator('#deathEvent-content #Place')).toContainText( + // declaration.event.deathLocation.postcodeOrZip + // ) + + /* + * Expected result: should include + * - Informant type + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + + /* + * Expected result: should include + * - Informant's First Name + * - Informant's Family Name + */ + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.firstNames + ) + await expect(page.locator('#informant-content #Full')).toContainText( + declaration.informant.name.familyName + ) + + /* + * Expected result: should include + * - informant's age + */ + await expect(page.locator('#informant-content #Age')).toContainText( + declaration.informant.age + ' years' + ) + + /* + * Expected result: should include + * - informant's Nationality + */ + await expect( + page.locator('#informant-content #Nationality') + ).toContainText(declaration.informant.nationality) + + /* + * Expected result: should include + * - informant's Type of Id + */ + await expect(page.locator('#informant-content #Type')).toContainText( + declaration.informant.identifier.type + ) + + /* + * Expected result: should include + * - informant's address + */ + await expect(page.locator('#informant-content #Usual')).toContainText( + 'No' + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.country + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.state + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.district + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.town + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine1 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine2 + ) + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.addressLine3 + ) + + await expect(page.locator('#informant-content #Usual')).toContainText( + declaration.informant.address.postcodeOrZip + ) + + /* + * Expected result: should include + * - Informant's Email + */ + await expect(page.locator('#informant-content #Email')).toContainText( + declaration.informantEmail + ) + + /* + * Expected result: should include + * - Spouse's details not available + * - Reason + */ + await expect(page.locator('#spouse-content')).toContainText( + "Spouse's details are not availableYes" + ) + await expect(page.locator('#spouse-content #Reason')).toContainText( + declaration.spouse.reason + ) + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-8.spec.ts b/e2e/testcases/death/declaration/death-declaration-8.spec.ts new file mode 100644 index 000000000..a482fd5a1 --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-8.spec.ts @@ -0,0 +1,509 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' + +test.describe.serial('8. Death declaration case - 8', () => { + let page: Page + const require = 'Required for registration' + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + address: { + country: 'Farajaland', + province: 'Central', + district: 'Ibombo' + }, + nationality: 'Farajaland' + }, + informantType: 'Grandson' + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('8.1 Declaratin started by FA', async () => { + test.beforeAll(async () => { + await login(page, 'k.bwalya', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('8.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + await page + .locator('#familyNameEng') + .fill(declaration.deceased.name.familyName) + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('8.1.2 Fill event details', async () => { + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('8.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('8.1.4 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('8.1.5 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + require + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's date of birth + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + require + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should require + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + require + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Must be a valid date of death' + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + require + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + 'Must be a valid email address' + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + + await expect(page.locator('#spouse-content #Full')).toContainText(require) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's date of birth + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText(require) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Farajaland' + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText(require) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + + test('8.1.6 Send for review', async () => { + await page.getByRole('button', { name: 'Send for review' }).click() + await expect(page.getByText('Send for review?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Sent for review' }).click() + + /* + * Expected result: The declaration should be in sent for review + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + ).toBeVisible() + }) + }) + + test.describe('8.2 Declaration Review by RA', async () => { + test('8.2.1 Navigate to the declaration review page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'In Progress' }).click() + await page.getByRole('button', { name: 'Field Agents' }).click() + + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames} ${declaration.deceased.name.familyName}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Update', exact: true }).click() + }) + + test('8.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.familyName + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + require + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's date of birth + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + require + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should require + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + require + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Must be a valid date of death' + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + require + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + 'Must be a valid email address' + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + + await expect(page.locator('#spouse-content #Full')).toContainText(require) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's date of birth + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText(require) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Farajaland' + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText(require) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + }) +}) diff --git a/e2e/testcases/death/declaration/death-declaration-9.spec.ts b/e2e/testcases/death/declaration/death-declaration-9.spec.ts new file mode 100644 index 000000000..eb9ac5068 --- /dev/null +++ b/e2e/testcases/death/declaration/death-declaration-9.spec.ts @@ -0,0 +1,520 @@ +import { test, expect, type Page } from '@playwright/test' +import { createPIN, goToSection, login } from '../../../helpers' +import faker from '@faker-js/faker' + +test.describe.serial('9. Death declaration case - 9', () => { + let page: Page + const REQUIRED = 'Required for registration' + const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('male') + }, + address: { + country: 'Farajaland', + province: 'Central', + district: 'Ibombo' + }, + nationality: 'Farajaland' + }, + informantType: 'Grandson' + } + test.beforeAll(async ({ browser }) => { + page = await browser.newPage() + }) + + test.afterAll(async () => { + await page.close() + }) + + test.describe('9.1 Declaratin started by FA', async () => { + test.beforeAll(async () => { + await login(page, 'k.bwalya', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByLabel('Death').click() + await page.getByRole('button', { name: 'Continue' }).click() + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('9.1.1 Fill deceased details', async () => { + await page + .locator('#firstNamesEng') + .fill(declaration.deceased.name.firstNames) + + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('9.1.2 Fill event details', async () => { + await page.waitForTimeout(500) + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('9.1.3 Fill informant details', async () => { + await page.waitForTimeout(500) + await page.locator('#informantType').click() + await page + .getByText(declaration.informantType, { + exact: true + }) + .click() + + await page.waitForTimeout(500) // Temporary measurement untill the bug is fixed. BUG: rerenders after selecting relation with deceased + await page.getByRole('button', { name: 'Continue' }).click() + }) + + test('9.1.4 Go to preview', async () => { + goToSection(page, 'preview') + }) + + test('9.1.5 Verify informations in preview page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * * should require + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's date of birth + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should require + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Must be a valid date of death' + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + REQUIRED + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + 'Must be a valid email address' + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + + await expect(page.locator('#spouse-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's date of birth + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Farajaland' + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + + test('9.1.6 Send for review', async () => { + await page.getByRole('button', { name: 'Send for review' }).click() + await expect(page.getByText('Send for review?')).toBeVisible() + await page.getByRole('button', { name: 'Confirm' }).click() + await expect(page.getByText('Farajaland CRS')).toBeVisible() + + /* + * Expected result: should redirect to registration home + */ + expect(page.url().includes('registration-home')).toBeTruthy() + + await expect(page.locator('#navigation_outbox')).not.toContainText('1', { + timeout: 1000 * 30 + }) + + await page.getByRole('button', { name: 'Sent for review' }).click() + + /* + * Expected result: The declaration should be in sent for review + */ + await expect( + page.getByRole('button', { + name: `${declaration.deceased.name.firstNames}` + }) + ).toBeVisible() + }) + }) + + test.describe('9.2 Declaration Review by RA', async () => { + test('9.2.1 Navigate to the declaration review page', async () => { + await login(page, 'f.katongo', 'test') + await createPIN(page) + await page.getByRole('button', { name: 'In Progress' }).click() + await page.getByRole('button', { name: 'Field Agents' }).click() + + await page + .getByRole('button', { + name: `${declaration.deceased.name.firstNames}` + }) + .click() + await page.getByLabel('Assign record').click() + await page.getByRole('button', { name: 'Assign', exact: true }).click() + await page.getByRole('button', { name: 'Update', exact: true }).click() + }) + + test('9.2.2 Verify informations in review page', async () => { + /* + * Expected result: should include + * - Deceased's First Name + * * should require + * - Deceased's Family Name + * - Change button + */ + await expect(page.locator('#deceased-content #Full')).toContainText( + declaration.deceased.name.firstNames + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's Gender + * - Change button + */ + await expect(page.locator('#deceased-content #Sex')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Sex')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Deceased's date of birth + * - Change button + */ + await expect(page.locator('#deceased-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's Nationality + * - Change button + */ + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText(declaration.deceased.nationality) + await expect( + page.locator('#deceased-content #Nationality') + ).toContainText('Change') + + /* + * Expected result: should require + * - Deceased's Type of Id + * - Change button + */ + await expect(page.locator('#deceased-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#deceased-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Deceased's address + * - Change button + */ + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.country + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.district + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + declaration.deceased.address.province + ) + await expect(page.locator('#deceased-content #Usual')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Date of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Must be a valid date of death' + ) + await expect(page.locator('#deathEvent-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Cause of death has been established + * - Change button + */ + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'No' + ) + await expect(page.locator('#deathEvent-content #Cause')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Place of death + * - Change button + */ + await expect(page.locator('#deathEvent-content #Place')).toContainText( + REQUIRED + ) + await expect(page.locator('#deathEvent-content #Place')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Informant type + * - Change button + */ + await expect(page.locator('#informant-content #Informant')).toContainText( + declaration.informantType + ) + await expect(page.locator('#informant-content #Informant')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Informant's Email + * - Change button + */ + await expect(page.locator('#informant-content #Email')).toContainText( + 'Must be a valid email address' + ) + await expect(page.locator('#informant-content #Email')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's First Name + * - Spouse's Family Name + * - Change button + */ + + await expect(page.locator('#spouse-content #Full')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Full')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's date of birth + * - Change button + */ + await expect(page.locator('#spouse-content #Date')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Date')).toContainText( + 'Change' + ) + + /* + * Expected result: should include + * - Spouse's Nationality + * - Change button + */ + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Farajaland' + ) + await expect(page.locator('#spouse-content #Nationality')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's Type of Id + * - Change button + */ + await expect(page.locator('#spouse-content #Type')).toContainText( + REQUIRED + ) + await expect(page.locator('#spouse-content #Type')).toContainText( + 'Change' + ) + + /* + * Expected result: should require + * - Spouse's address + * - Change button + */ + await expect(page.locator('#spouse-content #Usual')).toContainText('Yes') + }) + }) +}) diff --git a/e2e/testcases/death/helpers.ts b/e2e/testcases/death/helpers.ts new file mode 100644 index 000000000..5f5d4cf90 --- /dev/null +++ b/e2e/testcases/death/helpers.ts @@ -0,0 +1,292 @@ +import gql from 'graphql-tag' +import { print } from 'graphql/language/printer' +import { GATEWAY_HOST } from '../../constants' +import { DeathRegistrationInput } from '../../gateway' +import faker from '@faker-js/faker' + +import { readFileSync } from 'fs' +import uuid from 'uuid' +import { format } from 'date-fns' +import { join } from 'path' +import { getRandomDate } from '../../helpers' + +export const CREATE_DEATH_REGISTRATION = print(gql` + mutation createDeathRegistration($details: DeathRegistrationInput!) { + createDeathRegistration(details: $details) { + trackingId + compositionId + isPotentiallyDuplicate + __typename + } + } +`) + +const declaration = { + deceased: { + name: { + firstNames: faker.name.firstName('male'), + familyName: faker.name.lastName('male') + }, + gender: 'male', + birthDate: getRandomDate(75, 200), + nationality: 'FAR', + identifier: { + type: 'NATIONAL_ID', + id: faker.random.numeric(10) + }, + address: { + country: 'FAR', + province: 'Sulaka', + district: 'Zobwe', + urbanOrRural: 'Urban', + town: faker.address.city(), + residentialArea: faker.address.county(), + street: faker.address.streetName(), + number: faker.address.buildingNumber(), + postcodeOrZip: faker.address.zipCode() + } + }, + event: { + manner: 'Natural causes', + date: getRandomDate(0, 20), + cause: { + established: true, + source: 'Physician' + }, + place: "Deceased's usual place of residence" + }, + informantType: 'Spouse', + informantEmail: faker.internet.email(), + spouse: { + name: { + firstNames: faker.name.firstName('female'), + familyName: faker.name.lastName('female') + }, + birthDate: getRandomDate(50, 200), + nationality: 'Farajaland', + identifier: { + id: faker.random.numeric(10), + type: 'NATIONAL_ID' + }, + address: { + sameAsDeceased: true + } + } +} + +async function getAllLocations( + type: 'ADMIN_STRUCTURE' | 'HEALTH_FACILITY' | 'CRVS_OFFICE' +) { + const locations = (await fetch( + `${GATEWAY_HOST}/location?type=${type}&_count=0` + ).then((res) => res.json())) as fhir.Bundle + return locations.entry!.map((entry) => entry.resource as fhir.Location) +} + +function getLocationIdByName(locations: fhir.Location[], name: string) { + const location = locations.find((location) => location.name === name) + if (!location?.id) { + throw new Error(`Location with name ${name} not found`) + } + return location.id +} + +export async function createDeathDeclaration(token: string) { + const locations = await getAllLocations('ADMIN_STRUCTURE') + const facilities = await getAllLocations('HEALTH_FACILITY') + + const res = await fetch(`${GATEWAY_HOST}/graphql`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + }, + body: JSON.stringify({ + query: CREATE_DEATH_REGISTRATION, + variables: { + details: { + createdAt: new Date().toISOString(), + registration: { + status: [ + { + timestamp: new Date().toISOString(), + timeLoggedMS: 1031608 + } + ], + informantsSignature: + 'data:image/png;base64,' + + readFileSync( + join(__dirname, './data/assets/528KB-random.png') + ).toString('base64'), + informantType: declaration.informantType, + contactEmail: declaration.informantEmail, + draftId: uuid.v4() + }, + causeOfDeath: 'NATURAL', + deceased: { + name: [ + { + use: 'en', + firstNames: declaration.deceased.name.firstNames, + familyName: declaration.deceased.name.familyName + } + ], + gender: declaration.deceased.gender as 'male', + birthDate: format( + new Date( + Number(declaration.deceased.birthDate.yyyy), + Number(declaration.deceased.birthDate.mm) - 1, + Number(declaration.deceased.birthDate.dd) + ), + 'yyyy-MM-dd' + ), + nationality: [declaration.deceased.nationality], + identifier: [ + { + type: declaration.deceased.identifier.type, + id: declaration.deceased.identifier.id + } + ], + address: [ + { + type: 'PRIMARY_ADDRESS', + line: [ + declaration.deceased.address.number, + declaration.deceased.address.street, + declaration.deceased.address.residentialArea, + '', + '', + 'URBAN', + '', + '', + '', + '', + '', + '', + '', + '', + '' + ], + country: declaration.deceased.address.country, + state: getLocationIdByName( + locations, + declaration.deceased.address.province + ), + partOf: getLocationIdByName( + locations, + declaration.deceased.address.district + ), + district: getLocationIdByName( + locations, + declaration.deceased.address.district + ), + city: declaration.deceased.address.town, + postalCode: declaration.deceased.address.postcodeOrZip + } + ], + deceased: { + deathDate: format( + new Date( + Number(declaration.event.date.yyyy), + Number(declaration.event.date.mm) - 1, + Number(declaration.event.date.dd) + ), + 'yyyy-MM-dd' + ) + } + }, + eventLocation: { + _fhirID: getLocationIdByName( + facilities, + 'Chikobo Rural Health Centre' + ) + }, + informant: { relationship: 'SPOUSE' }, + questionnaire: [ + { + fieldId: 'death.deceased.deceased-view-group.deceasedIdType', + value: 'NATIONAL_ID' + }, + { + fieldId: 'death.spouse.spouse-view-group.spouseIdType', + value: 'NATIONAL_ID' + } + ], + causeOfDeathEstablished: 'false', + spouse: { + name: [ + { + use: 'en', + firstNames: declaration.spouse.name.firstNames, + familyName: declaration.spouse.name.familyName + } + ], + birthDate: format( + new Date( + Number(declaration.spouse.birthDate.yyyy), + Number(declaration.spouse.birthDate.mm) - 1, + Number(declaration.spouse.birthDate.dd) + ), + 'yyyy-MM-dd' + ), + nationality: ['FAR'], + identifier: [ + { + id: declaration.spouse.identifier.id, + type: declaration.spouse.identifier.type + } + ], + address: [ + { + type: 'PRIMARY_ADDRESS', + line: [ + declaration.deceased.address.number, + declaration.deceased.address.street, + declaration.deceased.address.residentialArea, + '', + '', + 'URBAN', + '', + '', + '', + '', + '', + '', + '', + '', + '' + ], + country: declaration.deceased.address.country, + state: getLocationIdByName( + locations, + declaration.deceased.address.province + ), + partOf: getLocationIdByName( + locations, + declaration.deceased.address.district + ), + district: getLocationIdByName( + locations, + declaration.deceased.address.district + ), + city: declaration.deceased.address.town, + postalCode: declaration.deceased.address.postcodeOrZip + } + ] + } + } satisfies ConvertEnumsToStrings + } + }) + }) + return res.json().then((r) => r.data.createDeathRegistration) +} + +type ConvertEnumsToStrings = T extends (infer U)[] + ? ConvertEnumsToStrings[] + : T extends string + ? `${T}` + : T extends object + ? { + [K in keyof T]: ConvertEnumsToStrings + } + : T