Summary of changes to include in the PR
- Increase timeouts for confirmation waits in e2e/tests/chat.spec.ts (20000 -> 30000 ms) to reduce CI flakiness.
- Improve HomePage confirmation helper implementations so they use robust Playwright locator wait/visibility APIs and return boolean with try/catch (suggested improvements).
- Add optional debug screenshot capture at assertion failure points (commented / optional).
Patch 1 — e2e/tests/chat.spec.ts
- Change waitForConfirmationMessage timeouts from 20000 to 30000 in two places.
Replace these lines:
- const confirmationAppeared = await homePage.waitForConfirmationMessage(20000);
- const confirmationAppeared1 = await homePage.waitForConfirmationMessage(20000);
- const confirmationAppeared2 = await homePage.waitForConfirmationMessage(20000);
With:
- const confirmationAppeared = await homePage.waitForConfirmationMessage(30000);
- const confirmationAppeared1 = await homePage.waitForConfirmationMessage(30000);
- const confirmationAppeared2 = await homePage.waitForConfirmationMessage(30000);
(Exact contexts: destructive operation test at ~line 240, duplicate record test at ~lines 279 and 286.)
Suggested diff (unified patch snippet)
--- a/e2e/tests/chat.spec.ts
+++ b/e2e/tests/chat.spec.ts
@@
- const confirmationAppeared = await homePage.waitForConfirmationMessage(20000);
- const confirmationAppeared = await homePage.waitForConfirmationMessage(30000);
@@
- const confirmationAppeared1 = await homePage.waitForConfirmationMessage(20000);
- const confirmationAppeared1 = await homePage.waitForConfirmationMessage(30000);
@@
- const confirmationAppeared2 = await homePage.waitForConfirmationMessage(20000);
- const confirmationAppeared2 = await homePage.waitForConfirmationMessage(30000);
Patch 2 — HomePage confirmation helpers (recommended)
- Ensure the HomePage methods use robust Playwright patterns: locator.waitFor({ state: 'visible', timeout }), try/catch, and explicit returns of boolean. Add slight polling/retry if needed.
Example implementation (file: e2e/logic/pom/homePage.ts) — adjust path if yours differs:
// Example implementations to add/update in HomePage
// Wait for a confirmation message to appear, return true if it appears within timeout
async waitForConfirmationMessage(timeout = 30000): Promise<boolean> {
try {
const confirmationLocator = this.page.locator('[data-test=confirmation-message]'); // adapt selector
await confirmationLocator.waitFor({ state: 'visible', timeout });
return true;
} catch (err) {
return false;
}
}
// Check visible state immediately (fast check)
async isConfirmationMessageVisible(): Promise<boolean> {
try {
const confirmationLocator = this.page.locator('[data-test=confirmation-message]'); // adapt selector
return await confirmationLocator.isVisible();
} catch (err) {
return false;
}
}
// Click confirm button with wait for it to be enabled & visible
async clickConfirmButton(): Promise<void> {
const confirmBtn = this.page.locator('[data-test=confirm-button]'); // adapt selector
await confirmBtn.waitFor({ state: 'visible', timeout: 5000 });
await confirmBtn.click();
}
Note: use the actual data-test selectors used by your app. If your UI doesn’t have test anchors, add data-test attributes to the confirmation dialog and confirm button to make tests more resilient and less brittle.
Optional: capture debug screenshot on assertion failures (helpful in CI)
- Add a helper in HomePage or in test after a failed assertion to capture page.screenshot({ path:
test-results/failed-${Date.now()}.png })
- Playwright’s reporter already uploads screenshots; but capturing them at specific points can help.
Branch, commit message, and PR metadata
- Branch name: fix/e2e-confirmation-timeouts
- Commit message: test(e2e): increase confirmation wait timeouts and harden confirmation helpers
- PR title: Fix Playwright E2E Chat confirmation & duplicate record timing flakiness
- PR description: list the summary above, mention CI job link you provided, and describe how the changes reduce flakiness and recommend adding test hooks (data-test attributes) if not present.
How to apply the changes locally and open a PR
- Create branch:
- git checkout -b fix/e2e-confirmation-timeouts
- Edit files:
- Apply the changes shown above to e2e/tests/chat.spec.ts
- Update HomePage implementation (e2e/logic/pom/homePage.ts) with the suggested robust wait/isVisible logic
- Run tests locally (fast subset) OR run the full Playwright suite:
- npx playwright test e2e/tests/chat.spec.ts --project=chromium
- or run complete suite: npx playwright test
- Commit and push:
- git add e2e/tests/chat.spec.ts e2e/logic/pom/homePage.ts
- git commit -m "test(e2e): increase confirmation wait timeouts and harden confirmation helpers"
- git push origin fix/e2e-confirmation-timeouts
- Open PR (target: staging)
- Using GitHub web UI or:
- gh pr create --base staging --head fix/e2e-confirmation-timeouts --title "Fix Playwright E2E Chat confirmation & duplicate record timing flakiness" --body "See CI run: . Increased timeouts and made confirmation code more robust."
- Or create via UI and paste the description.
Notes & next steps
- If flakiness persists after increasing timeout and hardening selectors, do:
- Inspect Playwright trace.zip from CI (playwright show-trace path) that was uploaded in the job artifacts to see what the UI looked like at the time of failure.
- Add explicit data-test attributes to the confirmation dialog and confirm button to reduce selector brittleness.
- If backend errors are swallowed, ensure the backend returns the duplicate error text and the frontend forwards it to the AI message area (so the duplicate test can assert on 'already exists' text). You may need to add a backend integration test or adjust error propagation.
Summary of changes to include in the PR
Patch 1 — e2e/tests/chat.spec.ts
Replace these lines:
With:
(Exact contexts: destructive operation test at ~line 240, duplicate record test at ~lines 279 and 286.)
Suggested diff (unified patch snippet)
--- a/e2e/tests/chat.spec.ts
+++ b/e2e/tests/chat.spec.ts
@@
@@
@@
Patch 2 — HomePage confirmation helpers (recommended)
Example implementation (file: e2e/logic/pom/homePage.ts) — adjust path if yours differs:
Note: use the actual data-test selectors used by your app. If your UI doesn’t have test anchors, add data-test attributes to the confirmation dialog and confirm button to make tests more resilient and less brittle.
Optional: capture debug screenshot on assertion failures (helpful in CI)
test-results/failed-${Date.now()}.png})Branch, commit message, and PR metadata
How to apply the changes locally and open a PR
Notes & next steps