Unverified Commit 9ac6c4ab authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

remove reducer unit tests (#62766)

These tests were added back when the router would suspend in reducers,
primarily to test that things were working as expected during concurrent
rendering. Now that we don't suspend in reducers, most of these tests
aren't actually adding much value, and instead introduce friction
anytime we want to change the router state since they're currently
relying on snapshotting.

Before removing these tests, I verified that we have a corresponding e2e
test that covers the expected behaviors more explicitly. Specifically:

- `test/e2e/app-dir/actions` (server actions) 
- `test/e2e/app-dir/navigation` (navigation tests & router.refresh)
- `test/e2e/app-dir/app-client-cache` and
`test/e2e/app-dir/app-prefetch` (prefetch & router cache behavior)
- `test/e2e/app-dir/router-autoscroll` (navigation auto-scrolling
behavior)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2669
parent 91a84b3e
import React from 'react'
import type { fetchServerResponse as fetchServerResponseType } from '../fetch-server-response'
import type { FlightData } from '../../../../server/app-render/types'
import type { FlightRouterState } from '../../../../server/app-render/types'
import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'
import { createInitialRouterState } from '../create-initial-router-state'
import {
ACTION_NAVIGATE,
ACTION_PREFETCH,
PrefetchKind,
} from '../router-reducer-types'
import type { NavigateAction, PrefetchAction } from '../router-reducer-types'
import { navigateReducer } from './navigate-reducer'
import { prefetchReducer } from './prefetch-reducer'
import { handleMutable } from '../handle-mutable'
const buildId = 'development'
const flightData: FlightData = [
[
'children',
'linking',
'children',
'about',
[
'about',
{
children: ['__PAGE__', {}],
},
],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
],
]
const demographicsFlightData: FlightData = [
[
[
'',
{
children: [
'parallel-tab-bar',
{
audience: [
'demographics',
{
children: ['__PAGE__', {}],
},
],
},
],
},
null,
null,
true,
],
[
'',
{},
<html>
<head></head>
<body>Root layout from response</body>
</html>,
],
<>
<title>Demographics Head</title>
</>,
],
]
jest.mock('../fetch-server-response', () => {
return {
fetchServerResponse: (
url: URL
): ReturnType<typeof fetchServerResponseType> => {
if (url.pathname === '/linking' && url.hash === '#hash') {
return Promise.resolve(['', undefined])
}
if (url.pathname === '/linking/about') {
return Promise.resolve([flightData, undefined])
}
if (url.pathname === '/parallel-tab-bar/demographics') {
return Promise.resolve([demographicsFlightData, undefined])
}
throw new Error('unknown url in mock')
},
}
})
const getInitialRouterStateTree = (): FlightRouterState => [
'',
{
children: [
'linking',
{
children: ['__PAGE__', {}],
},
],
},
undefined,
undefined,
true,
]
describe('navigateReducer', () => {
beforeAll(() => {
jest.useFakeTimers()
jest.setSystemTime(new Date('2023-07-26'))
})
afterAll(() => {
jest.useRealTimers()
})
it('should apply navigation', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url: new URL('/linking/about', 'https://localhost'),
isExternalUrl: false,
locationSearch: '',
navigateType: 'push',
shouldScroll: true,
}
const newState = await navigateReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
"about" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"head": <React.Fragment>
<title>
About page!
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <h1>
About Page!
</h1>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking/about",
"focusAndScrollRef": {
"apply": true,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [
[
"children",
"linking",
"children",
"about",
"children",
"__PAGE__",
],
],
},
"nextUrl": "/linking/about",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
"/linking/about" => {
"data": Promise {},
"key": "/linking/about",
"kind": "temporary",
"lastUsedTime": 1690329600000,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"about",
{
"children": [
"__PAGE__",
{},
],
},
],
},
],
},
,
,
true,
],
}
`)
})
it('should apply navigation when called twice (concurrent)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url: new URL('/linking/about', 'https://localhost'),
isExternalUrl: false,
locationSearch: '',
navigateType: 'push',
shouldScroll: true,
}
const newState = await navigateReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
"about" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"head": <React.Fragment>
<title>
About page!
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <h1>
About Page!
</h1>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking/about",
"focusAndScrollRef": {
"apply": true,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [
[
"children",
"linking",
"children",
"about",
"children",
"__PAGE__",
],
],
},
"nextUrl": "/linking/about",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
"/linking/about" => {
"data": Promise {},
"key": "/linking/about",
"kind": "temporary",
"lastUsedTime": 1690329600000,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"about",
{
"children": [
"__PAGE__",
{},
],
},
],
},
],
},
,
,
true,
],
}
`)
})
it('should apply navigation for external url (push)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const url = new URL('https://example.vercel.sh', 'https://localhost')
const isExternalUrl = url.origin !== 'localhost'
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url,
isExternalUrl,
locationSearch: '',
navigateType: 'push',
shouldScroll: true,
}
const newState = await navigateReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "https://example.vercel.sh/",
"focusAndScrollRef": {
"apply": false,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [],
},
"nextUrl": "/linking",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": true,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
}
`)
})
it('should apply navigation for external url (replace)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const url = new URL('https://example.vercel.sh', 'https://localhost')
const isExternalUrl = url.origin !== 'localhost'
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url,
isExternalUrl,
locationSearch: '',
navigateType: 'replace',
shouldScroll: true,
}
const newState = await navigateReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "https://example.vercel.sh/",
"focusAndScrollRef": {
"apply": false,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [],
},
"nextUrl": "/linking",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": true,
"pendingPush": false,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
}
`)
})
it('should apply navigation for scroll', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking#hash', 'https://localhost') as any,
})
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url: new URL('/linking#hash', 'https://localhost'),
isExternalUrl: false,
locationSearch: '',
navigateType: 'push',
shouldScroll: false, // should not scroll
}
const newState = await navigateReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking#hash",
"focusAndScrollRef": {
"apply": false,
"hashFragment": null,
"onlyHashChange": true,
"segmentPaths": [],
},
"nextUrl": "/linking",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": 1690329600000,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
,
,
true,
],
}
`)
})
it('should apply navigation with prefetched data', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const url = new URL('/linking/about', 'https://localhost')
const prefetchAction: PrefetchAction = {
type: ACTION_PREFETCH,
url,
kind: PrefetchKind.AUTO,
}
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
await prefetchReducer(state, prefetchAction)
await state.prefetchCache.get(url.pathname + url.search)?.data
await prefetchReducer(state, prefetchAction)
await state.prefetchCache.get(url.pathname + url.search)?.data
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url: new URL('/linking/about', 'https://localhost'),
isExternalUrl: false,
navigateType: 'push',
locationSearch: '',
shouldScroll: true,
}
const newState = await navigateReducer(state, action)
const prom = Promise.resolve([
[
[
'children',
'linking',
'children',
'about',
[
'about',
{
children: ['__PAGE__', {}],
},
],
<h1>About Page!</h1>,
<React.Fragment>
<title>About page!</title>
</React.Fragment>,
],
],
undefined,
] as any)
await prom
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
"about" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"head": <React.Fragment>
<title>
About page!
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <h1>
About Page!
</h1>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking/about",
"focusAndScrollRef": {
"apply": true,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [
[
"children",
"linking",
"children",
"about",
"children",
"__PAGE__",
],
],
},
"nextUrl": "/linking/about",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
"/linking/about" => {
"data": Promise {},
"key": "/linking/about",
"kind": "auto",
"lastUsedTime": 1690329600000,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"about",
{
"children": [
"__PAGE__",
{},
],
},
],
},
],
},
,
,
true,
],
}
`)
})
it('should apply parallel routes navigation (concurrent)', async () => {
const initialTree: FlightRouterState = [
'',
{
children: [
'parallel-tab-bar',
{
audience: ['__PAGE__', {}],
views: ['__PAGE__', {}],
children: ['__PAGE__', {}],
},
],
},
null,
null,
true,
]
const initialCanonicalUrl = '/parallel-tab-bar'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'parallel-tab-bar',
{
parallelRoutes: new Map([
[
'audience',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Audience Page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
[
'views',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Views Page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Children Page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/parallel-tab-bar', 'https://localhost') as any,
})
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url: new URL('/parallel-tab-bar/demographics', 'https://localhost'),
isExternalUrl: false,
locationSearch: '',
navigateType: 'push',
shouldScroll: true,
}
const newState = await navigateReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"parallel-tab-bar" => {
"lazyData": null,
"parallelRoutes": Map {
"audience" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Audience Page
</React.Fragment>,
},
"demographics" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"head": <React.Fragment>
<title>
Demographics Head
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": null,
},
},
"views" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Views Page
</React.Fragment>,
},
},
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Children Page
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout from response
</body>
</html>,
},
"canonicalUrl": "/parallel-tab-bar/demographics",
"focusAndScrollRef": {
"apply": true,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [
[
"children",
"parallel-tab-bar",
"audience",
"demographics",
"children",
"__PAGE__",
],
],
},
"nextUrl": "/parallel-tab-bar/demographics",
"prefetchCache": Map {
"/parallel-tab-bar" => {
"data": Promise {},
"key": "/parallel-tab-bar",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"parallel-tab-bar",
{
"audience": [
"__PAGE__",
{},
],
"children": [
"__PAGE__",
{},
],
"views": [
"__PAGE__",
{},
],
},
],
},
null,
null,
true,
],
},
"/parallel-tab-bar/demographics" => {
"data": Promise {},
"key": "/parallel-tab-bar/demographics",
"kind": "temporary",
"lastUsedTime": 1690329600000,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"parallel-tab-bar",
{
"audience": [
"__PAGE__",
{},
],
"children": [
"__PAGE__",
{},
],
"views": [
"__PAGE__",
{},
],
},
],
},
null,
null,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"parallel-tab-bar",
{
"audience": [
"demographics",
{
"children": [
"__PAGE__",
{},
],
},
],
"children": [
"__PAGE__",
{},
],
"views": [
"__PAGE__",
{},
],
},
],
},
,
,
true,
],
}
`)
})
it('should apply navigation for hash fragments within the same tree', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking#hash', 'https://localhost') as any,
})
const mutable = {
canonicalUrl: '/linking#hash',
previousTree: initialTree,
hashFragment: '#hash',
pendingPush: true,
shouldScroll: true,
preserveCustomHistoryState: false,
}
const newState = handleMutable(state, mutable)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking#hash",
"focusAndScrollRef": {
"apply": false,
"hashFragment": "hash",
"onlyHashChange": true,
"segmentPaths": [],
},
"nextUrl": "/linking",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
}
`)
})
it('should apply navigation for hash fragments within a different tree', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'__PAGE__',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: NavigateAction = {
type: ACTION_NAVIGATE,
url: new URL('/linking/about#hash', 'https://localhost'),
isExternalUrl: false,
locationSearch: '',
navigateType: 'push',
shouldScroll: true,
}
const newState = await navigateReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
"about" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"__PAGE__" => {
"head": <React.Fragment>
<title>
About page!
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <h1>
About Page!
</h1>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking/about#hash",
"focusAndScrollRef": {
"apply": true,
"hashFragment": "hash",
"onlyHashChange": false,
"segmentPaths": [
[
"children",
"linking",
"children",
"about",
"children",
"__PAGE__",
],
],
},
"nextUrl": "/linking/about",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
"/linking/about" => {
"data": Promise {},
"key": "/linking/about",
"kind": "temporary",
"lastUsedTime": 1690329600000,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"__PAGE__",
{},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"about",
{
"children": [
"__PAGE__",
{},
],
},
],
},
],
},
,
,
true,
],
}
`)
})
})
import React from 'react'
import type { fetchServerResponse as fetchServerResponseType } from '../fetch-server-response'
import type { FlightData } from '../../../../server/app-render/types'
import type { FlightRouterState } from '../../../../server/app-render/types'
import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'
import { createInitialRouterState } from '../create-initial-router-state'
import {
ACTION_PREFETCH,
PrefetchCacheEntryStatus,
PrefetchKind,
} from '../router-reducer-types'
import type {
PrefetchAction,
PrefetchCacheEntry,
} from '../router-reducer-types'
import { prefetchReducer } from './prefetch-reducer'
import { fetchServerResponse } from '../fetch-server-response'
jest.mock('../fetch-server-response', () => {
const flightData: FlightData = [
[
'children',
'linking',
'children',
'about',
[
'about',
{
children: ['', {}],
},
],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
],
]
return {
fetchServerResponse: (
url: URL
): ReturnType<typeof fetchServerResponseType> => {
if (url.pathname === '/linking/about') {
return Promise.resolve([flightData, undefined])
}
throw new Error('unknown url in mock')
},
}
})
const getInitialRouterStateTree = (): FlightRouterState => [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
]
async function runPromiseThrowChain(fn: any): Promise<any> {
try {
return await fn()
} catch (err) {
if (err instanceof Promise) {
await err
return await runPromiseThrowChain(fn)
}
throw err
}
}
describe('prefetchReducer', () => {
it('should apply navigation', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId: 'development',
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const url = new URL('/linking/about', 'https://localhost')
const serverResponse = await fetchServerResponse(
url,
initialTree,
null,
state.buildId,
PrefetchKind.AUTO
)
const action: PrefetchAction = {
type: ACTION_PREFETCH,
url,
kind: PrefetchKind.AUTO,
}
const newState = await runPromiseThrowChain(() =>
prefetchReducer(state, action)
)
const prom = Promise.resolve(serverResponse)
await prom
const expectedState: ReturnType<typeof prefetchReducer> = {
buildId: 'development',
prefetchCache: new Map([
[
'/linking',
{
key: '/linking',
data: expect.any(Promise),
prefetchTime: expect.any(Number),
kind: PrefetchKind.AUTO,
lastUsedTime: null,
treeAtTimeOfPrefetch: initialTree,
status: PrefetchCacheEntryStatus.fresh,
},
],
[
'/linking/about',
{
key: '/linking/about',
data: prom,
kind: PrefetchKind.AUTO,
lastUsedTime: null,
prefetchTime: expect.any(Number),
status: PrefetchCacheEntryStatus.fresh,
treeAtTimeOfPrefetch: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
},
],
]),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: true,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>Root layout</body>
</html>
),
prefetchRsc: null,
parallelRoutes: initialParallelRoutes,
},
tree: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
nextUrl: '/linking',
}
expect(newState).toMatchObject(expectedState)
})
it('should apply navigation (concurrent)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId: 'development',
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const state2 = createInitialRouterState({
buildId: 'development',
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const url = new URL('/linking/about', 'https://localhost')
const serverResponse = await fetchServerResponse(
url,
initialTree,
null,
state.buildId,
PrefetchKind.AUTO
)
const action: PrefetchAction = {
type: ACTION_PREFETCH,
url,
kind: PrefetchKind.AUTO,
}
await runPromiseThrowChain(() => prefetchReducer(state, action))
const newState = await runPromiseThrowChain(() =>
prefetchReducer(state2, action)
)
const prom = Promise.resolve(serverResponse)
await prom
const prefetchCache = new Map<string, PrefetchCacheEntry>()
prefetchCache.set('/linking', {
data: expect.any(Promise),
kind: PrefetchKind.AUTO,
lastUsedTime: null,
prefetchTime: expect.any(Number),
treeAtTimeOfPrefetch: initialTree,
key: '/linking',
status: PrefetchCacheEntryStatus.fresh,
})
const expectedState: ReturnType<typeof prefetchReducer> = {
buildId: 'development',
prefetchCache: new Map([
[
'/linking',
{
key: '/linking',
data: expect.any(Promise),
prefetchTime: expect.any(Number),
kind: PrefetchKind.AUTO,
lastUsedTime: null,
treeAtTimeOfPrefetch: initialTree,
status: PrefetchCacheEntryStatus.fresh,
},
],
[
'/linking/about',
{
key: '/linking/about',
data: prom,
prefetchTime: expect.any(Number),
kind: PrefetchKind.AUTO,
lastUsedTime: null,
status: PrefetchCacheEntryStatus.fresh,
treeAtTimeOfPrefetch: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
},
],
]),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: true,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>Root layout</body>
</html>
),
prefetchRsc: null,
parallelRoutes: initialParallelRoutes,
},
tree: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
nextUrl: '/linking',
}
expect(newState).toMatchObject(expectedState)
})
})
import React from 'react'
import type { fetchServerResponse } from '../fetch-server-response'
import type { FlightData } from '../../../../server/app-render/types'
import type { FlightRouterState } from '../../../../server/app-render/types'
import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'
import { createInitialRouterState } from '../create-initial-router-state'
import { ACTION_REFRESH } from '../router-reducer-types'
import type { RefreshAction } from '../router-reducer-types'
import { refreshReducer } from './refresh-reducer'
const buildId = 'development'
jest.mock('../fetch-server-response', () => {
const flightData: FlightData = [
[
[
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
null,
null,
true,
],
[
'',
{},
<html>
<head></head>
<body>
<h1>Linking Page!</h1>
</body>
</html>,
],
<>
<title>Linking page!</title>
</>,
],
]
return {
fetchServerResponse: (url: URL): ReturnType<typeof fetchServerResponse> => {
if (url.pathname === '/linking') {
return Promise.resolve([flightData, undefined])
}
throw new Error('unknown url in mock')
},
}
})
const getInitialRouterStateTree = (): FlightRouterState => [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
]
async function runPromiseThrowChain(fn: any): Promise<any> {
try {
return await fn()
} catch (err) {
if (err instanceof Promise) {
await err
return await runPromiseThrowChain(fn)
}
throw err
}
}
describe('refreshReducer', () => {
it('should apply refresh', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: RefreshAction = {
type: ACTION_REFRESH,
origin: new URL('/linking', 'https://localhost').origin,
}
const newState = await runPromiseThrowChain(() =>
refreshReducer(state, action)
)
const expectedState: ReturnType<typeof refreshReducer> = {
buildId,
prefetchCache: new Map(),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: false,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking',
nextUrl: '/linking',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>
<h1>Linking Page!</h1>
</body>
</html>
),
prefetchRsc: null,
parallelRoutes: new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: null,
prefetchRsc: null,
parallelRoutes: new Map(),
head: (
<>
<title>Linking page!</title>
</>
),
},
],
]),
],
]),
lazyData: null,
rsc: null,
prefetchRsc: null,
},
],
]),
],
]),
},
tree: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
}
expect(newState).toMatchObject(expectedState)
})
it('should apply refresh (concurrent)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const state2 = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: RefreshAction = {
type: ACTION_REFRESH,
origin: new URL('/linking', 'https://localhost').origin,
}
await runPromiseThrowChain(() => refreshReducer(state, action))
const newState = await runPromiseThrowChain(() =>
refreshReducer(state2, action)
)
const expectedState: ReturnType<typeof refreshReducer> = {
buildId,
prefetchCache: new Map(),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: false,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking',
nextUrl: '/linking',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>
<h1>Linking Page!</h1>
</body>
</html>
),
prefetchRsc: null,
parallelRoutes: new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: null,
prefetchRsc: null,
parallelRoutes: new Map(),
head: (
<>
<title>Linking page!</title>
</>
),
},
],
]),
],
]),
lazyData: null,
rsc: null,
prefetchRsc: null,
},
],
]),
],
]),
},
tree: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
}
expect(newState).toMatchObject(expectedState)
})
it('should invalidate all segments (concurrent)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
[
'about',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>About page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>About layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const state2 = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: RefreshAction = {
type: ACTION_REFRESH,
origin: new URL('/linking', 'https://localhost').origin,
}
await runPromiseThrowChain(() => refreshReducer(state, action))
const newState = await runPromiseThrowChain(() =>
refreshReducer(state2, action)
)
const expectedState: ReturnType<typeof refreshReducer> = {
buildId,
prefetchCache: new Map(),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: false,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking',
nextUrl: '/linking',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>
<h1>Linking Page!</h1>
</body>
</html>
),
prefetchRsc: null,
parallelRoutes: new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: null,
prefetchRsc: null,
parallelRoutes: new Map(),
head: (
<>
<title>Linking page!</title>
</>
),
},
],
]),
],
]),
lazyData: null,
rsc: null,
prefetchRsc: null,
},
],
]),
],
]),
},
tree: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
}
expect(newState).toMatchObject(expectedState)
})
it('should invalidate prefetchCache (concurrent)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
[
'about',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>About page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>About layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const state2 = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: RefreshAction = {
type: ACTION_REFRESH,
origin: new URL('/linking', 'https://localhost').origin,
}
await runPromiseThrowChain(() => refreshReducer(state, action))
const newState = await runPromiseThrowChain(() =>
refreshReducer(state2, action)
)
const expectedState: ReturnType<typeof refreshReducer> = {
buildId,
prefetchCache: new Map(),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: false,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking',
nextUrl: '/linking',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>
<h1>Linking Page!</h1>
</body>
</html>
),
prefetchRsc: null,
parallelRoutes: new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: null,
prefetchRsc: null,
parallelRoutes: new Map(),
head: (
<>
<title>Linking page!</title>
</>
),
},
],
]),
],
]),
lazyData: null,
rsc: null,
prefetchRsc: null,
},
],
]),
],
]),
},
tree: [
'',
{
children: [
'linking',
{
children: ['', {}],
},
],
},
undefined,
undefined,
true,
],
}
expect(newState).toMatchObject(expectedState)
})
})
import React from 'react'
import type { FlightRouterState } from '../../../../server/app-render/types'
import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'
import { createInitialRouterState } from '../create-initial-router-state'
import {
ACTION_RESTORE,
PrefetchCacheEntryStatus,
PrefetchKind,
} from '../router-reducer-types'
import type { RestoreAction } from '../router-reducer-types'
import { restoreReducer } from './restore-reducer'
const buildId = 'development'
const getInitialRouterStateTree = (): FlightRouterState => [
'',
{
children: [
'linking',
{
children: ['about', { children: ['', {}] }],
},
],
},
undefined,
undefined,
true,
]
async function runPromiseThrowChain(fn: any): Promise<any> {
try {
return await fn()
} catch (err) {
if (err instanceof Promise) {
await err
return await runPromiseThrowChain(fn)
}
throw err
}
}
describe('serverPatchReducer', () => {
it('should apply server patch', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: RestoreAction = {
type: ACTION_RESTORE,
url: new URL('/linking/about', 'https://localhost'),
tree: [
'',
{
children: [
'linking',
{
children: [
'about',
{
children: ['', {}],
},
],
},
],
},
null,
null,
true,
],
}
const newState = await runPromiseThrowChain(() =>
restoreReducer(state, action)
)
const expectedState: ReturnType<typeof restoreReducer> = {
buildId,
prefetchCache: new Map([
[
'/linking',
{
key: '/linking',
data: expect.any(Promise),
prefetchTime: expect.any(Number),
kind: PrefetchKind.AUTO,
lastUsedTime: null,
treeAtTimeOfPrefetch: initialTree,
status: PrefetchCacheEntryStatus.fresh,
},
],
]),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: true,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking/about',
nextUrl: '/linking/about',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>Root layout</body>
</html>
),
prefetchRsc: null,
parallelRoutes: new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
]),
},
tree: [
'',
{
children: [
'linking',
{
children: ['about', { children: ['', {}] }],
},
],
},
null,
null,
true,
],
}
expect(newState).toMatchObject(expectedState)
})
it('should apply server patch (concurrent)', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const state2 = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
})
const action: RestoreAction = {
type: ACTION_RESTORE,
url: new URL('/linking/about', 'https://localhost'),
tree: [
'',
{
children: [
'linking',
{
children: [
'about',
{
children: ['', {}],
},
],
},
],
},
null,
null,
true,
],
}
await runPromiseThrowChain(() => restoreReducer(state, action))
const newState = await runPromiseThrowChain(() =>
restoreReducer(state2, action)
)
const expectedState: ReturnType<typeof restoreReducer> = {
buildId,
prefetchCache: new Map([
[
'/linking',
{
key: '/linking',
data: expect.any(Promise),
prefetchTime: expect.any(Number),
kind: PrefetchKind.AUTO,
lastUsedTime: null,
treeAtTimeOfPrefetch: initialTree,
status: PrefetchCacheEntryStatus.fresh,
},
],
]),
pushRef: {
mpaNavigation: false,
pendingPush: false,
preserveCustomHistoryState: true,
},
focusAndScrollRef: {
apply: false,
onlyHashChange: false,
hashFragment: null,
segmentPaths: [],
},
canonicalUrl: '/linking/about',
nextUrl: '/linking/about',
cache: {
lazyData: null,
rsc: (
<html>
<head></head>
<body>Root layout</body>
</html>
),
prefetchRsc: null,
parallelRoutes: new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
]),
},
tree: [
'',
{
children: [
'linking',
{
children: ['about', { children: ['', {}] }],
},
],
},
null,
null,
true,
],
}
expect(newState).toMatchObject(expectedState)
})
})
import React from 'react'
import type { fetchServerResponse as fetchServerResponseType } from '../fetch-server-response'
import type {
FlightData,
FlightRouterState,
} from '../../../../server/app-render/types'
import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'
import { createInitialRouterState } from '../create-initial-router-state'
import { ACTION_SERVER_PATCH, ACTION_NAVIGATE } from '../router-reducer-types'
import type { ServerPatchAction, NavigateAction } from '../router-reducer-types'
import { navigateReducer } from './navigate-reducer'
import { serverPatchReducer } from './server-patch-reducer'
const buildId = 'development'
jest.mock('../fetch-server-response', () => {
const flightData: FlightData = [
[
'children',
'linking',
'children',
'about',
[
'about',
{
children: ['', {}],
},
],
['about', {}, <h1>About Page!</h1>],
<>
<title>About page!</title>
</>,
],
]
return {
fetchServerResponse: (
url: URL
): ReturnType<typeof fetchServerResponseType> => {
if (url.pathname === '/linking/about') {
return Promise.resolve([flightData, undefined])
}
throw new Error('unknown url in mock')
},
}
})
const flightDataForPatch: FlightData = [
[
'children',
'linking',
'children',
'somewhere-else',
[
'somewhere-else',
{
children: ['', {}],
},
],
['somewhere-else', {}, <h1>Somewhere Page!</h1>],
<>
<title>Somewhere page!</title>
</>,
],
]
const getInitialRouterStateTree = (): FlightRouterState => [
'',
{
children: [
'linking',
{
children: ['about', { children: ['', {}] }],
},
],
},
undefined,
undefined,
true,
]
describe('serverPatchReducer', () => {
beforeAll(() => {
jest.useFakeTimers()
jest.setSystemTime(new Date('2023-07-26'))
})
afterAll(() => {
jest.useRealTimers()
})
it('should apply server patch', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const url = new URL('/linking/about', 'https://localhost') as any
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: url,
})
const action: ServerPatchAction = {
type: ACTION_SERVER_PATCH,
serverResponse: [flightDataForPatch, undefined],
previousTree: [
'',
{
children: [
'linking',
{
children: ['about', { children: ['', {}] }],
},
],
},
undefined,
undefined,
true,
],
}
const newState = await serverPatchReducer(state, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
"somewhere-else" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"" => {
"head": <React.Fragment>
<title>
Somewhere page!
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <h1>
Somewhere Page!
</h1>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking/about",
"focusAndScrollRef": {
"apply": false,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [],
},
"nextUrl": "/linking/somewhere-else",
"prefetchCache": Map {
"/linking/about" => {
"data": Promise {},
"key": "/linking/about",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"about",
{
"children": [
"",
{},
],
},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": false,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"somewhere-else",
{
"children": [
"",
{},
],
},
],
},
],
},
,
,
true,
],
}
`)
})
it('should apply server patch without affecting focusAndScrollRef', async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map([
[
'children',
new Map([
[
'linking',
{
parallelRoutes: new Map([
[
'children',
new Map([
[
'',
{
lazyData: null,
rsc: <>Linking page</>,
prefetchRsc: null,
parallelRoutes: new Map(),
},
],
]),
],
]),
lazyData: null,
rsc: <>Linking layout level</>,
prefetchRsc: null,
},
],
]),
],
])
const navigateAction: NavigateAction = {
type: ACTION_NAVIGATE,
url: new URL('/linking/about', 'https://localhost'),
isExternalUrl: false,
locationSearch: '',
navigateType: 'push',
shouldScroll: true,
}
const url = new URL(initialCanonicalUrl, 'https://localhost') as any
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes,
location: url,
})
const stateAfterNavigate = await navigateReducer(state, navigateAction)
const action: ServerPatchAction = {
type: ACTION_SERVER_PATCH,
serverResponse: [flightDataForPatch, undefined],
previousTree: [
'',
{
children: [
'linking',
{
children: ['about', { children: ['', {}] }],
},
],
},
undefined,
undefined,
true,
],
}
const newState = await serverPatchReducer(stateAfterNavigate, action)
expect(newState).toMatchInlineSnapshot(`
{
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"" => {
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking page
</React.Fragment>,
},
"about" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"" => {
"head": <React.Fragment>
<title>
About page!
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <h1>
About Page!
</h1>,
},
"somewhere-else" => {
"lazyData": null,
"parallelRoutes": Map {
"children" => Map {
"" => {
"head": <React.Fragment>
<title>
Somewhere page!
</title>
</React.Fragment>,
"lazyData": null,
"parallelRoutes": Map {},
"prefetchRsc": null,
"rsc": null,
},
},
},
"prefetchRsc": null,
"rsc": <h1>
Somewhere Page!
</h1>,
},
},
},
"prefetchRsc": null,
"rsc": <React.Fragment>
Linking layout level
</React.Fragment>,
},
},
},
"prefetchRsc": null,
"rsc": <html>
<head />
<body>
Root layout
</body>
</html>,
},
"canonicalUrl": "/linking/about",
"focusAndScrollRef": {
"apply": true,
"hashFragment": null,
"onlyHashChange": false,
"segmentPaths": [
[
"children",
"linking",
"children",
"about",
"children",
"",
],
],
},
"nextUrl": "/linking/somewhere-else",
"prefetchCache": Map {
"/linking" => {
"data": Promise {},
"key": "/linking",
"kind": "auto",
"lastUsedTime": null,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"about",
{
"children": [
"",
{},
],
},
],
},
],
},
undefined,
undefined,
true,
],
},
"/linking/about" => {
"data": Promise {},
"key": "/linking/about",
"kind": "temporary",
"lastUsedTime": 1690329600000,
"prefetchTime": 1690329600000,
"status": "fresh",
"treeAtTimeOfPrefetch": [
"",
{
"children": [
"linking",
{
"children": [
"about",
{
"children": [
"",
{},
],
},
],
},
],
},
undefined,
undefined,
true,
],
},
},
"pushRef": {
"mpaNavigation": false,
"pendingPush": true,
"preserveCustomHistoryState": false,
},
"tree": [
"",
{
"children": [
"linking",
{
"children": [
"somewhere-else",
{
"children": [
"",
{},
],
},
],
},
],
},
,
,
true,
],
}
`)
})
it("should gracefully recover if the server patch doesn't match the current tree", async () => {
const initialTree = getInitialRouterStateTree()
const initialCanonicalUrl = '/linking'
const children = (
<html>
<head></head>
<body>Root layout</body>
</html>
)
const url = new URL('/linking/about', 'https://localhost') as any
const state = createInitialRouterState({
buildId,
initialTree,
initialHead: null,
initialCanonicalUrl,
initialSeedData: ['', {}, children],
initialParallelRoutes: new Map(),
location: url,
})
const action: ServerPatchAction = {
type: ACTION_SERVER_PATCH,
// this flight data is intentionally completely unrelated to the existing tree
serverResponse: [
[
[
'children',
'tree-patch-failure',
'children',
'new-page',
['new-page', { children: ['__PAGE__', {}] }],
null,
null,
],
],
undefined,
],
previousTree: [
'',
{
children: [
'linking',
{
children: ['about', { children: ['', {}] }],
},
],
},
undefined,
undefined,
true,
],
}
const newState = await serverPatchReducer(state, action)
expect(newState.pushRef.pendingPush).toBe(true)
expect(newState.pushRef.mpaNavigation).toBe(true)
expect(newState.canonicalUrl).toBe('/linking/about')
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment