Skip to content

Commit 018845c

Browse files
committed
Fix flaky E2E test by using fresh frame locator after navigation
The ZIP import tests were failing because after navigating the WordPress iframe to a marker page, the test was checking the body content immediately before navigation completed. Fixed by: - Using website.wordpress() instead of the wordpress fixture to get a fresh frame locator reference after navigation - Increasing the timeout to 30 seconds to allow for iframe navigation time
1 parent 3706052 commit 018845c

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

packages/playground/website/playwright/e2e/opfs.spec.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -701,23 +701,20 @@ test('should import ZIP into temporary site when a saved site exists', async ({
701701
{ timeout: 30000 }
702702
);
703703

704-
// Navigate to the test marker page and verify the original content is intact
705-
await website.wordpress().locator('body').waitFor();
704+
// Get the site slug from the URL to reload with the marker page
705+
const currentUrl = new URL(website.page.url());
706+
const siteSlug = currentUrl.searchParams.get('site-slug');
707+
expect(siteSlug).toBeTruthy();
706708

707-
// Use the playground to navigate to our test page
708-
const playgroundViewport = website.page.frameLocator(
709-
'#playground-viewport:visible,.playground-viewport:visible'
710-
);
711-
await playgroundViewport
712-
.locator('#wp')
713-
.evaluate((iframe: HTMLIFrameElement) => {
714-
iframe.contentWindow!.location.href = '/test-marker.php';
715-
});
709+
// Navigate directly to the marker page by reloading with url parameter
710+
await website.goto(`./?site-slug=${siteSlug}&url=/test-marker.php`);
711+
await website.waitForNestedIframes();
716712

717713
// Verify the saved site still has the original marker (not the imported content)
718-
await expect(wordpress.locator('body')).toContainText(savedSiteMarker, {
719-
timeout: 10000,
720-
});
714+
await expect(website.wordpress().locator('body')).toContainText(
715+
savedSiteMarker,
716+
{ timeout: 30000 }
717+
);
721718
});
722719

723720
test('should create temporary site when importing ZIP while on a saved site with no existing temporary site', async ({
@@ -825,4 +822,19 @@ test('should create temporary site when importing ZIP while on a saved site with
825822
savedSiteName,
826823
{ timeout: 30000 }
827824
);
825+
826+
// Get the site slug from the URL to reload with the marker page
827+
const currentUrl = new URL(website.page.url());
828+
const siteSlug = currentUrl.searchParams.get('site-slug');
829+
expect(siteSlug).toBeTruthy();
830+
831+
// Navigate directly to the marker page by reloading with url parameter
832+
await website.goto(`./?site-slug=${siteSlug}&url=/saved-only-marker.php`);
833+
await website.waitForNestedIframes();
834+
835+
// Verify the saved site still has the original marker
836+
await expect(website.wordpress().locator('body')).toContainText(
837+
savedSiteMarker,
838+
{ timeout: 30000 }
839+
);
828840
});

0 commit comments

Comments
 (0)