-
Notifications
You must be signed in to change notification settings - Fork 28.3k
/
Copy pathprefetching-not-found.test.ts
42 lines (33 loc) · 1.37 KB
/
prefetching-not-found.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('prefetching-not-found', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should correctly navigate to/from a global 404 page when following links with prefetch=auto', async () => {
let browser = await next.browser('/')
expect(await browser.elementByCss('h1').text()).toBe('Home Page')
await browser.elementByCss("[href='/fake-link']").click()
await retry(async () => {
expect(await browser.elementByCss('body').text()).toContain(
'This page could not be found.'
)
})
await browser.elementByCss("[href='/']").click()
await retry(async () => {
expect(await browser.elementByCss('h1').text()).toBe('Home Page')
})
// Assert the same behavior, but starting at the not found page. This is to
// ensure that when we seed the prefetch cache, we don't have any cache
// collisions that would cause the not-found page to remain rendered when
// following a link to the home page.
browser = await next.browser('/fake-link')
expect(await browser.elementByCss('body').text()).toContain(
'This page could not be found.'
)
await browser.elementByCss("[href='/']").click()
await retry(async () => {
expect(await browser.elementByCss('h1').text()).toBe('Home Page')
})
})
})