Skip to content

Commit 3d25a7f

Browse files
committed
Fix flaky phpMyAdmin test
1 parent 3a41c0d commit 3d25a7f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/playground/website/playwright/e2e/website-ui.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,18 +450,30 @@ test.describe('Database panel', () => {
450450
await expect(newPage.locator('body')).toContainText('phpMyAdmin');
451451
await expect(newPage.locator('body')).toContainText('wp_posts');
452452

453+
/*
454+
* Before navigating to a page in phpMyAdmin, we need to wait for jQuery
455+
* to be ready to prevent clicking a link before listeners are attached.
456+
* This prevents flaky tests (mainly in Firefox).
457+
*/
458+
const waitForAjaxHandlers = async () =>
459+
newPage.waitForFunction(
460+
() => (window as any)?.jQuery?.isReady ?? false
461+
);
462+
453463
// Browse the "wp_posts" table
454464
const wpPostsRow = newPage
455465
.locator('tr')
456466
.filter({ hasText: 'wp_posts' })
457467
.first();
458468
await expect(wpPostsRow).toBeVisible({ timeout: 10000 });
469+
await waitForAjaxHandlers();
459470
await wpPostsRow.getByRole('link', { name: 'Browse' }).click();
460471
await newPage.waitForLoadState();
461472
const pmaRows = newPage.locator('table.table_results tbody tr');
462473
await expect(pmaRows.first()).toContainText('Welcome to WordPress.');
463474

464475
// Click "edit" on a row
476+
await waitForAjaxHandlers();
465477
await pmaRows
466478
.first()
467479
.getByRole('link', { name: 'Edit' })

0 commit comments

Comments
 (0)