Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions packages/plugin-rsc/e2e/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ export async function setupIsolatedFixture(options: {
dest: string
overrides?: Record<string, string>
}) {
// Allow 60s for the calling `beforeAll` hook, because `pnpm i` hits the
// network and can exceed the default 30s on macOS runners.
test.setTimeout(60_000)

// copy fixture
fs.rmSync(options.dest, { recursive: true, force: true })
fs.cpSync(options.src, options.dest, {
Expand Down
25 changes: 22 additions & 3 deletions packages/plugin-rsc/e2e/use-cache-persistent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ function defineDevTests(f: Fixture) {
await expect(executionCount).toHaveText('1')

// Editing the cached function advances its module generation.
action.edit((code) => code.replace('body-v1', 'body-v2'))
await editServerModule(page, () =>
action.edit((code) => code.replace('body-v1', 'body-v2')),
)
await page.reload()
await waitForHydration(page)
await expectResultAfterUpdate(
Expand All @@ -123,7 +125,9 @@ function defineDevTests(f: Fixture) {
)

// Editing a direct dependency invalidates the importing cache module.
direct.edit((code) => code.replace('direct-v1', 'direct-v2'))
await editServerModule(page, () =>
direct.edit((code) => code.replace('direct-v1', 'direct-v2')),
)
await page.reload()
await waitForHydration(page)
await expectResultAfterUpdate(
Expand All @@ -134,7 +138,9 @@ function defineDevTests(f: Fixture) {
)

// Reverse-importer traversal also reaches transitive dependencies.
transitive.edit((code) => code.replace('transitive-v1', 'transitive-v2'))
await editServerModule(page, () =>
transitive.edit((code) => code.replace('transitive-v1', 'transitive-v2')),
)
await page.reload()
await waitForHydration(page)
await expectResultAfterUpdate(
Expand All @@ -159,6 +165,19 @@ function defineDevTests(f: Fixture) {
})
}

// Edit a server module and wait for the `rsc:update` refetch it triggers.
// Reloading before that finishes can abort the refetch (an unhandled
// `TypeError: Load failed` in WebKit), or let the late update reach the
// reloaded page before it has hydrated.
async function editServerModule(page: Page, edit: () => void) {
const refetch = page.waitForResponse(
(response) =>
response.request().method() === 'GET' && response.url().includes('_.rsc'),
)
edit()
await (await refetch).finished()
}

async function expectResultAfterUpdate(
page: Page,
form: Locator,
Expand Down
Loading