Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions e2e/react-start/hmr/tests/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,7 @@ async function captureOriginals() {

const capturePromise = captureOriginals()

async function restoreRouteFiles(
forceRouteFileKeys: Iterable<RouteFileKey> = [],
) {
const forceRestoreKeys = new Set(forceRouteFileKeys)
async function restoreRouteFiles() {
const restoredRouteKeys: Array<RouteFileKey> = []

for (const [key, filePath] of Object.entries(routeFiles) as Array<
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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()
Expand All @@ -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')

Expand Down Expand Up @@ -885,7 +878,6 @@ test.describe('react-start hmr', () => {
),
async () => {},
)
await page.waitForTimeout(300)

await reloadPageAndWaitForText(
page,
Expand Down
Loading