WP-12: contract and failing tests for the Kubernetes overview
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
45
frontend/src/components/WorkloadTable.test.ts
Normal file
45
frontend/src/components/WorkloadTable.test.ts
Normal 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' })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user