feat(dashboard): verbatim modal + defect feed on /defects (T8)

This commit is contained in:
Julien Calixte
2026-05-28 00:54:51 +02:00
parent 406a4d5ec5
commit 73e4c56a9e
9 changed files with 316 additions and 4 deletions

View File

@@ -0,0 +1,51 @@
// @vitest-environment nuxt
import { describe, it, expect } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import DefectFeed from '../app/components/DefectFeed.vue'
const defect = (over: Partial<Record<string, unknown>> = {}) => ({
id: 'd1',
sectionId: 'macroplan',
projectName: 'Acme',
reporterEmail: 'dev@theodo.com',
verbatim: 'builds are flaky',
createdAt: '2026-05-28T10:00:00Z',
...over,
})
describe('DefectFeed', () => {
it('renders each defect with its date, project, reporter and verbatim', async () => {
const wrapper = await mountSuspended(DefectFeed, {
props: { defects: [defect()] },
})
const items = wrapper.findAll('[data-test="feed-item"]')
expect(items).toHaveLength(1)
const text = items[0]!.text()
expect(text).toContain('28/05')
expect(text).toContain('Acme')
expect(text).toContain('dev@theodo.com')
expect(text).toContain('builds are flaky')
})
it('preserves the feed order it is given (newest-first from the API)', async () => {
const wrapper = await mountSuspended(DefectFeed, {
props: {
defects: [
defect({ id: 'newer', verbatim: 'newer one' }),
defect({ id: 'older', verbatim: 'older one' }),
],
},
})
const items = wrapper.findAll('[data-test="feed-item"]')
expect(items[0]!.text()).toContain('newer one')
expect(items[1]!.text()).toContain('older one')
})
it('shows an empty state when there are no defects', async () => {
const wrapper = await mountSuspended(DefectFeed, { props: { defects: [] } })
expect(wrapper.findAll('[data-test="feed-item"]')).toHaveLength(0)
expect(wrapper.find('[data-test="feed-empty"]').exists()).toBe(true)
})
})