test: add test for parallel routes hmr (#67392)

### What?

A test for #67222
This commit is contained in:
hrmny 2024-07-02 17:07:16 +02:00 committed by GitHub
parent 18c2fa85ab
commit a22858d6e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 56 additions and 0 deletions

View file

@ -0,0 +1,3 @@
export default function BarPage() {
return <div id="bar">Bar Page</div>
}

View file

@ -0,0 +1,3 @@
export default function FooPage() {
return <div id="foo">Foo Page</div>
}

View file

@ -0,0 +1,14 @@
import { ReactNode } from 'react'
function Layout(props: { foo: ReactNode; bar: ReactNode }) {
return (
<html>
<body>
{props.foo}
{props.bar}
</body>
</html>
)
}
export default Layout

View file

@ -0,0 +1,30 @@
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
describe('hmr-parallel-routes', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should update parallel routes via HMR', async () => {
const browser = await next.browser('/')
expect(await browser.elementByCss('#bar').text()).toBe('Bar Page')
expect(await browser.elementByCss('#foo').text()).toBe('Foo Page')
await next.patchFile('app/@bar/page.tsx', (content) =>
content.replace('Bar Page', 'Bar Page Updated')
)
await assertNoRedbox(browser)
expect(await browser.elementByCss('#bar').text()).toBe('Bar Page Updated')
await next.patchFile('app/@foo/page.tsx', (content) =>
content.replace('Foo Page', 'Foo Page Updated')
)
await assertNoRedbox(browser)
expect(await browser.elementByCss('#foo').text()).toBe('Foo Page Updated')
})
})

View file

@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}
module.exports = nextConfig