test: trigger logging with client-side navigation

This commit is contained in:
Daniel Roe 2024-10-11 14:17:01 +01:00
parent 2984d3f66a
commit 1edb8d2d7a
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -625,6 +625,17 @@ describe('pages', () => {
const html = await $fetch('/prerender/test')
expect(html).toContain('should be prerendered: true')
})
it('should trigger page:loading:end only once', async () => {
const { page, consoleLogs } = await renderPage('/')
await page.getByText('to page load hook').click()
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/page-load-hook')
const loadingEndLogs = consoleLogs.filter(c => c.text.includes('page:loading:end'))
expect(loadingEndLogs.length).toBe(1)
await page.close()
})
})
describe('nuxt composables', () => {
@ -2854,15 +2865,3 @@ describe('namespace access to useNuxtApp', () => {
await page.close()
})
})
describe('page hook', () => {
it('should trigger page:loading:end only once', async () => {
const { page, consoleLogs } = await renderPage()
await page.goto(url('/page-load-hook'))
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/page-load-hook')
const loadingEndLogs = consoleLogs.filter(c => c.text.includes('page:loading:end'))
expect(loadingEndLogs.length).toBe(1)
await page.close()
})
})