diff --git a/e2e/react-start/hmr/tests/app.spec.ts b/e2e/react-start/hmr/tests/app.spec.ts index bbaff95bc13..5af93dc0dc7 100644 --- a/e2e/react-start/hmr/tests/app.spec.ts +++ b/e2e/react-start/hmr/tests/app.spec.ts @@ -269,10 +269,7 @@ async function captureOriginals() { const capturePromise = captureOriginals() -async function restoreRouteFiles( - forceRouteFileKeys: Iterable = [], -) { - const forceRestoreKeys = new Set(forceRouteFileKeys) +async function restoreRouteFiles() { const restoredRouteKeys: Array = [] for (const [key, filePath] of Object.entries(routeFiles) as Array< @@ -281,9 +278,7 @@ async function restoreRouteFiles( const content = originalContents[key] if (content === undefined) continue const current = await readFile(filePath, 'utf8') - // Re-emit pending restores in case the watcher coalesced the previous - // restore write and the dev server is still serving stale route options. - if (current !== content || forceRestoreKeys.has(key)) { + if (current !== content) { await writeFile(filePath, content) restoredRouteKeys.push(key) } @@ -552,15 +547,13 @@ test.describe('react-start hmr', () => { test.beforeEach(async ({ page }) => { await capturePromise - const pendingRouteKeys = Array.from(routeKeysPendingRestoreCheck) - const restoredRouteKeys = await restoreRouteFiles(pendingRouteKeys) + const routeKeysToCheck = new Set(routeKeysPendingRestoreCheck) + routeKeysPendingRestoreCheck.clear() + const restoredRouteKeys = await restoreRouteFiles() for (const routeFileKey of restoredRouteKeys) { - routeKeysPendingRestoreCheck.add(routeFileKey) + routeKeysToCheck.add(routeFileKey) } - const routeKeysToCheck = Array.from(routeKeysPendingRestoreCheck) - routeKeysPendingRestoreCheck.clear() - for (const routeFileKey of routeKeysToCheck) { await waitForRestoredRouteFile(page, routeFileKey) } @@ -736,7 +729,6 @@ test.describe('react-start hmr', () => { await waitForRouteModuleUpdate(page, '/child', 'Child Updated Again') }, ) - await waitForHydrationSafeReload(page, '/child', 'Child Updated Again') // Now navigate to /child — should see the LATEST value await page.getByTestId('child-link').click() @@ -755,6 +747,7 @@ test.describe('react-start hmr', () => { // Set up local state in the index route await page.getByTestId('increment').click() + await expect(page.getByTestId('count')).toHaveText('Count: 1') await page.getByTestId('increment').click() await page.getByTestId('message').fill('preserve me') @@ -885,7 +878,6 @@ test.describe('react-start hmr', () => { ), async () => {}, ) - await page.waitForTimeout(300) await reloadPageAndWaitForText( page,