feat(admin): streamline appointments and fleet intake

This commit is contained in:
2026-10-09 22:05:51 +08:00
parent 88dc4852c6
commit e1457a8e57
39 changed files with 1215 additions and 165 deletions
@@ -0,0 +1,41 @@
import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import AppointmentInboundCodes from './AppointmentInboundCodes.vue'
describe('appointment inbound code list', () => {
const codes = Array.from({ length: 20 }, (_, index) => `WT-LONG-INBOUND-CODE-${index + 1}`)
it('previews three codes, exposes the total and expands without losing full codes', async () => {
const wrapper = mount(AppointmentInboundCodes, { props: { codes } })
expect(wrapper.findAll('li')).toHaveLength(3)
expect(wrapper.text()).toContain('20 个')
expect(wrapper.get('button').text()).toContain('还有 17 个')
expect(wrapper.get('li').attributes('title')).toBe(codes[0])
expect(wrapper.get('button').attributes('aria-expanded')).toBe('false')
await wrapper.get('button').trigger('click')
expect(wrapper.findAll('li').map(row => row.text())).toEqual(codes)
expect(wrapper.get('ul').classes()).toContain('expanded')
expect(wrapper.get('ul').attributes('tabindex')).toBe('0')
expect(wrapper.get('button').attributes('aria-controls')).toBe(wrapper.get('ul').attributes('id'))
await wrapper.get('button').trigger('click')
expect(wrapper.findAll('li')).toHaveLength(3)
})
it('does not count missing or duplicate codes and shows no redundant toggle', () => {
const wrapper = mount(AppointmentInboundCodes, { props: { codes: [' A ', 'A', '', null, undefined, 'B'] } })
expect(wrapper.findAll('li').map(row => row.text())).toEqual(['A', 'B'])
expect(wrapper.text()).toContain('2 个')
expect(wrapper.find('button').exists()).toBe(false)
expect(mount(AppointmentInboundCodes, { props: { codes: [] } }).text()).toContain('—')
})
it('preserves expansion on equivalent data but resets when the appointment codes change', async () => {
const wrapper = mount(AppointmentInboundCodes, { props: { codes } })
await wrapper.get('button').trigger('click')
await wrapper.setProps({ codes: [...codes] })
expect(wrapper.findAll('li')).toHaveLength(20)
await wrapper.setProps({ codes: codes.map(code => `${code}-NEW`) })
expect(wrapper.findAll('li')).toHaveLength(3)
expect(wrapper.get('button').attributes('aria-expanded')).toBe('false')
})
})