File size: 1,360 Bytes
1e92f2d | 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 43 44 | import { nextTestSetup } from 'e2e-utils'
describe('i18n-navigations-middleware', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should respect selected locale when navigating to a dynamic route', async () => {
const browser = await next.browser('/')
// change to "de" locale
await browser.elementByCss("[href='/de']").click()
const dynamicLink = await browser.waitForElementByCss(
"[href='/de/dynamic/1']"
)
expect(await browser.elementById('current-locale').text()).toBe(
'Current locale: de'
)
// navigate to dynamic route
await dynamicLink.click()
// the locale should still be "de"
expect(await browser.elementById('dynamic-locale').text()).toBe(
'Locale: de'
)
})
it('should respect selected locale when navigating to a static route', async () => {
const browser = await next.browser('/')
// change to "de" locale
await browser.elementByCss("[href='/de']").click()
const staticLink = await browser.waitForElementByCss("[href='/de/static']")
expect(await browser.elementById('current-locale').text()).toBe(
'Current locale: de'
)
// navigate to static route
await staticLink.click()
// the locale should still be "de"
expect(await browser.elementById('static-locale').text()).toBe('Locale: de')
})
})
|