WP-10: contract and failing tests for OS and package inventory
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
37
frontend/src/components/PackageTable.test.ts
Normal file
37
frontend/src/components/PackageTable.test.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import PackageTable from './PackageTable.vue'
|
||||
import type { Package } from '../api/types'
|
||||
|
||||
const pkgs: Package[] = [
|
||||
{ name: 'bash', source: 'apt', installed: '5.2', candidate: null, is_security: false },
|
||||
{ name: 'openssl', source: 'apt', installed: '3.0.1', candidate: '3.0.2', is_security: true },
|
||||
{ name: 'curl', source: 'apt', installed: '7.88', candidate: '7.89', is_security: false },
|
||||
{ name: 'microk8s', source: 'snap', installed: 'v1.32', candidate: null, is_security: false },
|
||||
]
|
||||
|
||||
const rows = (w: ReturnType<typeof mount>) => w.findAll('tbody tr').map((r) => r.text())
|
||||
|
||||
describe('PackageTable', () => {
|
||||
it('lists all packages and marks upgradable ones', () => {
|
||||
const w = mount(PackageTable, { props: { packages: pkgs } })
|
||||
expect(rows(w)).toHaveLength(4)
|
||||
expect(rows(w)[1]).toContain('3.0.2')
|
||||
expect(rows(w)[1]).toContain('security')
|
||||
})
|
||||
|
||||
it('filters by search text and upgradable flag', async () => {
|
||||
const w = mount(PackageTable, { props: { packages: pkgs } })
|
||||
await w.find('input[name=search]').setValue('ssl')
|
||||
expect(rows(w)).toHaveLength(1)
|
||||
await w.find('input[name=search]').setValue('')
|
||||
await w.find('input[name=upgradable]').setValue(true)
|
||||
expect(rows(w).map((r) => r.split(' ')[0])).toEqual(['openssl', 'curl'])
|
||||
})
|
||||
|
||||
it('filters by source', async () => {
|
||||
const w = mount(PackageTable, { props: { packages: pkgs } })
|
||||
await w.find('select[name=source]').setValue('snap')
|
||||
expect(rows(w)).toHaveLength(1)
|
||||
expect(rows(w)[0]).toContain('microk8s')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user