Skip to content

Commit f6bd714

Browse files
[backport] [test] Compile the middleware redirect routes up front in dev (#97328)
Backports #97190 ("[test] Compile the middleware redirect routes up front in dev") to `next-16-3`. <!-- NEXT_JS_LLM --> Co-authored-by: Hendrik Liebau <[email protected]>
1 parent 43c1c60 commit f6bd714

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎test/e2e/app-dir/navigation/navigation.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,17 @@ describe('app dir - navigation', () => {
10291029

10301030
describe('middleware redirect', () => {
10311031
it('should change browser location when router.refresh() gets a redirect response', async () => {
1032+
if (isNextDev) {
1033+
// The browser location only changes at the end of a chain of requests:
1034+
// the page posts to `/api/set-token`, calls `router.refresh()`, and the
1035+
// refresh gets a middleware redirect to the dashboard. In dev the first
1036+
// request to each of those routes compiles it on demand, which costs
1037+
// seconds on a CI runner. Hit them here so the chain below does not pay
1038+
// for it.
1039+
await next.fetch('/api/set-token', { method: 'POST' })
1040+
await next.fetch('/redirect-on-refresh/dashboard')
1041+
}
1042+
10321043
const browser = await next.browser('/redirect-on-refresh/auth')
10331044
await retry(async () =>
10341045
expect(await browser.url()).toBe(

0 commit comments

Comments
 (0)