Skip to content

Commit 0791856

Browse files
test: update
1 parent a772aa3 commit 0791856

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

app/components/SearchBox.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const searchQuery = defineModel<string>({
1313
default: '',
1414
})
1515
16-
function handleSubmit(): void {
16+
function handleSubmit() {
1717
emit('submit', searchQuery.value)
1818
}
1919
@@ -38,7 +38,7 @@ defineExpose({
3838
<template>
3939
<search class="w-full @container">
4040
<form method="GET" action="/search" class="relative" @submit.prevent="handleSubmit">
41-
<label for="home-search" class="sr-only">
41+
<label for="search-box" class="sr-only">
4242
{{ $t('search.label') }}
4343
</label>
4444

@@ -55,12 +55,11 @@ defineExpose({
5555
</span>
5656

5757
<input
58-
id="home-search"
58+
id="search-box"
5959
ref="inputRef"
6060
v-model.trim="searchQuery"
6161
type="search"
6262
name="q"
63-
autofocus
6463
:placeholder="$t('search.placeholder')"
6564
v-bind="noCorrect"
6665
class="w-full bg-bg-subtle border border-border font-mono text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 motion-reduce:transition-none hover:border-fg-subtle outline-2 outline-transparent focus:border-accent focus-visible:(outline-2 outline-accent/70)"

test/e2e/interactions.spec.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,19 @@ test.describe('Search Pages', () => {
8888
test('/ (homepage) → search, keeps focus on search input', async ({ page, goto }) => {
8989
await goto('/', { waitUntil: 'hydration' })
9090

91-
const homeSearchInput = page.locator('#home-search')
92-
await homeSearchInput.click()
91+
const searchInput = page.locator('#search-box')
92+
await searchInput.click()
9393
await page.keyboard.type('vue')
94+
await page.keyboard.press('Enter')
9495

95-
// Wait for navigation to /search (debounce is 250ms)
9696
await expect(page).toHaveURL(/\/search/, { timeout: 10000 })
9797

9898
await expect(page.locator('[data-result-index="0"]').first()).toBeVisible({
9999
timeout: 15000,
100100
})
101101

102-
// Home search input should be gone (we're on /search now)
103-
await expect(homeSearchInput).not.toBeVisible()
104-
105-
// Header search input should now exist and be focused
106-
const headerSearchInput = page.locator('#header-search')
107-
await expect(headerSearchInput).toBeVisible()
108-
await expect(headerSearchInput).toBeFocused()
102+
await expect(searchInput).toBeVisible()
103+
await expect(searchInput).toBeFocused()
109104
})
110105

111106
test('/settings → search, keeps focus on search input', async ({ page, goto }) => {
@@ -116,14 +111,15 @@ test.describe('Search Pages', () => {
116111

117112
await searchInput.click()
118113
await searchInput.fill('vue')
114+
await page.keyboard.press('Enter')
119115

120116
await expect(page).toHaveURL(/\/search/, { timeout: 10000 })
121117

122118
await expect(page.locator('[data-result-index="0"]').first()).toBeVisible({
123119
timeout: 15000,
124120
})
125121

126-
const headerSearchInput = page.locator('#header-search')
122+
const headerSearchInput = page.locator('#search-box')
127123
await expect(headerSearchInput).toBeFocused()
128124
})
129125
})
@@ -167,15 +163,15 @@ test.describe('Keyboard Shortcuts', () => {
167163
test('"c" does not navigate when search input is focused', async ({ page, goto }) => {
168164
await goto('/settings', { waitUntil: 'hydration' })
169165

170-
const searchInput = page.locator('#header-search')
166+
const searchInput = page.locator('#search-box')
171167
await searchInput.focus()
172168
await expect(searchInput).toBeFocused()
173169

174170
await page.keyboard.press('c')
175171

176-
// Should still be on settings, not navigated to compare
172+
// // Should still be on settings, not navigated to compare
177173
await expect(page).toHaveURL(/\/settings/)
178-
// The 'c' should have been typed into the input
174+
// // The 'c' should have been typed into the input
179175
await expect(searchInput).toHaveValue('c')
180176
})
181177

@@ -208,7 +204,7 @@ test.describe('Keyboard Shortcuts', () => {
208204
test('"," does not navigate when any modifier key is pressed', async ({ page, goto }) => {
209205
await goto('/settings', { waitUntil: 'hydration' })
210206

211-
const searchInput = page.locator('#header-search')
207+
const searchInput = page.locator('#search-box')
212208
await searchInput.focus()
213209
await expect(searchInput).toBeFocused()
214210

@@ -227,7 +223,7 @@ test.describe('Keyboard Shortcuts', () => {
227223
test('"," does not navigate when search input is focused', async ({ page, goto }) => {
228224
await goto('/compare', { waitUntil: 'hydration' })
229225

230-
const searchInput = page.locator('#header-search')
226+
const searchInput = page.locator('#search-box')
231227
await searchInput.focus()
232228
await expect(searchInput).toBeFocused()
233229

0 commit comments

Comments
 (0)