Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test navigation between multiple root layouts #43762

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions test/e2e/app-dir/root-layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('app-dir root layout', () => {
),
},
dependencies: {
react: 'experimental',
'react-dom': 'experimental',
react: 'latest',
'react-dom': 'latest',
jankaifer marked this conversation as resolved.
Show resolved Hide resolved
},
})
})
Expand Down Expand Up @@ -215,5 +215,16 @@ describe('app-dir root layout', () => {
)
expect(await browser.eval('window.__TEST_NO_RELOAD')).toBeUndefined()
})

it('should correctly handle navigation between multiple root layouts', async () => {
const browser = await webdriver(next.url, '/root-layout-a')
browser.elementById('root-a')
expect(await browser.hasElementByCssSelector('#root-b')).toBeFalse()

browser.elementById('to-layout-b').click()
jankaifer marked this conversation as resolved.
Show resolved Hide resolved

browser.elementById('root-b')
jankaifer marked this conversation as resolved.
Show resolved Hide resolved
expect(await browser.hasElementByCssSelector('#root-a')).toBeFalse()
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'

export default function Layout({ children }) {
return (
<html>
<head></head>
<body>
<div id="root-a">{children}</div>
</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import Link from 'next/link'

export default function Page() {
return (
<Link href="../root-layout-b" id="link-to-b">
To b
</Link>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'

export default function Layout({ children }) {
return (
<html>
<head></head>
<body>
<div id="root-b">{children}</div>
</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import Link from 'next/link'

export default function Page() {
return (
<Link href="../root-layout-a" id="link-to-a">
To a
</Link>
)
}