2023-05-18 22:06:57 +02:00
|
|
|
import { createNextDescribe } from 'e2e-utils'
|
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
export function runTest({ next }) {
|
|
|
|
it('should allow navigation on not-found', async () => {
|
|
|
|
const browser = await next.browser('/trigger-404')
|
|
|
|
expect(await browser.elementByCss('#not-found-component').text()).toBe(
|
|
|
|
'Not Found!'
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(
|
2023-05-22 17:04:36 +02:00
|
|
|
await browser
|
|
|
|
.elementByCss('#to-result')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#result-page')
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
.text()
|
|
|
|
).toBe('Result Page!')
|
|
|
|
})
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
it('should allow navigation on error', async () => {
|
|
|
|
const browser = await next.browser('/trigger-error')
|
|
|
|
expect(await browser.elementByCss('#error-component').text()).toBe(
|
|
|
|
'Error Happened!'
|
|
|
|
)
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
expect(
|
2023-05-22 17:04:36 +02:00
|
|
|
await browser
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
.elementByCss('#to-result')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#result-page')
|
|
|
|
.text()
|
|
|
|
).toBe('Result Page!')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should allow navigation to other routes on route that was initially not-found', async () => {
|
|
|
|
// Intentionally non-existent route.
|
|
|
|
const browser = await next.browser('/testabc')
|
|
|
|
expect(await browser.elementByCss('#not-found-component').text()).toBe(
|
|
|
|
'Not Found!'
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(
|
|
|
|
await browser
|
|
|
|
.elementByCss('#to-result')
|
2023-05-22 17:04:36 +02:00
|
|
|
.click()
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
.waitForElementByCss('#result-page')
|
|
|
|
.text()
|
|
|
|
).toBe('Result Page!')
|
|
|
|
})
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
it('should allow navigation back to route that was initially not-found', async () => {
|
|
|
|
// Intentionally non-existent route.
|
|
|
|
const browser = await next.browser('/testabc')
|
|
|
|
expect(await browser.elementByCss('#not-found-component').text()).toBe(
|
|
|
|
'Not Found!'
|
|
|
|
)
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
await browser
|
|
|
|
.elementByCss('#to-result')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#result-page')
|
|
|
|
.back()
|
|
|
|
.waitForElementByCss('#not-found-component')
|
|
|
|
})
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
it('should allow navigating to a page calling notfound', async () => {
|
|
|
|
const browser = await next.browser('/')
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
await browser
|
|
|
|
.elementByCss('#trigger-404-link')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#not-found-component')
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
expect(await browser.elementByCss('#not-found-component').text()).toBe(
|
|
|
|
'Not Found!'
|
|
|
|
)
|
|
|
|
|
|
|
|
await browser.back().waitForElementByCss('#homepage')
|
|
|
|
|
|
|
|
expect(await browser.elementByCss('#homepage').text()).toBe('Home')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should allow navigating to a non-existent page', async () => {
|
|
|
|
const browser = await next.browser('/')
|
|
|
|
|
|
|
|
await browser
|
|
|
|
.elementByCss('#non-existent-link')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#not-found-component')
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
expect(await browser.elementByCss('#not-found-component').text()).toBe(
|
|
|
|
'Not Found!'
|
|
|
|
)
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
await browser.back().waitForElementByCss('#homepage')
|
2023-05-22 17:04:36 +02:00
|
|
|
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
expect(await browser.elementByCss('#homepage').text()).toBe('Home')
|
|
|
|
})
|
Fix root not-found page tree loader structure (#54080)
### What & Why
Previously when rendering the root `/_not-found` in production, we'll always override the parallel routes component children with not-found component, this will break the navigation in build mode from root 404 `/_not-found` path.
### How
The new solution is to change the root `/_not-found` rendering strategy. Previously the loader tree of `/_not-found` look like this
```js
['',
{
children: ['not-found', {}, {}]
},
{ layout: ..., 'not-found': ...}
]
```
it's not a pretty valid tree, which could lead to problems during rendering.
New solution is to change the children to render a page, but the page content is `not-found.js` component. The new tree of root not-found will look like
```js
['',
{
children: ['__PAGE__', {}, {
page: ... // same as root 'not-found'
}]
},
{ layout: ..., 'not-found': ...}
]
```
This change could fix the navigation on the root not-found page.
Fixes #52264
2023-08-16 17:10:08 +02:00
|
|
|
|
|
|
|
it('should be able to navigate to other page from root not-found page', async () => {
|
|
|
|
const browser = await next.browser('/')
|
|
|
|
|
|
|
|
await browser
|
|
|
|
.elementByCss('#go-to-404')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#not-found-component')
|
|
|
|
|
|
|
|
await browser
|
|
|
|
.elementByCss('#go-to-dynamic')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#dynamic')
|
|
|
|
|
|
|
|
expect(await browser.elementByCss('#dynamic').text()).toBe(
|
|
|
|
'Dynamic page: foo'
|
|
|
|
)
|
|
|
|
|
|
|
|
await browser
|
|
|
|
.elementByCss('#go-to-dynamic-404')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#not-found-component')
|
|
|
|
|
|
|
|
await browser
|
|
|
|
.elementByCss('#go-to-index')
|
|
|
|
.click()
|
|
|
|
.waitForElementByCss('#homepage')
|
|
|
|
})
|
Fix not found hangs the build with overridden node env (#53106)
### Why
In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.
### What
Fixes #53082
Fixes #53083
### How
When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes
For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page
To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
2023-07-24 23:00:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
createNextDescribe(
|
|
|
|
'app dir - not found navigation',
|
|
|
|
{
|
|
|
|
files: __dirname,
|
|
|
|
},
|
|
|
|
({ next }) => {
|
|
|
|
runTest({ next })
|
2023-05-18 22:06:57 +02:00
|
|
|
}
|
|
|
|
)
|