Skip to content
Merged
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
14 changes: 9 additions & 5 deletions app/components/Package/Versions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,16 @@ const visibleTagRows = computed(() => {
)
: rowsMaybeFilteredForDeprecation
const first = rows.slice(0, MAX_VISIBLE_TAGS)
const latestTagRow = rows.find(row => row.tag === 'latest')
// Ensure 'latest' tag is always included (at the end) if not already present
if (latestTagRow && !first.includes(latestTagRow)) {
first.pop()
first.push(latestTagRow)

// When no filter is active, ensure 'latest' is always shown (even if not fully loaded)
if (!isFilterActive.value) {
const latestTagRow = rows.find(row => row.tag === 'latest')
if (latestTagRow && !first.includes(latestTagRow)) {
first.pop()
first.push(latestTagRow)
}
}

return first
})

Expand Down
15 changes: 15 additions & 0 deletions test/nuxt/components/Package/Versions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,21 @@ describe('PackageVersions', () => {
expect(text).not.toContain('0.5.0')
})
})

it('does not show latest tag when it does not match the filter', async () => {
const component = await mountSuspended(PackageVersions, { props: multiVersionProps })

const input = component.find('input[type="text"]')
await input.setValue('^1.0.0 <2.0.0')

const versionLinks = component.findAll('a').filter(isVersionLink)
const versions = versionLinks.map(l => l.text())

// 3.0.0 is latest but does NOT match the filter
expect(versions).not.toContain('3.0.0')
// 1.0.0 does match
expect(versions).toContain('1.0.0')
})
})

describe('error handling', () => {
Expand Down
Loading