mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
4b66771895
The `legacyBehavior` prop of the `Link` component has been deprecated since #77473. For Next.js 16, we're finally removing support for it. Consequently, we're also removing support for the `passHref` prop, which was only useful in conjunction with the `legacyBehavior` prop. A [codemod is available](https://nextjs.org/docs/app/guides/upgrading/codemods#new-link) to help you automatically upgrade your codebase. reverts #77473 --------- Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
/* eslint-env jest */
|
|
|
|
import { waitFor } from 'next-test-utils'
|
|
import path from 'path'
|
|
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('Client Navigation', () => {
|
|
const { next } = nextTestSetup({
|
|
files: path.join(__dirname, 'fixture'),
|
|
env: {
|
|
TEST_STRICT_NEXT_HEAD: String(true),
|
|
},
|
|
})
|
|
|
|
describe('with <a/> tag inside the <Link />', () => {
|
|
it('should navigate the page', async () => {
|
|
const browser = await next.browser('/nav/about')
|
|
const text = await browser
|
|
.elementByCss('#home-link')
|
|
.click()
|
|
.waitForElementByCss('.nav-home')
|
|
.elementByCss('p')
|
|
.text()
|
|
|
|
expect(text).toBe('This is the home.')
|
|
await browser.close()
|
|
})
|
|
|
|
it('should not navigate if the <a/> tag has a target', async () => {
|
|
const browser = await next.browser('/nav')
|
|
|
|
await browser
|
|
.elementByCss('#increase')
|
|
.click()
|
|
.elementByCss('#target-link')
|
|
.click()
|
|
|
|
await waitFor(1000)
|
|
|
|
const counterText = await browser.elementByCss('#counter').text()
|
|
|
|
expect(counterText).toBe('Counter: 1')
|
|
await browser.close()
|
|
})
|
|
|
|
it('should not navigate if the click-event is modified', async () => {
|
|
const browser = await next.browser('/nav')
|
|
|
|
await browser.elementByCss('#increase').click()
|
|
|
|
const key = process.platform === 'darwin' ? 'Meta' : 'Control'
|
|
|
|
await browser.keydown(key)
|
|
|
|
await browser.elementByCss('#in-svg-link').click()
|
|
|
|
await browser.keyup(key)
|
|
await waitFor(1000)
|
|
|
|
const counterText = await browser.elementByCss('#counter').text()
|
|
|
|
expect(counterText).toBe('Counter: 1')
|
|
await browser.close()
|
|
})
|
|
|
|
it('should not reload when link in svg is clicked', async () => {
|
|
const browser = await next.browser('/nav')
|
|
await browser.eval('window.hello = true')
|
|
await browser
|
|
.elementByCss('#in-svg-link')
|
|
.click()
|
|
.waitForElementByCss('.nav-about')
|
|
|
|
expect(await browser.eval('window.hello')).toBe(true)
|
|
await browser.close()
|
|
})
|
|
})
|
|
})
|