From db0bd840a2c1488e77b4b61a5e29b6cb720172a4 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 22 Nov 2024 12:43:21 +0600 Subject: [PATCH 1/4] fix: increase randomness in correction-death dates --- e2e/helpers.ts | 11 ++++++++--- .../correction-death/correct-death-record-11.spec.ts | 1 - e2e/testcases/death/helpers.ts | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/e2e/helpers.ts b/e2e/helpers.ts index ba5771db2..01e835b9a 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -80,16 +80,21 @@ export const goToSection = async ( /* Generates a random past date - at least 'minAge' years ago + at least 'minAge' years + 'offset' days ago and up to an additional 'range' days earlier */ -export const getRandomDate = (minAge: number, range: number) => { +export const getRandomDate = ( + minAge: number, + range: number, + offset: number = 0 +) => { const randomDate = new Date() randomDate.setDate( new Date().getDate() - Math.random() * range - minAge * 365 - - (minAge + 3) / 4 + (minAge + 3) / 4 - + offset ) const [yyyy, mm, dd] = randomDate.toISOString().split('T')[0].split('-') return { dd, mm, yyyy } diff --git a/e2e/testcases/correction-death/correct-death-record-11.spec.ts b/e2e/testcases/correction-death/correct-death-record-11.spec.ts index a87d614a1..376035810 100644 --- a/e2e/testcases/correction-death/correct-death-record-11.spec.ts +++ b/e2e/testcases/correction-death/correct-death-record-11.spec.ts @@ -1,7 +1,6 @@ import { expect, test, type Page } from '@playwright/test' import { assignRecord, - // assignRecord, createPIN, expectOutboxToBeEmpty, formatDateTo_ddMMMMyyyy, diff --git a/e2e/testcases/death/helpers.ts b/e2e/testcases/death/helpers.ts index 40ba9c982..c5a000219 100644 --- a/e2e/testcases/death/helpers.ts +++ b/e2e/testcases/death/helpers.ts @@ -59,7 +59,7 @@ const declaration = { }, event: { manner: 'Natural causes', - date: getRandomDate(0, 20), + date: getRandomDate(0, 20, 20), cause: { established: true, source: 'Physician' @@ -73,7 +73,7 @@ const declaration = { firstNames: faker.name.firstName('female'), familyName: faker.name.lastName('female') }, - birthDate: getRandomDate(50, 200), + birthDate: getRandomDate(50, 200, 200), nationality: 'Farajaland', identifier: { id: faker.random.numeric(10), From 74264a2082e0f5b3da8c314a9de51e0dbd61947d Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 22 Nov 2024 12:44:02 +0600 Subject: [PATCH 2/4] feat: save trace on failure --- playwright.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 81f140304..3f209c682 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -27,8 +27,8 @@ export default defineConfig({ // baseURL: 'http://127.0.0.1:3000', /* Capture screenshot on failure */ screenshot: 'only-on-failure', - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry' + /* Collect trace when the test failed. See https://playwright.dev/docs/trace-viewer */ + trace: 'retain-on-failure' }, /* Configure projects for major browsers */ From 70b824f6afea3578249cdc99ca7187a08baba6ef Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 22 Nov 2024 12:50:29 +0600 Subject: [PATCH 3/4] fix: make matching more flexible for in progress --- e2e/testcases/birth/1-birth-event-declaration.spec.ts | 6 +++--- e2e/testcases/death/1-death-event-declaration.spec.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/testcases/birth/1-birth-event-declaration.spec.ts b/e2e/testcases/birth/1-birth-event-declaration.spec.ts index 56eb5cf62..99107e4e0 100644 --- a/e2e/testcases/birth/1-birth-event-declaration.spec.ts +++ b/e2e/testcases/birth/1-birth-event-declaration.spec.ts @@ -430,7 +430,7 @@ test.describe('1. Birth event declaration', () => { * - find the declared birth 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() + await expect(page.getByText(/seconds ago/)).toBeVisible() }) }) }) @@ -491,7 +491,7 @@ test.describe('1. Birth event declaration', () => { await expect( page.locator('#content-name', { hasText: 'In progress' }) ).toBeVisible() - await expect(page.getByText('0 seconds ago')).toBeHidden() + await expect(page.getByText(/seconds ago/)).toBeHidden() }) }) @@ -560,7 +560,7 @@ test.describe('1. Birth event declaration', () => { await expect( page.locator('#content-name', { hasText: 'In progress' }) ).toBeVisible() - await expect(page.getByText('0 seconds ago')).toBeHidden() + await expect(page.getByText(/seconds ago/)).toBeHidden() }) }) diff --git a/e2e/testcases/death/1-death-event-declaration.spec.ts b/e2e/testcases/death/1-death-event-declaration.spec.ts index 064fca85b..1f9d2e9c5 100644 --- a/e2e/testcases/death/1-death-event-declaration.spec.ts +++ b/e2e/testcases/death/1-death-event-declaration.spec.ts @@ -410,7 +410,7 @@ test.describe('1. Death event declaration', () => { * - 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() + await expect(page.getByText(/seconds ago/)).toBeVisible() }) }) }) @@ -471,7 +471,7 @@ test.describe('1. Death event declaration', () => { await expect( page.locator('#content-name', { hasText: 'In progress' }) ).toBeVisible() - await expect(page.getByText('0 seconds ago')).toBeHidden() + await expect(page.getByText(/seconds ago/)).toBeHidden() }) }) @@ -540,7 +540,7 @@ test.describe('1. Death event declaration', () => { await expect( page.locator('#content-name', { hasText: 'In progress' }) ).toBeVisible() - await expect(page.getByText('0 seconds ago')).toBeHidden() + await expect(page.getByText(/seconds ago/)).toBeHidden() }) }) From 4ba317c0cdf2ec836060582e7bcfcadce8755d0b Mon Sep 17 00:00:00 2001 From: jamil314 Date: Fri, 22 Nov 2024 13:16:12 +0600 Subject: [PATCH 4/4] feat: make playwright report name more precise --- .github/workflows/deploy-and-e2e.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-and-e2e.yml b/.github/workflows/deploy-and-e2e.yml index 8234c835a..2c2308e5c 100644 --- a/.github/workflows/deploy-and-e2e.yml +++ b/.github/workflows/deploy-and-e2e.yml @@ -89,7 +89,7 @@ jobs: echo "test_matrix=$test_dirs" test: - needs: [deploy, discover-tests] + needs: [deploy, discover-tests, get-core-commit, get-country-config-commit] runs-on: ubuntu-22.04 environment: ${{ github.event.inputs.environment || 'development' }} strategy: @@ -138,7 +138,11 @@ jobs: - uses: actions/upload-artifact@v4 if: always() && steps.check-specs.outputs.has_spec_files == 'true' with: - name: playwright-report-${{ matrix.test_dir }} + name: >- + playwright-report- + ${{ github.event.inputs.core-image-tag || needs.get-core-commit.outputs.latest_commit_sha }}- + ${{ github.event.inputs.countryconfig-image-tag || needs.get-country-config-commit.outputs.short_sha }}- + ${{ matrix.test_dir }} path: playwright-report/ retention-days: 30