Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/e2e/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ test.describe('ui mode smoke', () => {
expect(errors).toEqual([])
})

test('clicking an item updates the URL to /N (no double slash)', async ({ page }) => {
const errors = captureErrors(page)
await page.goto(`${BASE}/`)
await expect(page.locator('[data-testid="navbar"]')).toBeVisible({ timeout: 10_000 })

const row = page.locator('[data-testid="item-row"]').first()
await expect(row).toBeVisible({ timeout: 10_000 })
const number = await row.getAttribute('data-item-number')

await row.click()
// Regression: UI-mode selection must produce `/N`, never `//N` (which
// vue-router can't match — see useSelectedItemSync.buildBase).
await expect(page).toHaveURL(`${BASE}/${number}`)
// The selected row is still mounted (view not torn down by a bad redirect).
await expect(page.locator(`[data-testid="item-row"][data-item-number="${number}"]`)).toBeVisible()
expect(errors).toEqual([])
})

test('Cmd+K opens the command palette and filters by query', async ({ page }) => {
const errors = captureErrors(page)
await page.goto(`${BASE}/`)
Expand Down
6 changes: 3 additions & 3 deletions ui/composables/useSelectedItemSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export function useSelectedItemSync(projectId: MaybeRefOrGetter<string>, initial
function buildBase(id: string): string {
const mode = hub.capabilities.value?.mode
if (mode !== 'hub')
return '/'
return ''
const project = hub.projects.value.find(p => p.id === id)
return project ? `/${project.repo}` : '/'
return project ? `/${project.repo}` : ''
}

// Apply the URL number on mount/route change.
Expand All @@ -50,7 +50,7 @@ export function useSelectedItemSync(projectId: MaybeRefOrGetter<string>, initial
if (!id)
return
const base = buildBase(id)
const target = number == null ? base : `${base}/${number}`
const target = number == null ? (base || '/') : `${base}/${number}`
if (route.path === target)
return
router.replace(target).catch(() => {})
Expand Down