Chore(UI): Fix flakiness in AutoPilot and ServiceEntity#27226
Chore(UI): Fix flakiness in AutoPilot and ServiceEntity#27226aniketkatkar97 merged 9 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Improves Playwright test stability by tightening navigation and toast-notification waits in shared utilities.
Changes:
- Update
redirectToHomePageto navigate withwaitUntil: 'domcontentloaded'before continuing. - Update
toastNotificationto wait for the specific alert-bar content matching the provided message (and forward the optionaltimeout).
| timeout?: number | ||
| ) => { | ||
| await page.getByTestId('alert-bar').waitFor({ | ||
| await page.getByTestId('alert-bar').getByText(message).waitFor({ |
There was a problem hiding this comment.
toastNotification now uses getByText(message) which does substring matching by default for string messages. This reduces assertion specificity compared to the previous toHaveText check and can allow the helper to pass even when the toast text contains additional/unexpected content. Consider using exact matching for string messages (e.g., getByText(message, { exact: true }) when typeof message === 'string') or otherwise restoring an explicit assertion that the visible toast message matches the expected text.
| await page.getByTestId('alert-bar').getByText(message).waitFor({ | |
| const alertBar = page.getByTestId('alert-bar'); | |
| const toastMessage = | |
| typeof message === 'string' | |
| ? alertBar.getByText(message, { exact: true }) | |
| : alertBar.getByText(message); | |
| await toastMessage.waitFor({ |
Code Review ✅ ApprovedStabilizes UI test execution for AutoPilot and ServiceEntity components by addressing intermittent flakiness. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
🟡 Playwright Results — all passed (27 flaky)✅ 3629 passed · ❌ 0 failed · 🟡 27 flaky · ⏭️ 84 skipped
🟡 27 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
Changes have been cherry-picked to the 1.12.6 branch. |



This pull request makes targeted improvements to the Playwright utility functions in
common.tsto enhance test reliability and specificity. The main changes focus on improving page navigation and toast notification handling.Navigation improvements:
redirectToHomePageto usewaitUntil: 'domcontentloaded'when navigating to the home page, ensuring the DOM is loaded before proceeding.Toast notification handling:
toastNotificationto wait specifically for the alert bar containing the provided message text, and to pass through the optional timeout parameter for more precise test control. Removed redundant checks for the alert bar text.