Skip to content

Commit 918252f

Browse files
committed
test(platform): stop waiting for hydration once a redirect has left the app
1 parent e4586a8 commit 918252f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎apps/sim/platform/checks/test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ interface Fiber {
1515
* holds its dehydrated markup. A press or pointer move on markup React has not hydrated reaches
1616
* no handler and is lost, and Playwright's actionability checks cannot see the difference: on a
1717
* production build the live suite lost a tab click this way. The app exposes no hydration signal
18-
* of its own, so this reads React's.
18+
* of its own, so this reads React's. Given the app's origin, a document that has since left it,
19+
* such as one a redirect to another site replaced after the load returned, has nothing to wait for.
1920
*/
20-
function isHydrated() {
21+
function isHydrated(appOrigin: string | undefined) {
22+
if (appOrigin !== undefined && location.origin !== appOrigin) return true
2123
const key = Object.keys(document).find((name) => name.startsWith('__reactContainer$'))
2224
if (!key) return false
2325
const container: { stateNode: { current: Fiber } } | undefined = Reflect.get(document, key)
@@ -50,7 +52,7 @@ export async function waitUntilHydrated(page: Page, timeout?: number) {
5052

5153
async function waitForHydration(page: Page, appOrigin: string) {
5254
if (new URL(page.url()).origin !== appOrigin) return
53-
await waitUntilHydrated(page)
55+
await page.waitForFunction(isHydrated, appOrigin, { polling: 100 })
5456
}
5557

5658
/**

0 commit comments

Comments
 (0)