Skip to content

Commit 9b49e3c

Browse files
committed
fix: fix regression with no-dependency column
1 parent ce0b30d commit 9b49e3c

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

app/components/Compare/PackageSelector.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,16 @@ function addPackage(name: string) {
5757
if (packages.value.length >= maxPackages.value) return
5858
if (packages.value.includes(name)) return
5959
60-
packages.value = [...packages.value, name]
60+
// Keep NO_DEPENDENCY_ID always last
61+
if (name === NO_DEPENDENCY_ID) {
62+
packages.value = [...packages.value, name]
63+
} else if (packages.value.includes(NO_DEPENDENCY_ID)) {
64+
// Insert before the no-dep entry
65+
const withoutNoDep = packages.value.filter(p => p !== NO_DEPENDENCY_ID)
66+
packages.value = [...withoutNoDep, name, NO_DEPENDENCY_ID]
67+
} else {
68+
packages.value = [...packages.value, name]
69+
}
6170
inputValue.value = ''
6271
}
6372

app/pages/compare.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ const showNoDependency = computed(() => packages.value.includes(NO_DEPENDENCY_ID
4343
// Build column definitions for real packages only (no-dep is handled separately by the grid)
4444
const gridColumns = computed(() =>
4545
packages.value
46-
.filter(pkg => pkg !== NO_DEPENDENCY_ID)
47-
.map((pkg, i) => {
48-
const data = packagesData.value?.[i]
46+
.map((pkg, i) => ({ pkg, originalIndex: i }))
47+
.filter(({ pkg }) => pkg !== NO_DEPENDENCY_ID)
48+
.map(({ pkg, originalIndex }) => {
49+
const data = packagesData.value?.[originalIndex]
4950
const header = data
5051
? data.package.version
5152
? `${data.package.name}@${data.package.version}`

test/e2e/interactions.spec.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,54 @@
11
import { expect, test } from './test-utils'
22

3+
test.describe('Compare Page', () => {
4+
test('no-dep column renders separately from package columns', async ({ page, goto }) => {
5+
await goto('/compare?packages=vue,__no_dependency__', { waitUntil: 'hydration' })
6+
7+
const grid = page.locator('.comparison-grid')
8+
await expect(grid).toBeVisible({ timeout: 15000 })
9+
10+
// Should have the no-dep column with special styling
11+
const noDepColumn = grid.locator('.comparison-cell-nodep')
12+
await expect(noDepColumn).toBeVisible()
13+
14+
// The no-dep column should not contain a link
15+
await expect(noDepColumn.locator('a')).toHaveCount(0)
16+
})
17+
18+
test('no-dep column is always last even when packages are added after', async ({
19+
page,
20+
goto,
21+
}) => {
22+
// Start with vue and no-dep
23+
await goto('/compare?packages=vue,__no_dependency__', { waitUntil: 'hydration' })
24+
25+
const grid = page.locator('.comparison-grid')
26+
await expect(grid).toBeVisible({ timeout: 15000 })
27+
28+
// Add another package via the input
29+
const input = page.locator('#package-search')
30+
await input.fill('nuxt')
31+
32+
// Wait for search results and click on nuxt
33+
const nuxtOption = page.locator('button:has-text("nuxt")').first()
34+
await expect(nuxtOption).toBeVisible({ timeout: 10000 })
35+
await nuxtOption.click()
36+
37+
// URL should have no-dep at the end, not in the middle
38+
await expect(page).toHaveURL(/packages=vue,nuxt,__no_dependency__/)
39+
40+
// Verify column order in the grid: vue, nuxt, then no-dep
41+
const headerLinks = grid.locator('.comparison-cell-header a.truncate')
42+
await expect(headerLinks).toHaveCount(2)
43+
await expect(headerLinks.nth(0)).toContainText('vue')
44+
await expect(headerLinks.nth(1)).toContainText('nuxt')
45+
46+
// No-dep should still be visible as the last column
47+
const noDepColumn = grid.locator('.comparison-cell-nodep')
48+
await expect(noDepColumn).toBeVisible()
49+
})
50+
})
51+
352
test.describe('Search Pages', () => {
453
test('/search?q=vue → keyboard navigation (arrow keys + enter)', async ({ page, goto }) => {
554
await goto('/search?q=vue', { waitUntil: 'hydration' })

0 commit comments

Comments
 (0)