Skip to content

Commit

Permalink
fix: align e2e with action-menu (#1135)
Browse files Browse the repository at this point in the history
* fix: click action buttons from menu

* fix: correction-birth

* fix: correction-death

* fix: application

* fix: birth

* fix: death

* fix: marriage

* fix: helpers

* chore: update playwright

* fix: select first button for action button

* fix: click the correct queue again after outbox is empty

* e2e: opt out of retry when e2e is run on CI

* fix: use exact flag for partial names

* feat:e2e: capture screenshot on failure

* Revert "feat:e2e: capture screenshot on failure"

This reverts commit 89b529d because it had some extra changes.

* feat:e2e: capture screenshot on failure

* fix(tests): vitest tried to run playwright tests

---------

Co-authored-by: Riku Rouvila <riku.rouvila@gmail.com>
  • Loading branch information
jamil314 and rikukissa authored Oct 29, 2024
1 parent 7623c34 commit 2768c62
Show file tree
Hide file tree
Showing 47 changed files with 791 additions and 221 deletions.
2 changes: 1 addition & 1 deletion e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export async function validateSectionButtons(page: Page) {
await expect(page.getByText('Continue', { exact: true })).toBeVisible()
await expect(page.getByText('Exit', { exact: true })).toBeVisible()
await expect(page.getByText('Save & Exit', { exact: true })).toBeVisible()
await expect(page.locator('#eventToggleMenuToggleButton')).toBeVisible()
await expect(page.locator('#eventToggleMenu-dropdownMenu')).toBeVisible()
}

export const uploadImage = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,70 @@ test.describe
/*
* Expected result: should
* - Navigate to record audit page
* - Not show correct recort optoin
* - Print button should be disabled
* - Correct record option should be disabled
* - Print option should be disabled
*/
await page.getByRole('button', { name: 'Action' }).first().click()

await expect(
page.getByRole('button', { name: 'Correct record' })
).not.toBeVisible()
page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Correct Record/
})
).toHaveAttribute('disabled')

await expect(
page.getByRole('button', { name: 'Print', exact: true })
).toBeDisabled()
page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Print certified copy/
})
).toHaveAttribute('disabled')

expect(page.url().includes('record-audit'))
})

test('17.2 Click download > click assign', async () => {
await page.getByLabel('Assign record').click()
await page.getByRole('button', { name: 'Assign', exact: true }).click()

await page.getByRole('button', { name: 'Action' }).first().click()

/*
* Expected result: should
* - Show correct recort optoin
* - Print button should not be disabled
* - Correct record option should not be disabled
* - Print option should not be disabled
*/
await expect(
page.getByRole('button', { name: 'Correct record' })
).toBeVisible()
page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Correct Record/
})
).not.toHaveAttribute('disabled')

await expect(
page.getByRole('button', { name: 'Print', exact: true })
).not.toBeDisabled()
page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Print certified copy/
})
).not.toHaveAttribute('disabled')
})

test('17.3 Click "Correct record"', async () => {
await page.getByRole('button', { name: 'Correct record' }).click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Correct Record/
})
.click()

