WP-12: contract and failing tests for the Kubernetes overview
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / ui (push) Has been cancelled

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Dennis Nemec
2026-09-02 22:29:36 +02:00
parent 684695e71a
commit 51ec216910
14 changed files with 922 additions and 0 deletions

View File

@ -91,3 +91,40 @@ export interface InventoryResponse {
packages: Package[]
summary: { total: number; upgradable: number; security: number }
}
export type WorkloadKind = 'deployment' | 'statefulset' | 'daemonset'
export interface Workload {
namespace: string
kind: WorkloadKind
name: string
ready: number
desired: number
containers: { name: string; image: string }[]
}
export interface NodeInfo {
name: string
version: string
ready: boolean
os_image: string
kernel: string
container_runtime: string
}
export interface VolumeClaim {
namespace: string
name: string
capacity: string
storage_class: string
status: string
}
export interface ClusterOverview {
nodes: NodeInfo[]
namespaces: string[]
workloads: Workload[]
volume_claims: VolumeClaim[]
images: string[]
fetched_at: string
}

View File

@ -0,0 +1,45 @@
import { mount } from '@vue/test-utils'
import WorkloadTable from './WorkloadTable.vue'
import type { Workload } from '../api/types'
const workloads: Workload[] = [
{
namespace: 'gitea',
kind: 'deployment',
name: 'gitea',
ready: 1,
desired: 1,
containers: [{ name: 'gitea', image: 'gitea/gitea:1.22.3' }],
},
{
namespace: 'gitea',
kind: 'statefulset',
name: 'gitea-postgresql',
ready: 0,
desired: 1,
containers: [{ name: 'postgresql', image: 'bitnami/postgresql:16.4.0' }],
},
]
describe('WorkloadTable', () => {
it('renders workloads with readiness and images', () => {
const w = mount(WorkloadTable, { props: { workloads, canAct: false } })
const rows = w.findAll('tbody tr')
expect(rows).toHaveLength(2)
expect(rows[0].text()).toContain('gitea/gitea:1.22.3')
expect(rows[0].text()).toContain('1/1')
expect(rows[1].text()).toContain('0/1')
expect(rows[1].classes().join(' ')).toContain('red')
expect(w.findAll('button[name=restart]')).toHaveLength(0)
})
it('emits actions for admins', async () => {
const w = mount(WorkloadTable, { props: { workloads, canAct: true } })
await w.findAll('button[name=restart]')[0].trigger('click')
expect(w.emitted('restart')![0][0]).toMatchObject({ name: 'gitea', kind: 'deployment' })
await w.findAll('button[name=scale]')[1].trigger('click')
expect(w.emitted('scale')![0][0]).toMatchObject({ name: 'gitea-postgresql' })
await w.findAll('button[name=image]')[0].trigger('click')
expect(w.emitted('image')![0][0]).toMatchObject({ name: 'gitea' })
})
})