Skip to content

Commit 8676a9f

Browse files
authored
Fix flaky observability alerts navigation in Playwright. (#27574)
Use a predicate-based response wait for subscriptions and await URL navigation before the API wait to avoid race conditions while opening the alerts page. Made-with: Cursor
1 parent a2cf8d2 commit 8676a9f

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/utils/observabilityAlert.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,22 @@ export const visitObservabilityAlertPage = async (page: Page) => {
4848
await waitForAllLoadersToDisappear(page);
4949

5050
// Set up the response promise before navigation
51-
const getAlerts = page.waitForResponse(
52-
'/api/v1/events/subscriptions?*alertType=Observability*'
53-
);
51+
const getAlerts = page.waitForResponse((response) => {
52+
const url = response.url();
53+
return (
54+
url.includes('/api/v1/events/subscriptions') &&
55+
url.includes('alertType=Observability')
56+
);
57+
});
5458

5559
// Set up navigation promise before clicking
5660
const navigationPromise = page.waitForURL('**/observability/alerts');
5761

5862
await sidebarClick(page, SidebarItem.OBSERVABILITY_ALERT);
5963

6064
// Wait for both navigation and API response
61-
await Promise.all([navigationPromise, getAlerts]);
65+
await navigationPromise;
66+
await getAlerts;
6267
};
6368

6469
export const addExternalDestination = async ({

0 commit comments

Comments
 (0)