diff --git a/specs/basic_usage.spec.ts b/specs/basic_usage.spec.ts index 8c2ab5127..6a37fe472 100644 --- a/specs/basic_usage.spec.ts +++ b/specs/basic_usage.spec.ts @@ -146,3 +146,23 @@ test('fallback to target lang', async () => { // current locale expect(await getText(page, '#lang-switcher-current-locale code')).toEqual('nl') }) + +test('(#2525) localePath should keep hash', async () => { + const { page } = await renderPage('/') + + expect(await page.locator('#link-about-hash').getAttribute('href')).toEqual('/about#my-hash') + expect(await page.locator('#link-about-hash-object').getAttribute('href')).toEqual('/about#my-hash') + + expect(await page.locator('#link-about-query-hash').getAttribute('href')).toEqual('/about?foo=bar#my-hash') + expect(await page.locator('#link-about-query-hash-object').getAttribute('href')).toEqual('/about?foo=bar#my-hash') + + // click `nl` lang switch with `` + await page.locator('#switch-locale-path-usages .switch-to-nl a').click() + await waitForURL(page, '/nl') + + expect(await page.locator('#link-about-hash').getAttribute('href')).toEqual('/nl/about#my-hash') + expect(await page.locator('#link-about-hash-object').getAttribute('href')).toEqual('/nl/about#my-hash') + + expect(await page.locator('#link-about-query-hash').getAttribute('href')).toEqual('/nl/about?foo=bar#my-hash') + expect(await page.locator('#link-about-query-hash-object').getAttribute('href')).toEqual('/nl/about?foo=bar#my-hash') +}) diff --git a/specs/fixtures/basic_usage/pages/index.vue b/specs/fixtures/basic_usage/pages/index.vue index ef4d6af32..53e016423 100644 --- a/specs/fixtures/basic_usage/pages/index.vue +++ b/specs/fixtures/basic_usage/pages/index.vue @@ -81,6 +81,27 @@ useHead({ {{ category.title }} +
  • + {{ $t('about') }} +
  • +
  • + + {{ $t('about') }} + +
  • +
  • + {{ + $t('about') + }} +
  • +
  • + + {{ $t('about') }} + +