Skip to content

Commit

Permalink
Fix domain locales not available on client (#26083)
Browse files Browse the repository at this point in the history
* bug: Fix domain locales not available on client

* Add test case

* update tests

Co-authored-by: JJ Kasper <[email protected]>
  • Loading branch information
RobVermeer and ijjk authored Jun 22, 2021
1 parent 005a6e4 commit 27d78a5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/next/client/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const urlPropertyFields = [
'isReady',
'isPreview',
'isLocaleDomain',
'domainLocales',
]
const routerEvents = [
'routeChangeStart',
Expand Down
2 changes: 1 addition & 1 deletion test/integration/build-output/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Build Output', () => {
expect(parseFloat(err404Size)).toBeCloseTo(gz ? 3.17 : 8.51, 1)
expect(err404Size.endsWith('kB')).toBe(true)

expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.9 : 204, 1)
expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.9 : 205, 1)
expect(err404FirstLoad.endsWith('kB')).toBe(true)

expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.7 : 196, 1)
Expand Down
1 change: 1 addition & 0 deletions test/integration/i18n-support-base-path/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function Page(props) {
<p id="router-locale">{router.locale}</p>
<p id="router-default-locale">{router.defaultLocale}</p>
<p id="router-locales">{JSON.stringify(router.locales)}</p>
<p id="router-domain-locales">{JSON.stringify(router.domainLocales)}</p>
<p id="router-query">{JSON.stringify(router.query)}</p>
<p id="router-pathname">{router.pathname}</p>
<p id="router-as-path">{router.asPath}</p>
Expand Down
1 change: 1 addition & 0 deletions test/integration/i18n-support/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function Page(props) {
<p id="router-locale">{router.locale}</p>
<p id="router-default-locale">{router.defaultLocale}</p>
<p id="router-locales">{JSON.stringify(router.locales)}</p>
<p id="router-domain-locales">{JSON.stringify(router.domainLocales)}</p>
<p id="router-query">{JSON.stringify(router.query)}</p>
<p id="router-pathname">{router.pathname}</p>
<p id="router-as-path">{router.asPath}</p>
Expand Down
15 changes: 15 additions & 0 deletions test/integration/i18n-support/test/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ async function addDefaultLocaleCookie(browser) {
}

export function runTests(ctx) {
it.only('should have domainLocales available on useRouter', async () => {
const browser = await webdriver(ctx.appPort, `${ctx.basePath || '/'}`)
expect(
JSON.parse(await browser.elementByCss('#router-domain-locales').text())
).toEqual([
{
http: true,
domain: 'example.do',
defaultLocale: 'do',
locales: ['do-BE'],
},
{ domain: 'example.com', defaultLocale: 'go', locales: ['go-BE'] },
])
})

it('should not error with similar named cookie to locale cookie', async () => {
const res = await fetchViaHTTP(
ctx.appPort,
Expand Down

0 comments on commit 27d78a5

Please sign in to comment.