Skip to content

Commit

Permalink
tweak e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Nov 21, 2022
1 parent 378e2de commit 493bb8f
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 11 deletions.
2 changes: 2 additions & 0 deletions specs/browser_language_detection/cookie.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ test('detection with cookie', async () => {

// navigate with home link
await page.locator('#link-home').click()
await page.waitForTimeout(100)

// locale in home
expect(await getText(page, '#lang-switcher-current-locale code')).toEqual('fr')

// click `fr` lang switch link
await page.locator('#set-locale-link-en').click()
await page.waitForTimeout(100)
expect(await ctx.cookies()).toMatchObject([{ name: 'my_custom_cookie_name', value: 'en' }])
})
3 changes: 3 additions & 0 deletions specs/browser_language_detection/disable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test('disable', async () => {

// 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
Expand All @@ -33,9 +34,11 @@ test('disable', async () => {

// 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('en')
Expand Down
8 changes: 4 additions & 4 deletions specs/custom_route_paths/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ test('can access to custom route path', async () => {
await page.goto(home)

await page.locator('#link-blog').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(500)

expect(await page.url()).include('/blog-us')

await page.goBack()
await page.locator('#lang-switcher-with-nuxt-link a').click()

await page.locator('#link-blog').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

expect(await page.url()).include('/fr/a-blog')
})
Expand All @@ -39,15 +39,15 @@ test('can access to custom dynamic route path', async () => {
await page.goto(home)

await page.locator('#link-category').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

expect(await page.url()).include('/categories/foo')

await page.goBack()
await page.locator('#lang-switcher-with-nuxt-link a').click()

await page.locator('#link-category').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

expect(await page.url()).include(encodeURI('/fr/catégories/foo'))
})
6 changes: 4 additions & 2 deletions specs/custom_route_paths/module_configration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ test('can access to custom route path', async () => {

// click `fr` switching link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// page path
expect(await getData(page, '#home-use-async-data')).toMatchObject({ aboutPath: '/fr/about-fr' })

// navigate to about page for `fr`
await page.locator('#link-about').click()
await page.waitForTimeout(100)

expect(await getText(page, '#about-header')).toEqual('À propos')
expect(await getText(page, '#lang-switcher-current-locale code')).toEqual('fr')
Expand All @@ -52,13 +54,13 @@ test('can access to custom nested route path', async () => {

// navigate to blog index page
await page.locator('#link-blog').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

expect(await page.url()).include('/news')

// navigate to blog article page
await page.locator('#link-blog-article').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

expect(await page.url()).include('/news/article')
})
1 change: 1 addition & 0 deletions specs/ignoring_localized_route/disable/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test('can not access to disable route path', async () => {

// click `fr` switching link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// disalbe href with <NuxtLink>
expect(await page.locator('#link-ignore-disable').getAttribute('href')).toBe(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test('can not access to disable route path', async () => {

// click `fr` switching link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// disalbe href with <NuxtLink>
expect(await page.locator('#link-about').getAttribute('href')).toBe(null)
Expand Down
1 change: 1 addition & 0 deletions specs/ignoring_localized_route/pick/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test('can not access to pick route path', async () => {

// click `fr` switching link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// pick href with <NuxtLink>
expect(await page.locator('#link-ignore-pick').getAttribute('href')).toBe('/fr/ignore-routes/pick')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test('can not access to pick route path', async () => {

// click `fr` switching link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// disalbe href with <NuxtLink>
expect(await page.locator('#link-about').getAttribute('href')).toBe(null)
Expand Down
1 change: 1 addition & 0 deletions specs/routing_strategies/no_prefix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('strategy: no_prefix', async () => {

// click `fr` lang switch link (`setLocale`)
await page.locator('#lang-switcher-with-set-locale a').click()
await page.waitForTimeout(100)

// `fr` rendering
expect(await getText(page, '#home-header')).toEqual('Accueil')
Expand Down
1 change: 1 addition & 0 deletions specs/routing_strategies/prefix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('strategy: prefix', async () => {

// click `fr` lang switch link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// `fr` rendering
expect(await getText(page, '#home-header')).toEqual('Accueil')
Expand Down
5 changes: 3 additions & 2 deletions specs/routing_strategies/prefix_and_default.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe('strategy: prefix_and_default', async () => {

// click `fr` lang switch link with NuxtLink
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// `fr` rendering
expect(await getText(page, '#home-header')).toEqual('Accueil')
Expand All @@ -125,9 +126,9 @@ describe('strategy: prefix_and_default', async () => {

// click `en` and `fr` lang switch link with setLocale
await page.locator('#set-locale-link-en').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)
await page.locator('#set-locale-link-fr').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

// navigation URL
expect(await page.url()).toEqual(url('/fr'))
Expand Down
5 changes: 3 additions & 2 deletions specs/routing_strategies/prefix_except_default.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('default strategy: prefix_except_default', async () => {

// click `fr` lang switch link with NuxtLink
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// `fr` rendering
expect(await getText(page, '#home-header')).toEqual('Accueil')
Expand All @@ -101,9 +102,9 @@ describe('default strategy: prefix_except_default', async () => {

// click `en` and `fr` lang switch link with setLocale
await page.locator('#set-locale-link-en').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)
await page.locator('#set-locale-link-fr').click()
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

// navigation URL
expect(await page.url()).toEqual(url('/fr'))
Expand Down
1 change: 1 addition & 0 deletions specs/seo/useHead.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ test('render with useHead', async () => {

// click `fr` lang switch link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)

// title tag
expect(await getText(page, 'title')).toMatch('Accueil')
Expand Down
2 changes: 2 additions & 0 deletions specs/vue_i18n_options_loader/success.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ test('load option successfully', async () => {

// click `fr` lang switch link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)
expect(await getText(page, '#home-header')).toEqual('Bonjour-le-monde!')

// click `en` lang switch link
await page.locator('#lang-switcher-with-nuxt-link a').click()
await page.waitForTimeout(100)
expect(await getText(page, '#home-header')).toEqual('Hello-World!')
})
2 changes: 1 addition & 1 deletion specs/vue_i18n_options_loader/warnning.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('warning in messages option', async () => {
const messages: string[] = []
page.on('console', msg => messages.push(msg.text()))
await page.goto(home)
await page.waitForTimeout(1000)
await page.waitForTimeout(100)

expect(messages[0]).include(
`[@nuxtjs/i18n]: Cannot include 'messages' option in 'vue-i18n.messages.options.ts'. Please use Lazy-load translations.`
Expand Down

0 comments on commit 493bb8f

Please sign in to comment.