Skip to content

Commit 2852acb

Browse files
committed
add test
1 parent 9d6c63b commit 2852acb

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

e2e/solid-router/basic/src/main.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,23 @@ function RootComponent() {
7171
}}
7272
>
7373
This Route Does Not Exist
74-
</Link>
74+
</Link>{' '}
75+
<div class="flex items-center">
76+
<svg width="20" height="20" viewBox="0 0 20 20" role="img">
77+
<title id="rectTitle">Link in SVG</title>
78+
<Link to="/posts" aria-label="Open posts from SVG">
79+
<rect
80+
x="0"
81+
y="0"
82+
width="20"
83+
height="20"
84+
rx="4"
85+
fill="blue"
86+
stroke-width="2"
87+
/>
88+
</Link>
89+
</svg>
90+
</div>
7591
</div>
7692
<Outlet />
7793
<TanStackRouterDevtools position="bottom-right" />

e2e/solid-router/basic/tests/app.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { expect, test } from '@playwright/test'
2+
import { getTestServerPort } from '@tanstack/router-e2e-utils'
3+
import packageJson from '../package.json' with { type: 'json' }
4+
5+
const PORT = await getTestServerPort(packageJson.name)
26

37
test.beforeEach(async ({ page }) => {
48
await page.goto('/')
@@ -45,3 +49,16 @@ test('Navigating to a post page with viewTransition types', async ({
4549
await page.getByRole('link', { name: 'sunt aut facere repe' }).click()
4650
await expect(page.getByRole('heading')).toContainText('sunt aut facere')
4751
})
52+
53+
test('Link in SVG does not trigger a full page reload', async ({ page }) => {
54+
let fullPageLoad = false
55+
page.on('domcontentloaded', () => {
56+
fullPageLoad = true
57+
})
58+
59+
await page.getByRole('link', { name: 'Open posts from SVG' }).click()
60+
const url = `http://localhost:${PORT}/posts`
61+
await page.waitForURL(url)
62+
63+
expect(fullPageLoad).toBeFalsy()
64+
})

0 commit comments

Comments
 (0)