fix(appointment): restore overlay panel and compact calendar controls

This commit is contained in:
2026-10-15 19:23:16 +08:00
parent 8dc0d2d3b8
commit 9f51392754
6 changed files with 248 additions and 58 deletions
@@ -1,9 +1,49 @@
import { mount } from '@vue/test-utils'
import { expect, it } from 'vitest'
import { afterEach, expect, it, vi } from 'vitest'
import WorkCalendarPanel from './WorkCalendarPanel.vue'
import { workCalendar } from './work.test-support'
import { workTypes } from './workApi'
function render() { return mount(WorkCalendarPanel, { props: { anchor: '2026-10-15', mode: 'month', flow: '', types: [...workTypes], calendar: workCalendar, loading: false, failed: false, reference: false, arrivals: [], referenceReady: false } }) }
afterEach(() => vi.useRealTimers())
it('offers all four flows directly and emits the original filter values with an exclusive selection', async () => {
const wrapper = render()
const buttons = wrapper.findAll('.flow-controls button')
expect(buttons.map(button => button.text())).toEqual(['全部流程', '海外仓中转', '整柜直送', '路线待确认'])
expect(wrapper.find('select').exists()).toBe(false)
for (const [index, flow] of (['', 'TRANSFER', 'DIRECT', 'UNKNOWN'] as const).entries()) {
await buttons[index]!.trigger('click')
expect(wrapper.emitted('flow')?.at(-1)).toEqual([flow])
await wrapper.setProps({ flow })
expect(wrapper.findAll('.flow-controls button[aria-pressed=true]')).toHaveLength(1)
expect(buttons[index]!.attributes('aria-pressed')).toBe('true')
}
wrapper.unmount()
})
it('distinguishes today from the selected day and type without changing the selected scope', async () => {
vi.useFakeTimers(); vi.setSystemTime(new Date('2026-10-15T12:00:00'))
const wrapper = render()
await wrapper.setProps({ selectedDate: '2026-10-16' })
expect(wrapper.get('[data-date="2026-10-15"] .day-heading').attributes('aria-current')).toBe('date')
expect(wrapper.get('[data-date="2026-10-15"] .day-heading').attributes('aria-pressed')).toBe('false')
expect(wrapper.get('[data-date="2026-10-16"]').classes()).toContain('is-selected')
await wrapper.setProps({ selectedDate: '2026-10-15', selectedType: 'DELIVERY' })
expect(wrapper.get('[data-date="2026-10-15"] [data-type="DELIVERY"]').attributes('aria-pressed')).toBe('true')
expect(wrapper.get('[data-date="2026-10-15"] [data-type="PICKUP"]').attributes('aria-pressed')).toBe('false')
wrapper.unmount()
})
it('shows the actual cross-month interval and hides empty-day zeros while keeping dates clickable', async () => {
const wrapper = render()
expect(wrapper.get('.calendar-counts').text()).toContain('2026-09-28 ~ 2026-11-08')
const empty = wrapper.get('[data-date="2026-10-01"] .day-heading')
expect(empty.text()).toBe('1')
expect(empty.attributes('disabled')).toBeUndefined()
await empty.trigger('click'); expect(wrapper.emitted('day')).toEqual([['2026-10-01']])
expect(wrapper.get('footer').text()).toContain('未定日期请从上方待办查看')
await wrapper.setProps({ mode: 'week' })
expect(wrapper.findAll('.work-day')).toHaveLength(7)
expect(wrapper.get('.view-switch button:last-child').attributes('aria-pressed')).toBe('true')
wrapper.unmount()
})
it('renders server type counts instead of individual event cards and opens exact date/type details', async () => {
const wrapper = render()
expect(wrapper.findAll('.work-day')).toHaveLength(42)