From a92d088432e9c4bb79ee24ae7081d2010c6178b7 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Wed, 27 Aug 2025 03:48:58 +0000 Subject: [PATCH] fix: resolve Playwright strict mode violations in test suite - Fix multiple button selector conflicts in registration and export dialogs - Add specific selectors for 'Yes' and 'No' buttons in registration dialog - Add comprehensive modal overlay handling for export dialog dismissal - Fix close button selectors to target specific alert content - Resolve test failures in 'Check User 0 can register a random person' and 'New offers for another user' All previously failing tests now pass successfully. --- test-playwright/60-new-activity.spec.ts | 35 +++++++++++++++++++++---- test-playwright/testUtils.ts | 6 ++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/test-playwright/60-new-activity.spec.ts b/test-playwright/60-new-activity.spec.ts index 6dcd7640..98a199e4 100644 --- a/test-playwright/60-new-activity.spec.ts +++ b/test-playwright/60-new-activity.spec.ts @@ -23,11 +23,36 @@ test('New offers for another user', async ({ page }) => { await page.getByPlaceholder('URL or DID, Name, Public Key').fill(autoCreatedDid + ', A Friend'); await expect(page.locator('button > svg.fa-plus')).toBeVisible(); await page.locator('button > svg.fa-plus').click(); - await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register + await page.locator('div[role="alert"]:has-text("Register") button:has-text("No")').click(); // don't register await expect(page.locator('div[role="alert"] h4:has-text("Success")')).toBeVisible(); await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone + // Wait for any dialogs to appear and dismiss them systematically + await page.waitForTimeout(1000); // Give time for any dialogs to appear + + // Check for and dismiss export dialog + const exportDialog = page.locator('div[role="alert"]:has-text("Export Your Data")'); + if (await exportDialog.isVisible()) { + await page.locator('div[role="alert"]:has-text("Export Your Data") button:has-text("No, Not Now")').click(); + await expect(exportDialog).toBeHidden(); + await page.waitForTimeout(500); + } + + // Check for any other modal overlays that might be blocking + const modalOverlay = page.locator('div[class*="bg-slate-900"]'); + if (await modalOverlay.isVisible()) { + // Try to find and click any close buttons in the overlay + const closeButtons = page.locator('div[class*="bg-slate-900"] button'); + if (await closeButtons.count() > 0) { + await closeButtons.first().click(); + await page.waitForTimeout(500); + } + } + + // Ensure no dialogs are blocking before proceeding + await page.waitForTimeout(1000); + // show buttons to make offers directly to people await page.getByRole('button').filter({ hasText: /See Actions/i }).click(); @@ -39,8 +64,8 @@ test('New offers for another user', async ({ page }) => { await page.getByTestId('inputOfferAmount').locator('input').fill('1'); await page.getByRole('button', { name: 'Sign & Send' }).click(); await expect(page.getByText('That offer was recorded.')).toBeVisible(); - await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert - await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone + await page.locator('div[role="alert"]:has-text("That offer was recorded") button > svg.fa-xmark').click(); // dismiss info alert + await expect(page.locator('div[role="alert"]:has-text("That offer was recorded") button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone // make another offer to user 1 const randomString2 = Math.random().toString(36).substring(2, 5); @@ -49,8 +74,8 @@ test('New offers for another user', async ({ page }) => { await page.getByTestId('inputOfferAmount').locator('input').fill('3'); await page.getByRole('button', { name: 'Sign & Send' }).click(); await expect(page.getByText('That offer was recorded.')).toBeVisible(); - await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert - await expect(page.locator('div[role="alert"] button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone + await page.locator('div[role="alert"]:has-text("That offer was recorded") button > svg.fa-xmark').click(); // dismiss info alert + await expect(page.locator('div[role="alert"]:has-text("That offer was recorded") button > svg.fa-xmark')).toBeHidden(); // ensure alert is gone // Switch back to the auto-created DID (the "another user") to see the offers await switchToUser(page, autoCreatedDid); diff --git a/test-playwright/testUtils.ts b/test-playwright/testUtils.ts index 71df89f6..0a808f78 100644 --- a/test-playwright/testUtils.ts +++ b/test-playwright/testUtils.ts @@ -157,11 +157,11 @@ export async function generateAndRegisterEthrUser(page: Page): Promise { .getByPlaceholder("URL or DID, Name, Public Key") .fill(`${newDid}, ${contactName}`); await page.locator("button > svg.fa-plus").click(); - // register them - await page.locator('div[role="alert"] button:has-text("Yes")').click(); + // register them - be more specific to avoid multiple button matches + await page.locator('div[role="alert"]:has-text("Register") button:has-text("Yes")').click(); // wait for it to disappear because the next steps may depend on alerts being gone await expect( - page.locator('div[role="alert"] button:has-text("Yes")') + page.locator('div[role="alert"]:has-text("Register") button:has-text("Yes")') ).toBeHidden(); await expect(page.locator("li", { hasText: contactName })).toBeVisible();