import { mount } from '@vue/test-utils' import { describe, expect, it } from 'vitest' import AuditTrail from '../../components/AuditTrail.vue' import BaseSelect from '../../components/BaseSelect.vue' import type { AuditEntry } from '../../types' const entries: AuditEntry[] = [ { id: '1', type: 'update', action: 'updated S-0012', detail: 'Conc 12.5 µM → 25 µM', user: 'Lin Zhang', timestamp: '2026-09-24T14:32:00Z' }, { id: '2', type: 'create', action: 'created S-0012', user: 'Kai Wang', timestamp: '2026-09-24T09:05:00Z' }, ] describe('AuditTrail', () => { it('should put who and what in one sentence when the entry has a user', () => { const wrapper = mount(AuditTrail, { props: { entries } }) expect(wrapper.find('.mint-audit-trail__sentence').text()).toBe('Lin Zhang updated S-0012') }) it('should render the detail text unchanged', () => { const wrapper = mount(AuditTrail, { props: { entries } }) expect(wrapper.find('.mint-audit-trail__detail').text()).toBe('Conc 12.5 µM → 25 µM') }) it('should filter with small BaseSelects when filters are shown', () => { const wrapper = mount(AuditTrail, { props: { entries, showFilters: true } }) expect(wrapper.findAllComponents(BaseSelect).map(select => select.props('size'))).toEqual(['sm', 'sm']) }) it('should narrow the list when a type filter is chosen', async () => { const wrapper = mount(AuditTrail, { props: { entries, showFilters: true } }) await wrapper.findAllComponents(BaseSelect)[0].vm.$emit('update:modelValue', 'create') expect(wrapper.findAll('.mint-audit-trail__entry')).toHaveLength(1) }) })