From f31d85c5a1d2a0ec2a678c29b652788613695b0f Mon Sep 17 00:00:00 2001 From: Eezi Date: Wed, 29 May 2024 20:12:54 +0300 Subject: [PATCH 01/10] Testcase 6 setup and made first test --- .../marriage/details-page-validation.spec.ts | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 e2e/testcases/marriage/details-page-validation.spec.ts diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts new file mode 100644 index 000000000..270c4230d --- /dev/null +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -0,0 +1,102 @@ +import { expect, test } from '@playwright/test' +import { createPIN, login } from '../../helpers' + +test.describe('6. Validate Marriage details page', () => { + test.beforeEach(async ({ page }) => { + await login(page, 'k.mweene', 'test') + await createPIN(page) + await page.click('#header_new_event') + await page.getByText('Marriage', { exact: true }).click() + await page.getByText('Continue', { exact: true }).click() + await page.getByText('Continue', { exact: true }).click() + await page.getByPlaceholder('dd').fill('02') + await page.getByPlaceholder('mm').fill('03') + await page.getByPlaceholder('yyyy').fill('1995') + await page.getByText('Continue', { exact: true }).click() + await page.getByPlaceholder('dd').fill('01') + await page.getByPlaceholder('mm').fill('05') + await page.getByPlaceholder('yyyy').fill('1993') + await page.getByText('Continue', { exact: true }).click() + }) + + test('1.1. Enter date Less than the current date But after Groom and Bride DOB', async ({ + page + }) => { + // Tästä vois tehdä utils function + const currentDate = new Date() + currentDate.setDate(currentDate.getDate() - 2) + const day = String(currentDate.getDate()).padStart(2, '0') + const month = String(currentDate.getMonth() + 1).padStart(2, '0') + const year = currentDate.getFullYear().toString() + + await page.getByPlaceholder('dd').fill(day) + await page.getByPlaceholder('mm').fill(month) + await page.getByPlaceholder('yyyy').fill(year) + await expect( + page.getByText('Illegal age of marriage', { exact: true }) + ).toBeHidden() + await expect( + page.getByText('Required for registration. Enter a valid date', { + exact: true + }) + ).toBeHidden() + }) + + // Jostain syystä validation errorit ei tule näkyviin. + test('1.2. Enter future date', async ({ page }) => { + const currentDate = new Date() + currentDate.setDate(currentDate.getDate() + 5) + const day = String(currentDate.getDate()).padStart(2, '0') + const month = String(currentDate.getMonth() + 1).padStart(2, '0') + const year = currentDate.getFullYear().toString() + + await page.getByPlaceholder('dd').fill(day) + await page.getByPlaceholder('mm').fill(month) + await page.getByPlaceholder('yyyy').fill(year) + await expect( + page.getByText('Required for registration. Enter a valid date', { + exact: true + }) + ).toBeVisible() + }) + test('1.3. Keep field as null', async ({ page }) => { + await page.getByText('Continue', { exact: true }).click() + await page.getByText('Continue', { exact: true }).click() + await page.getByText('Continue', { exact: true }).click() + await page.getByText('Continue', { exact: true }).click() + await expect( + page.getByText('Required for registration', { + exact: true + }) + ).toBeVisible() + }) + // Jostain syystä validation errorit ei tule näkyviin. + test('1.4. Enter date Less than the current date But before Groom and Bride DOB', async ({ + page + }) => { + await page.getByPlaceholder('dd').fill('01') + await page.getByPlaceholder('mm').fill('05') + await page.getByPlaceholder('yyyy').fill('1980') + await expect( + page.getByText('Illegal age of marriage', { + exact: true + }) + ).toBeVisible() + }) + + test('2.1. Select any country from the "Country" dropdown field, Default value is Farajaland', async ({ + page + }) => {}) + test('2.2. Select any Province from "Province" dropdown field, Default value is Central', async ({ + page + }) => {}) + test('2.3. Select any district from "District" dropdown field, Default value is Ibombo', async ({ + page + }) => {}) + test('2.4. Select Urban address', async ({ page }) => {}) + test('2.5. Select Rural address', async ({ page }) => {}) + test('3 Select any of the following options from Type of marriage dropdown', async ({ + page + }) => {}) + test('4 Navigate to Witness 1 details page', async ({ page }) => {}) +}) From 8c4cfc639299ada91d4e13aa873afb5face1cd41 Mon Sep 17 00:00:00 2001 From: Eezi Date: Wed, 5 Jun 2024 20:21:10 +0300 Subject: [PATCH 02/10] Tests for marriage details page --- .../marriage/details-page-validation.spec.ts | 116 +++++++++++++----- 1 file changed, 84 insertions(+), 32 deletions(-) diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index 270c4230d..c479f244c 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -22,16 +22,13 @@ test.describe('6. Validate Marriage details page', () => { test('1.1. Enter date Less than the current date But after Groom and Bride DOB', async ({ page }) => { - // Tästä vois tehdä utils function - const currentDate = new Date() - currentDate.setDate(currentDate.getDate() - 2) - const day = String(currentDate.getDate()).padStart(2, '0') - const month = String(currentDate.getMonth() + 1).padStart(2, '0') - const year = currentDate.getFullYear().toString() + const pastDate = new Date() + pastDate.setDate(new Date().getDate() - 2) + const [yyyy, mm, dd] = pastDate.toISOString().split('T')[0].split('-') - await page.getByPlaceholder('dd').fill(day) - await page.getByPlaceholder('mm').fill(month) - await page.getByPlaceholder('yyyy').fill(year) + await page.getByPlaceholder('dd').fill(dd) + await page.getByPlaceholder('mm').fill(mm) + await page.getByPlaceholder('yyyy').fill(yyyy) await expect( page.getByText('Illegal age of marriage', { exact: true }) ).toBeHidden() @@ -42,22 +39,18 @@ test.describe('6. Validate Marriage details page', () => { ).toBeHidden() }) - // Jostain syystä validation errorit ei tule näkyviin. test('1.2. Enter future date', async ({ page }) => { - const currentDate = new Date() - currentDate.setDate(currentDate.getDate() + 5) - const day = String(currentDate.getDate()).padStart(2, '0') - const month = String(currentDate.getMonth() + 1).padStart(2, '0') - const year = currentDate.getFullYear().toString() + const futureDate = new Date() + futureDate.setDate(new Date().getDate() + 5) + const [yyyy, mm, dd] = futureDate.toISOString().split('T')[0].split('-') - await page.getByPlaceholder('dd').fill(day) - await page.getByPlaceholder('mm').fill(month) - await page.getByPlaceholder('yyyy').fill(year) - await expect( - page.getByText('Required for registration. Enter a valid date', { - exact: true - }) - ).toBeVisible() + await page.getByPlaceholder('dd').fill(dd) + await page.getByPlaceholder('mm').fill(mm) + await page.getByPlaceholder('yyyy').fill(yyyy) + await page.locator('#typeOfMarriage').click() + await expect(page.locator('#marriageDate_error')).toHaveText( + 'Required for registration. Enter a valid date' + ) }) test('1.3. Keep field as null', async ({ page }) => { await page.getByText('Continue', { exact: true }).click() @@ -65,18 +58,18 @@ test.describe('6. Validate Marriage details page', () => { await page.getByText('Continue', { exact: true }).click() await page.getByText('Continue', { exact: true }).click() await expect( - page.getByText('Required for registration', { + page.getByText('Required for registration. Enter a valid date', { exact: true }) ).toBeVisible() }) - // Jostain syystä validation errorit ei tule näkyviin. test('1.4. Enter date Less than the current date But before Groom and Bride DOB', async ({ page }) => { await page.getByPlaceholder('dd').fill('01') await page.getByPlaceholder('mm').fill('05') await page.getByPlaceholder('yyyy').fill('1980') + await page.locator('#typeOfMarriage').click() await expect( page.getByText('Illegal age of marriage', { exact: true @@ -86,17 +79,76 @@ test.describe('6. Validate Marriage details page', () => { test('2.1. Select any country from the "Country" dropdown field, Default value is Farajaland', async ({ page - }) => {}) + }) => { + await expect(page.getByText('Farajaland', { exact: true })).toBeVisible() + await page.locator('#countryPlaceofmarriage').click() + await page.getByText('Estonia', { exact: true }).click() + await expect( + page.getByText('Estonia', { + exact: true + }) + ).toBeVisible() + }) test('2.2. Select any Province from "Province" dropdown field, Default value is Central', async ({ page - }) => {}) + }) => { + await expect(page.getByText('Central', { exact: true })).toBeVisible() + await page.locator('#statePlaceofmarriage').click() + await page.getByText('Sulaka', { exact: true }).click() + await expect( + page.getByText('Sulaka', { + exact: true + }) + ).toBeVisible() + }) test('2.3. Select any district from "District" dropdown field, Default value is Ibombo', async ({ page - }) => {}) - test('2.4. Select Urban address', async ({ page }) => {}) - test('2.5. Select Rural address', async ({ page }) => {}) + }) => { + await expect(page.getByText('Ibombo', { exact: true })).toBeVisible() + await page.locator('#districtPlaceofmarriage').click() + await page.getByText('Isamba', { exact: true }).click() + await expect( + page.getByText('Isamba', { + exact: true + }) + ).toBeVisible() + }) + // Kesken + test('2.4. Select Urban address', async ({ page }) => { + const townValue = 'My town' + const residentalAreaValue = 'My residential area' + const streetValue = 'My street' + const phoneValue = '09123456' + const postalCodeValue = '00120' + await page.locator("[name='cityPlaceofmarriage']").fill(townValue) + await page + .locator("[name='addressLine1UrbanOptionPlaceofmarriage']") + .fill(residentalAreaValue) + await page + .locator("[name='addressLine2UrbanOptionPlaceofmarriage']") + .fill(streetValue) + await page + .locator("[name='addressLine3UrbanOptionPlaceofmarriage']") + .fill(phoneValue) + await page + .locator("[name='postalCodePlaceofmarriage']") + .fill(postalCodeValue) + }) + test('2.5. Select Rural address', async ({ page }) => { + await page.getByText('Rural', { exact: true }).click() + await page + .locator('#addressLine1RuralOptionPlaceofmarriage') + .fill('My village') + }) test('3 Select any of the following options from Type of marriage dropdown', async ({ page - }) => {}) - test('4 Navigate to Witness 1 details page', async ({ page }) => {}) + }) => { + await page.locator('#typeOfMarriage').click() + await page.getByText('Polygamous', { exact: true }).click() + await expect(page.getByText('Polygamous', { exact: true })).toBeVisible() + await page.getByText('Continue', { exact: true }).click() + await expect( + page.getByText('Witness 1 details', { exact: true }) + ).toBeVisible() + }) }) From cab7b8afbb135396a94a6cc2b70d5c77e2785abf Mon Sep 17 00:00:00 2001 From: Eezi Date: Sat, 8 Jun 2024 08:28:03 +0300 Subject: [PATCH 03/10] Changed the error text selector to id since the review page has many exactly the same error messages. --- e2e/testcases/marriage/details-page-validation.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index c479f244c..8d963fc26 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -58,9 +58,7 @@ test.describe('6. Validate Marriage details page', () => { await page.getByText('Continue', { exact: true }).click() await page.getByText('Continue', { exact: true }).click() await expect( - page.getByText('Required for registration. Enter a valid date', { - exact: true - }) + page.locator('#required_label_marriageEvent_marriageDate') ).toBeVisible() }) test('1.4. Enter date Less than the current date But before Groom and Bride DOB', async ({ From 412f3e1b9331e1fe5c320607255ab9eb29603ddc Mon Sep 17 00:00:00 2001 From: Eezi Date: Sat, 8 Jun 2024 19:03:11 +0300 Subject: [PATCH 04/10] Changed the error message catch for test 1.4. --- e2e/testcases/marriage/details-page-validation.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index 8d963fc26..ef6e45873 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -69,9 +69,7 @@ test.describe('6. Validate Marriage details page', () => { await page.getByPlaceholder('yyyy').fill('1980') await page.locator('#typeOfMarriage').click() await expect( - page.getByText('Illegal age of marriage', { - exact: true - }) + page.locator('#marriageDate_error').getByText('Illegal age of marriage') ).toBeVisible() }) From 3671d4be0053be74aa6419d6247c16265e74c7f9 Mon Sep 17 00:00:00 2001 From: Eezi Date: Sun, 9 Jun 2024 09:02:54 +0300 Subject: [PATCH 05/10] Fix(1.4.): Fixed the invalid marriageDate test --- e2e/testcases/marriage/details-page-validation.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index ef6e45873..21bd7ee57 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -67,10 +67,10 @@ test.describe('6. Validate Marriage details page', () => { await page.getByPlaceholder('dd').fill('01') await page.getByPlaceholder('mm').fill('05') await page.getByPlaceholder('yyyy').fill('1980') - await page.locator('#typeOfMarriage').click() - await expect( - page.locator('#marriageDate_error').getByText('Illegal age of marriage') - ).toBeVisible() + await page.getByText('Marriage details').click() + await expect(page.locator('#marriageDate_error')).toHaveText( + 'Illegal age of marriage' + ) }) test('2.1. Select any country from the "Country" dropdown field, Default value is Farajaland', async ({ From 190bf9ef9218b1a70a80557ee0f5aeb696d1e77b Mon Sep 17 00:00:00 2001 From: Eezi Date: Sun, 9 Jun 2024 20:39:22 +0300 Subject: [PATCH 06/10] fix(1.4.): Changed the text selctor to be id --- e2e/testcases/marriage/details-page-validation.spec.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index 21bd7ee57..460968ec3 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -66,11 +66,9 @@ test.describe('6. Validate Marriage details page', () => { }) => { await page.getByPlaceholder('dd').fill('01') await page.getByPlaceholder('mm').fill('05') - await page.getByPlaceholder('yyyy').fill('1980') + await page.getByPlaceholder('yyyy').fill('1960') await page.getByText('Marriage details').click() - await expect(page.locator('#marriageDate_error')).toHaveText( - 'Illegal age of marriage' - ) + await expect(page.locator('#marriageDate_error')).toBeVisible() }) test('2.1. Select any country from the "Country" dropdown field, Default value is Farajaland', async ({ From bc43c461f35688601f627c11196913e036ae2e35 Mon Sep 17 00:00:00 2001 From: Eezi Date: Tue, 11 Jun 2024 19:15:43 +0300 Subject: [PATCH 07/10] Removed comment --- e2e/testcases/marriage/details-page-validation.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index 460968ec3..377148568 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -107,7 +107,6 @@ test.describe('6. Validate Marriage details page', () => { }) ).toBeVisible() }) - // Kesken test('2.4. Select Urban address', async ({ page }) => { const townValue = 'My town' const residentalAreaValue = 'My residential area' From 173770472d8b819fe6a58280aeb22353a20519ad Mon Sep 17 00:00:00 2001 From: Eezi Date: Sat, 6 Jul 2024 11:57:18 +0300 Subject: [PATCH 08/10] Added goToSection helper method --- e2e/helpers.ts | 19 +++++++++++++++++++ .../7-validate-witness-2-page.spec.ts | 1 + .../marriage/details-page-validation.spec.ts | 7 ++----- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 e2e/testcases/marriage/7-validate-witness-2-page.spec.ts diff --git a/e2e/helpers.ts b/e2e/helpers.ts index a768d6132..489202c14 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -45,6 +45,25 @@ async function getToken(username: string, password: string) { return verifyBody.token } +type DeclarationSection = + | 'child' + | 'informant' + | 'father' + | 'mother' + | 'documents' + | 'preview' + | 'groom' + | 'bride' + | 'marriageEvent' + | 'witnessOne' + | 'witnessTwo' + +export const goToSection = async (page: Page, section: DeclarationSection) => { + while (!page.url().includes(section)) { + await page.getByRole('button', { name: 'Continue' }).click() + } +} + export async function ensureLoginPageReady(page: Page) { /* * Wait until config for loading page has been loaded diff --git a/e2e/testcases/marriage/7-validate-witness-2-page.spec.ts b/e2e/testcases/marriage/7-validate-witness-2-page.spec.ts new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/e2e/testcases/marriage/7-validate-witness-2-page.spec.ts @@ -0,0 +1 @@ + diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index 377148568..c070bc996 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -1,5 +1,5 @@ import { expect, test } from '@playwright/test' -import { createPIN, login } from '../../helpers' +import { createPIN, goToSection, login } from '../../helpers' test.describe('6. Validate Marriage details page', () => { test.beforeEach(async ({ page }) => { @@ -53,10 +53,7 @@ test.describe('6. Validate Marriage details page', () => { ) }) test('1.3. Keep field as null', async ({ page }) => { - await page.getByText('Continue', { exact: true }).click() - await page.getByText('Continue', { exact: true }).click() - await page.getByText('Continue', { exact: true }).click() - await page.getByText('Continue', { exact: true }).click() + goToSection(page, 'preview') await expect( page.locator('#required_label_marriageEvent_marriageDate') ).toBeVisible() From 8c9114c24cc9ed93505c9018f376e8ef67eabcc6 Mon Sep 17 00:00:00 2001 From: Eezi Date: Sat, 6 Jul 2024 11:58:58 +0300 Subject: [PATCH 09/10] Removed witness-2 test file --- e2e/testcases/marriage/7-validate-witness-2-page.spec.ts | 1 - 1 file changed, 1 deletion(-) delete mode 100644 e2e/testcases/marriage/7-validate-witness-2-page.spec.ts diff --git a/e2e/testcases/marriage/7-validate-witness-2-page.spec.ts b/e2e/testcases/marriage/7-validate-witness-2-page.spec.ts deleted file mode 100644 index 8b1378917..000000000 --- a/e2e/testcases/marriage/7-validate-witness-2-page.spec.ts +++ /dev/null @@ -1 +0,0 @@ - From 2a12d26847db80f9d7881d753b92b96866da80c7 Mon Sep 17 00:00:00 2001 From: Tomi Salo <54830004+Eezi@users.noreply.github.com> Date: Thu, 18 Jul 2024 07:37:03 +0300 Subject: [PATCH 10/10] Update e2e/testcases/marriage/details-page-validation.spec.ts Co-authored-by: Jamil --- e2e/testcases/marriage/details-page-validation.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/testcases/marriage/details-page-validation.spec.ts b/e2e/testcases/marriage/details-page-validation.spec.ts index c070bc996..b15e8a19b 100644 --- a/e2e/testcases/marriage/details-page-validation.spec.ts +++ b/e2e/testcases/marriage/details-page-validation.spec.ts @@ -53,7 +53,7 @@ test.describe('6. Validate Marriage details page', () => { ) }) test('1.3. Keep field as null', async ({ page }) => { - goToSection(page, 'preview') + await goToSection(page, 'preview') await expect( page.locator('#required_label_marriageEvent_marriageDate') ).toBeVisible()