/*
* Expected result: should show correct record page
Expand Down
48 changes: 34 additions & 14 deletions e2e/testcases/birth/1-birth-event-declaration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ test.describe('1. Birth event declaration', () => {
page.getByRole('button', { name: 'Save & Exit' })
).toBeVisible()

await page.locator('#eventToggleMenuToggleButton').click()
await page.locator('#eventToggleMenu-dropdownMenu').click()
await expect(
page.getByRole('button', { name: 'Delete declaration' })
page
.locator('#eventToggleMenu-dropdownMenu')
.getByRole('listitem')
.filter({ hasText: 'Delete declaration' })
).toBeVisible()
})

Expand Down Expand Up @@ -157,9 +160,12 @@ test.describe('1. Birth event declaration', () => {
page.getByRole('button', { name: 'Save & Exit' })
).toBeVisible()

await page.locator('#eventToggleMenuToggleButton').click()
await page.locator('#eventToggleMenu-dropdownMenu').click()
await expect(
page.getByRole('button', { name: 'Delete declaration' })
page
.locator('#eventToggleMenu-dropdownMenu')
.getByRole('listitem')
.filter({ hasText: 'Delete declaration' })
).toBeVisible()
})

Expand Down Expand Up @@ -199,9 +205,12 @@ test.describe('1. Birth event declaration', () => {
await expect(
page.getByRole('button', { name: 'Save & Exit' })
).toBeVisible()
await page.locator('#eventToggleMenuToggleButton').click()
await page.locator('#eventToggleMenu-dropdownMenu').click()
await expect(
page.getByRole('button', { name: 'Delete declaration' })
page
.locator('#eventToggleMenu-dropdownMenu')
.getByRole('listitem')
.filter({ hasText: 'Delete declaration' })
).toBeVisible()
})

Expand Down Expand Up @@ -257,9 +266,12 @@ test.describe('1. Birth event declaration', () => {
await expect(
page.getByRole('button', { name: 'Save & Exit' })
).toBeVisible()
await page.locator('#eventToggleMenuToggleButton').click()
await page.locator('#eventToggleMenu-dropdownMenu').click()
await expect(
page.getByRole('button', { name: 'Delete declaration' })
page
.locator('#eventToggleMenu-dropdownMenu')
.getByRole('listitem')
.filter({ hasText: 'Delete declaration' })
).toBeVisible()
})

Expand Down Expand Up @@ -300,9 +312,12 @@ test.describe('1. Birth event declaration', () => {
await expect(
page.getByRole('button', { name: 'Save & Exit' })
).toBeVisible()
await page.locator('#eventToggleMenuToggleButton').click()
await page.locator('#eventToggleMenu-dropdownMenu').click()
await expect(
page.getByRole('button', { name: 'Delete declaration' })
page
.locator('#eventToggleMenu-dropdownMenu')
.getByRole('listitem')
.filter({ hasText: 'Delete declaration' })
).toBeVisible()
})

Expand Down Expand Up @@ -343,9 +358,12 @@ test.describe('1. Birth event declaration', () => {
await expect(
page.getByRole('button', { name: 'Save & Exit' })
).toBeVisible()
await page.locator('#eventToggleMenuToggleButton').click()
await page.locator('#eventToggleMenu-dropdownMenu').click()
await expect(
page.getByRole('button', { name: 'Delete declaration' })
page
.locator('#eventToggleMenu-dropdownMenu')
.getByRole('listitem')
.filter({ hasText: 'Delete declaration' })
).toBeVisible()
})

Expand Down Expand Up @@ -489,9 +507,11 @@ test.describe('1. Birth event declaration', () => {
await page.getByLabel('Birth').click()
await page.getByRole('button', { name: 'Continue' }).click()

await page.locator('#eventToggleMenuToggleButton').click()
await page.locator('#eventToggleMenu-dropdownMenu').click()
await page
.getByRole('button', { name: 'Delete declaration', exact: true })
.locator('#eventToggleMenu-dropdownMenu')
.getByRole('listitem')
.filter({ hasText: 'Delete declaration' })
.click()
})

Expand Down
26 changes: 21 additions & 5 deletions e2e/testcases/birth/8-validate-declaration-review-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ test.describe.serial('8. Validate declaration review page', () => {
*/
expect(page.url().includes('registration-home')).toBeTruthy()

