Skip to content

Commit e6eb4c6

Browse files
committed
use test id to locate element
1 parent ba3bf14 commit e6eb4c6

4 files changed

Lines changed: 16 additions & 22 deletions

File tree

e2e/react-router/basic-file-based/src/routes/hover-preload-hash.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ export const Route = createFileRoute('/hover-preload-hash')({
55
})
66

77
function Page() {
8-
return (
9-
<>
10-
<div className="p-2">Hello from About!</div>
11-
<Link
12-
to="/hover-preload-hash"
13-
hash={'position1'}
14-
className="[&.active]:font-bold"
15-
>
16-
To hash
17-
</Link>
8+
9+
return <>
10+
11+
<div className="p-2">Hello from About!</div>
12+
<Link to="/hover-preload-hash" hash={"position1"} className="[&.active]:font-bold" data-testid="link-to-hash">
13+
To hash
14+
</Link>
1815

1916
<p>
2017
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy

e2e/react-router/basic-file-based/tests/hover-preload-hash.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('clicking hash link then hovering another link does not scroll back to hash
88
await page.goto(toRuntimePath('/hover-preload-hash'))
99

1010
// Click the hash link to navigate to position1
11-
await page.getByRole('link', { name: 'To hash' }).click()
11+
await page.getByTestId('link-to-hash').click()
1212
await expect(page.locator('#position1')).toBeInViewport()
1313

1414
// Scroll up so position1 is no longer in view

e2e/solid-router/basic-file-based/src/routes/hover-preload-hash.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ export const Route = createFileRoute('/hover-preload-hash')({
55
})
66

77
function Page() {
8-
return (
9-
<>
10-
<div class="p-2">Hello from About!</div>
11-
<Link
12-
to="/hover-preload-hash"
13-
hash={'position1'}
14-
class="[&.active]:font-bold"
15-
>
16-
To hash
17-
</Link>
8+
9+
return <>
10+
11+
<div class="p-2">Hello from About!</div>
12+
<Link to="/hover-preload-hash" hash={"position1"} class="[&.active]:font-bold" data-testid="link-to-hash">
13+
To hash
14+
</Link>
1815

1916
<p>
2017
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy

e2e/solid-router/basic-file-based/tests/hover-preload-hash.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('clicking hash link then hovering another link does not scroll back to hash
88
await page.goto(toRuntimePath('/hover-preload-hash'))
99

1010
// Click the hash link to navigate to position1
11-
await page.getByRole('link', { name: 'To hash' }).click()
11+
await page.getByTestId('link-to-hash').click()
1212
await expect(page.locator('#position1')).toBeInViewport()
1313

1414
// Scroll up so position1 is no longer in view

0 commit comments

Comments
 (0)