Skip to content

Commit ccc290b

Browse files
authored
Merge branch 'main' into feat/install-command-icons
2 parents e020042 + 8498f68 commit ccc290b

4 files changed

Lines changed: 27 additions & 30 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The aim of [npmx.dev](https://npmx.dev) is to provide a better browser for the n
2121
## Shortcuts
2222

2323
> [!IMPORTANT]
24-
> We're keeping the website, repository, and our discord community low-profile until the browser is polished enough. We'll do a formal announcement at that point. Please avoid sharing the website or the invite link to discord on social media directly. The repo is public, so people who care about the project can easily find it and join us. Anyone who wants to help is more than welcome to [join the community](https://chat.npm.dev). If you know others who would be interested, please invite them too!
24+
> We're keeping the website, repository, and our discord community low-profile until the browser is polished enough. We'll do a formal announcement at that point. Please avoid sharing the website or the invite link to discord on social media directly. The repo is public, so people who care about the project can easily find it and join us. Anyone who wants to help is more than welcome to [join the community](https://chat.npmx.dev). If you know others who would be interested, please invite them too!
2525
2626
- [chat.npmx.dev](https://chat.npmx.dev) - Discord Server
2727
- [social.npmx.dev](https://social.npmx.dev) - Bluesky Profile

app/pages/search.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ const { data: results, status } = useNpmSearch(query, () => ({
8989
}))
9090
9191
// Keep track of previous results to show while loading
92-
const previousQuery = ref('')
92+
// Use useState so the value persists from SSR to client hydration
93+
const previousQuery = useState('search-previous-query', () => query.value)
9394
const cachedResults = ref(results.value)
9495
9596
// Update cached results smartly

tests/docs.spec.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,29 @@ test.describe('Version Selector', () => {
141141

142142
await versionButton.click()
143143

144-
// Find a different version and click it
145-
const differentVersion = page.locator('[role="option"]').filter({ hasNotText: '1.6.3' }).first()
144+
// Find a version link that's not the current version by checking the href
145+
const versionLinks = page.locator('[role="option"] a[href*="/docs/ufo/v/"]')
146+
const count = await versionLinks.count()
147+
148+
// Find first link that doesn't point to 1.6.3
149+
let targetHref: string | null = null
150+
for (let i = 0; i < count; i++) {
151+
const href = await versionLinks.nth(i).getAttribute('href')
152+
if (href && !href.includes('/v/1.6.3')) {
153+
targetHref = href
154+
await versionLinks.nth(i).click()
155+
break
156+
}
157+
}
146158

147159
// Skip if no other versions available
148-
if (!(await differentVersion.isVisible())) {
160+
if (!targetHref) {
149161
test.skip()
150162
return
151163
}
152164

153-
const versionText = await differentVersion.textContent()
154-
await differentVersion.click()
155-
156-
// URL should change to the new version
157-
if (versionText) {
158-
const versionMatch = versionText.match(/\d+\.\d+\.\d+/)
159-
if (versionMatch) {
160-
await expect(page).toHaveURL(new RegExp(`/docs/ufo/v/${versionMatch[0]}`))
161-
}
162-
}
165+
// URL should match the href we clicked
166+
await expect(page).toHaveURL(new RegExp(targetHref.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')))
163167
})
164168

165169
test('escape key closes version dropdown', async ({ page, goto }) => {

tests/interactions.spec.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,18 @@ test.describe('Search Pages', () => {
1212
const firstResult = page.locator('[data-result-index="0"]').first()
1313
await expect(firstResult).toBeVisible()
1414

15-
// First result is selected by default, Enter navigates to it
16-
// URL is /vue not /package/vue (cleaner URLs)
17-
await page.keyboard.press('Enter')
18-
await expect(page).toHaveURL(/\/vue/)
19-
20-
await page.goBack()
21-
// Wait for search page to be ready
22-
await expect(page).toHaveURL(/\/search/)
23-
await expect(page.locator('text=/found \\d+/i')).toBeVisible()
24-
// Search input is autofocused on mount
25-
await expect(searchInput).toBeFocused()
26-
2715
// ArrowDown changes visual selection but keeps focus in input
2816
await page.keyboard.press('ArrowDown')
2917
await expect(searchInput).toBeFocused()
3018

31-
// Enter navigates to the now-selected second result
19+
// ArrowUp goes back to first result
20+
await page.keyboard.press('ArrowUp')
21+
await expect(searchInput).toBeFocused()
22+
23+
// First result is selected, Enter navigates to it
24+
// URL is /vue not /package/vue (cleaner URLs)
3225
await page.keyboard.press('Enter')
33-
// Second result could be vue-router, vuex, etc - just check we navigated away
34-
await expect(page).not.toHaveURL(/\/search/)
26+
await expect(page).toHaveURL(/\/vue/)
3527
})
3628

3729
test('/search?q=vue → "/" focuses the search input from results', async ({ page, goto }) => {

0 commit comments

Comments
 (0)