-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
183 changes: 99 additions & 84 deletions
183
...app-dir/error-boundary-and-not-found-linking/error-boundary-and-not-found-linking.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,119 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'not-found-linking', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ 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( | ||
await browser | ||
.elementByCss('#to-result') | ||
.click() | ||
.waitForElementByCss('#result-page') | ||
.text() | ||
).toBe('Result Page!') | ||
}) | ||
|
||
it('should allow navigation on error', async () => { | ||
const browser = await next.browser('/trigger-error') | ||
expect(await browser.elementByCss('#error-component').text()).toBe( | ||
'Error Happened!' | ||
) | ||
|
||
expect( | ||
await browser | ||
.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') | ||
.click() | ||
.waitForElementByCss('#result-page') | ||
.text() | ||
).toBe('Result Page!') | ||
}) | ||
|
||
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!' | ||
) | ||
|
||
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( | ||
await browser | ||
.elementByCss('#to-result') | ||
.click() | ||
.waitForElementByCss('#result-page') | ||
.back() | ||
.waitForElementByCss('#not-found-component') | ||
}) | ||
.text() | ||
).toBe('Result Page!') | ||
}) | ||
|
||
it('should allow navigating to a page calling notfound', async () => { | ||
const browser = await next.browser('/') | ||
it('should allow navigation on error', async () => { | ||
const browser = await next.browser('/trigger-error') | ||
expect(await browser.elementByCss('#error-component').text()).toBe( | ||
'Error Happened!' | ||
) | ||
|
||
expect( | ||
await browser | ||
.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('#trigger-404-link') | ||
.elementByCss('#to-result') | ||
.click() | ||
.waitForElementByCss('#not-found-component') | ||
.waitForElementByCss('#result-page') | ||
.text() | ||
).toBe('Result Page!') | ||
}) | ||
|
||
expect(await browser.elementByCss('#not-found-component').text()).toBe( | ||
'Not Found!' | ||
) | ||
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!' | ||
) | ||
|
||
await browser.back().waitForElementByCss('#homepage') | ||
await browser | ||
.elementByCss('#to-result') | ||
.click() | ||
.waitForElementByCss('#result-page') | ||
.back() | ||
.waitForElementByCss('#not-found-component') | ||
}) | ||
|
||
expect(await browser.elementByCss('#homepage').text()).toBe('Home') | ||
}) | ||
it('should allow navigating to a page calling notfound', async () => { | ||
const browser = await next.browser('/') | ||
|
||
it('should allow navigating to a non-existent page', async () => { | ||
const browser = await next.browser('/') | ||
await browser | ||
.elementByCss('#trigger-404-link') | ||
.click() | ||
.waitForElementByCss('#not-found-component') | ||
|
||
await browser | ||
.elementByCss('#non-existent-link') | ||
.click() | ||
.waitForElementByCss('#not-found-component') | ||
expect(await browser.elementByCss('#not-found-component').text()).toBe( | ||
'Not Found!' | ||
) | ||
|
||
await browser.back().waitForElementByCss('#homepage') | ||
|
||
expect(await browser.elementByCss('#homepage').text()).toBe('Home') | ||
}) | ||
|
||
expect(await browser.elementByCss('#not-found-component').text()).toBe( | ||
'Not Found!' | ||
) | ||
it('should allow navigating to a non-existent page', async () => { | ||
const browser = await next.browser('/') | ||
|
||
await browser.back().waitForElementByCss('#homepage') | ||
await browser | ||
.elementByCss('#non-existent-link') | ||
.click() | ||
.waitForElementByCss('#not-found-component') | ||
|
||
expect(await browser.elementByCss('#homepage').text()).toBe('Home') | ||
}) | ||
expect(await browser.elementByCss('#not-found-component').text()).toBe( | ||
'Not Found!' | ||
) | ||
|
||
await browser.back().waitForElementByCss('#homepage') | ||
|
||
expect(await browser.elementByCss('#homepage').text()).toBe('Home') | ||
}) | ||
} | ||
|
||
createNextDescribe( | ||
'app dir - not found navigation', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
runTest({ next }) | ||
} | ||
) | ||
|
||
createNextDescribe( | ||
'app dir - not found navigation - with overridden node env', | ||
{ | ||
files: __dirname, | ||
env: { NODE_ENV: 'test' }, | ||
}, | ||
({ next }) => { | ||
runTest({ next }) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters