|
| 1 | +import { nextTestSetup } from 'e2e-utils' |
| 2 | + |
| 3 | +describe('i18n-navigations-middleware', () => { |
| 4 | + const { next } = nextTestSetup({ |
| 5 | + files: __dirname, |
| 6 | + }) |
| 7 | + |
| 8 | + it('should respect selected locale when navigating to a dynamic route', async () => { |
| 9 | + const browser = await next.browser('/') |
| 10 | + // change to "de" locale |
| 11 | + await browser.elementByCss("[href='/de']").click() |
| 12 | + const dynamicLink = await browser.waitForElementByCss( |
| 13 | + "[href='/de/dynamic/1']" |
| 14 | + ) |
| 15 | + expect(await browser.elementById('current-locale').text()).toBe( |
| 16 | + 'Current locale: de' |
| 17 | + ) |
| 18 | + |
| 19 | + // navigate to dynamic route |
| 20 | + await dynamicLink.click() |
| 21 | + |
| 22 | + // the locale should still be "de" |
| 23 | + expect(await browser.elementById('dynamic-locale').text()).toBe( |
| 24 | + 'Locale: de' |
| 25 | + ) |
| 26 | + }) |
| 27 | + |
| 28 | + it('should respect selected locale when navigating to a static route', async () => { |
| 29 | + const browser = await next.browser('/') |
| 30 | + // change to "de" locale |
| 31 | + await browser.elementByCss("[href='/de']").click() |
| 32 | + const staticLink = await browser.waitForElementByCss("[href='/de/static']") |
| 33 | + expect(await browser.elementById('current-locale').text()).toBe( |
| 34 | + 'Current locale: de' |
| 35 | + ) |
| 36 | + |
| 37 | + // navigate to static route |
| 38 | + await staticLink.click() |
| 39 | + |
| 40 | + // the locale should still be "de" |
| 41 | + expect(await browser.elementById('static-locale').text()).toBe('Locale: de') |
| 42 | + }) |
| 43 | +}) |
0 commit comments