-
Notifications
You must be signed in to change notification settings - Fork 463
/
disable.spec.ts
45 lines (37 loc) · 1.21 KB
/
disable.spec.ts
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
45
import { test, expect } from 'vitest'
import { fileURLToPath } from 'node:url'
import { setup, url, createPage } from '@nuxt/test-utils'
import { getText } from '../helper'
await setup({
rootDir: fileURLToPath(new URL(`../fixtures/basic`, import.meta.url)),
browser: true,
// overrides
nuxtConfig: {
i18n: {
strategy: 'no_prefix',
detectBrowserLanguage: false
}
}
})
test('disable', async () => {
const home = url('/')
const page = await createPage(undefined, { locale: 'en' })
await page.goto(home)
const ctx = await page.context()
// click `fr` lang switch link
await page.locator('#set-locale-link-fr').click()
await page.waitForTimeout(100)
expect(await ctx.cookies()).toMatchObject([])
// navigate to about
await page.goto(url('/about'))
// set default locale
expect(await getText(page, '#lang-switcher-current-locale code')).toEqual('en')
// click `fr` lang switch link
await page.locator('#set-locale-link-fr').click()
await page.waitForTimeout(100)
// navigate with home link
await page.locator('#link-home').click()
await page.waitForTimeout(100)
// set default locale
expect(await getText(page, '#lang-switcher-current-locale code')).toEqual('fr')
})