await page.getByRole('button', { name: 'Sent for review' }).click()
await expectOutboxToBeEmpty(page)
await page.getByRole('button', { name: 'Sent for review' }).click()
/*
* Expected result: The declaration should be in sent for review
*/
Expand Down Expand Up @@ -896,7 +896,15 @@ test.describe.serial('8. Validate declaration review page', () => {
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Review declaration/
})
.click()
})
test('8.2.1.1 Verify information added on previous pages', async () => {
/*
Expand Down Expand Up @@ -1120,8 +1128,8 @@ test.describe.serial('8. Validate declaration review page', () => {
*/
expect(page.url().includes('registration-home')).toBeTruthy()

await page.getByRole('button', { name: 'Sent for approval' }).click()
await expectOutboxToBeEmpty(page)
await page.getByRole('button', { name: 'Sent for approval' }).click()

/*
* Expected result: The declaration should be in sent for approval
Expand Down Expand Up @@ -1150,7 +1158,15 @@ test.describe.serial('8. Validate declaration review page', () => {
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Review declaration/
})
.click()
})
test('8.3.1.1 Verify information added on previous pages', async () => {
/*
Expand Down Expand Up @@ -1398,8 +1414,8 @@ test.describe.serial('8. Validate declaration review page', () => {
*/
expect(page.url().includes('registration-home')).toBeTruthy()

await page.getByRole('button', { name: 'Ready to print' }).click()
await expectOutboxToBeEmpty(page)
await page.getByRole('button', { name: 'Ready to print' }).click()

/*
* Expected result: The declaration should be in Ready to print
Expand Down
10 changes: 9 additions & 1 deletion e2e/testcases/birth/declarations/birth-declaration-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,15 @@ test.describe.serial('1. Birth declaration case - 1', () => {
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Review declaration/
})
.click()
})

test('1.2.2 Verify information on review page', async () => {
Expand Down
16 changes: 13 additions & 3 deletions e2e/testcases/birth/declarations/birth-declaration-10.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ test.describe.serial('10. Birth declaration case - 10', () => {
*/
await expect(
page.getByRole('button', {
name: `${declaration.child.name.firstNames}`
name: `${declaration.child.name.firstNames}`,
exact: true
})
).toBeVisible()
})
Expand All @@ -219,12 +220,21 @@ test.describe.serial('10. Birth declaration case - 10', () => {
await page.getByRole('button', { name: 'Field Agents' }).click()
await page
.getByRole('button', {
name: `${declaration.child.name.firstNames}`
name: `${declaration.child.name.firstNames}`,
exact: true
})
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Update declaration/
})
.click()
})

test('10.2.2 Verify information on preview page', async () => {
Expand Down
10 changes: 9 additions & 1 deletion e2e/testcases/birth/declarations/birth-declaration-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,15 @@ test.describe.serial('2. Birth declaration case - 2', () => {
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Review declaration/
})
.click()
})

test('2.2.2 Verify information on review page', async () => {
Expand Down
10 changes: 9 additions & 1 deletion e2e/testcases/birth/declarations/birth-declaration-3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,15 @@ test.describe.serial('3. Birth declaration case - 3', () => {
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Review declaration/
})
.click()
})

test('3.2.2 Verify information on review page', async () => {
Expand Down
10 changes: 9 additions & 1 deletion e2e/testcases/birth/declarations/birth-declaration-4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,15 @@ test.describe.serial('4. Birth declaration case - 4', () => {
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Review declaration/
})
.click()
})

test('4.2.2 Verify information on review page', async () => {
Expand Down
10 changes: 9 additions & 1 deletion e2e/testcases/birth/declarations/birth-declaration-7.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,15 @@ test.describe.serial('7. Birth declaration case - 7', () => {
.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()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Update declaration/
})
.click()
})

test('7.2.2 Verify information on preview page', async () => {
Expand Down
10 changes: 9 additions & 1 deletion e2e/testcases/birth/declarations/birth-declaration-8.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,15 @@ test.describe.serial('8. Birth declaration case - 8', () => {

await page.getByLabel('Assign record').click()
await page.getByRole('button', { name: 'Assign', exact: true }).click()
await page.getByRole('button', { name: 'Update', exact: true }).click()

await page.getByRole('button', { name: 'Action' }).first().click()
await page
.locator('#action-dropdownMenu')
.getByRole('listitem')
.filter({
hasText: /Update declaration/
})
.click()
})

test('8.2.2 Verify information on preview page', async () => {
Expand Down
Loading

0 comments on commit 2768c62

Please sign in to comment.