Skip to content

Commit 8cee51b

Browse files
committed
test: refactor to separate test file
1 parent ed93729 commit 8cee51b

2 files changed

Lines changed: 39 additions & 36 deletions

File tree

tests/interactions.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { expect, test } from '@nuxt/test-utils/playwright'
2+
3+
test.describe('Search Pages', () => {
4+
test('/search?q=vue → keyboard navigation (arrow keys + enter)', async ({ page, goto }) => {
5+
await goto('/search?q=vue', { waitUntil: 'domcontentloaded' })
6+
7+
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
8+
9+
const searchInput = page.locator('input[type="search"]')
10+
await expect(searchInput).toBeFocused()
11+
12+
const firstResult = page.locator('[data-result-index="0"]').first()
13+
await expect(firstResult).toBeVisible()
14+
15+
await page.keyboard.press('Enter')
16+
await expect(page).toHaveURL(/\/package\//)
17+
18+
await page.goBack()
19+
await expect(searchInput).toBeFocused()
20+
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
21+
22+
await page.keyboard.press('ArrowDown')
23+
const secondResult = page.locator('[data-result-index="1"]').first()
24+
await expect(secondResult).toBeFocused()
25+
26+
await page.keyboard.press('Enter')
27+
await expect(page).toHaveURL(/\/package\//)
28+
})
29+
30+
test('/search?q=vue → "/" focuses the search input from results', async ({ page, goto }) => {
31+
await goto('/search?q=vue', { waitUntil: 'domcontentloaded' })
32+
33+
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
34+
35+
await page.locator('[data-result-index="0"]').first().focus()
36+
await page.keyboard.press('/')
37+
await expect(page.locator('input[type="search"]')).toBeFocused()
38+
})
39+
})

tests/url-compatibility.spec.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -54,42 +54,6 @@ test.describe('npmjs.com URL Compatibility', () => {
5454
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
5555
})
5656

57-
test('/search?q=vue → keyboard navigation (arrow keys + enter)', async ({ page, goto }) => {
58-
await goto('/search?q=vue', { waitUntil: 'domcontentloaded' })
59-
60-
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
61-
62-
const searchInput = page.locator('input[type="search"]')
63-
await expect(searchInput).toBeFocused()
64-
65-
const firstResult = page.locator('[data-result-index="0"]').first()
66-
await expect(firstResult).toBeVisible()
67-
68-
await page.keyboard.press('Enter')
69-
await expect(page).toHaveURL(/\/package\//)
70-
71-
await page.goBack()
72-
await expect(searchInput).toBeFocused()
73-
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
74-
75-
await page.keyboard.press('ArrowDown')
76-
const secondResult = page.locator('[data-result-index="1"]').first()
77-
await expect(secondResult).toBeFocused()
78-
79-
await page.keyboard.press('Enter')
80-
await expect(page).toHaveURL(/\/package\//)
81-
})
82-
83-
test('/search?q=vue → "/" focuses the search input from results', async ({ page, goto }) => {
84-
await goto('/search?q=vue', { waitUntil: 'domcontentloaded' })
85-
86-
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
87-
88-
await page.locator('[data-result-index="0"]').first().focus()
89-
await page.keyboard.press('/')
90-
await expect(page.locator('input[type="search"]')).toBeFocused()
91-
})
92-
9357
test('/search?q=keywords:framework → keyword search', async ({ page, goto }) => {
9458
await goto('/search?q=keywords:framework', { waitUntil: 'domcontentloaded' })
9559

0 commit comments

Comments
 (0)