mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
44 lines
1.2 KiB
test.runIf(process.env.VITE_TEST_BUILD)(
|
|
'prefetches SVG links without errors and respects new-tab targets',
|
|
async () => {
|
|
const errors: string[] = []
|
|
const onPageError = (error: Error) => errors.push(error.message)
|
|
page.on('pageerror', onPageError)
|
|
|
|
try {
|
|
await goto('/prefetch/')
|
|
|
|
await expect
|
|
.poll(
|
|
async () => ({
|
|
errors,
|
|
pages: await page
|
|
.locator('link[rel="prefetch"]')
|
|
.evaluateAll((links) =>
|
|
links
|
|
.map(
|
|
(link) =>
|
|
link
|
|
.getAttribute('href')
|
|
?.match(/prefetch_(.*?)\.md\./)?.[1]
|
|
)
|
|
.filter(Boolean)
|
|
.sort()
|
|
)
|
|
}),
|
|
{ timeout: 10_000 }
|
|
)
|
|
.toEqual({ errors: [], pages: ['html', 'svg', 'xlink'] })
|
|
|
|
await page.locator('svg a[href="./svg.html"]').click()
|
|
await page.waitForSelector('h1', { state: 'visible' })
|
|
await expect
|
|
.poll(() => page.locator('h1').textContent())
|
|
.toContain('SVG link destination')
|
|
expect(errors).toEqual([])
|
|
} finally {
|
|
page.off('pageerror', onPageError)
|
|
}
|
|
}
|
|
)
|