test: add route-provider e2e test (#24195)

This commit is contained in:
Daniel Roe 2023-11-09 03:21:19 +00:00 committed by GitHub
parent 56147b4a86
commit 9bab21edbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 0 deletions

View File

@ -1291,6 +1291,17 @@ describe('page key', () => {
})
})
describe('route provider', () => {
it('should preserve current route when navigation is suspended', async () => {
const { page } = await renderPage('/route-provider/foo')
await page.click('[href="/route-provider/bar"]')
expect(await page.getByTestId('foo').innerText()).toMatchInlineSnapshot('"foo: /route-provider/foo - /route-provider/foo"')
expect(await page.getByTestId('bar').innerText()).toMatchInlineSnapshot('"bar: /route-provider/bar - /route-provider/bar"')
await page.close()
})
})
// Bug #6592
describe('layout change not load page twice', () => {
const cases = {

View File

@ -0,0 +1,11 @@
<template>
<div>
<NuxtPage />
<NuxtLink to="/route-provider/foo">
foo
</NuxtLink>
<NuxtLink to="/route-provider/bar">
bar
</NuxtLink>
</div>
</template>

View File

@ -0,0 +1,14 @@
<script setup lang="ts">
const route = useRoute()
await new Promise(resolve => setTimeout(resolve, 100))
</script>
<template>
<div data-testid="bar">
bar: {{ $route.path }} - {{ route.path }}
</div>
</template>
<style scoped>
</style>

View File

@ -0,0 +1,14 @@
<script setup lang="ts">
const route = useRoute()
await new Promise(resolve => setTimeout(resolve, 100))
</script>
<template>
<div data-testid="foo">
foo: {{ $route.path }} - {{ route.path }}
</div>
</template>
<style scoped>
</style>