feat(appointment): integrate work calendar and original business actions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const tripQuery = vi.hoisted(() => ({ tab: '' }))
|
||||
const tripQuery = vi.hoisted(() => ({ tab: '', appointmentReturn: '' }))
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { shallowMount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
@@ -40,12 +40,19 @@ function mount(component: object, props: Record<string, unknown> = {}): VueWrapp
|
||||
}
|
||||
function button(wrapper: VueWrapper, text: string) { return wrapper.findAll('button').find(node => node.text() === text)! }
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks(); state.writable = true; tripQuery.tab = ''
|
||||
vi.clearAllMocks(); state.writable = true; tripQuery.tab = ''; tripQuery.appointmentReturn = ''
|
||||
vi.mocked(api.listTrips).mockResolvedValue({ records: [structuredClone(trip)], page: 1, size: 20, total: 1, pages: 1 })
|
||||
vi.mocked(api.getTrip).mockResolvedValue(structuredClone(detail))
|
||||
vi.mocked(api.listTripHistory).mockResolvedValue({ records: [], page: 1, size: 20, total: 0, pages: 0 })
|
||||
})
|
||||
afterEach(() => wrappers.splice(0).forEach(wrapper => wrapper.unmount()))
|
||||
it('returns from a trip to the exact appointment work context and preserves it while choosing a trip', async () => {
|
||||
tripQuery.appointmentReturn = '/appointment-calendar?workItem=work-1&workPage=3'
|
||||
const list = mount(TripsView); await flushPromises(); await button(list, '详情').trigger('click')
|
||||
expect(state.push).toHaveBeenCalledWith({ name: 'overseas-master-data-trip-detail', params: { tripNo: 'TR-TEST' }, query: { appointmentReturn: tripQuery.appointmentReturn } })
|
||||
const page = mount(TripDetailView); await flushPromises(); await button(page, '返回预约工作').trigger('click')
|
||||
expect(state.push).toHaveBeenLastCalledWith(tripQuery.appointmentReturn)
|
||||
})
|
||||
|
||||
it('shows mixed signature and return quantities from one lazy completion read', async () => {
|
||||
vi.mocked(api.getTrip).mockResolvedValue({ ...structuredClone(detail), trip: { ...trip, status: 'IN_TRANSIT' } })
|
||||
@@ -79,7 +86,7 @@ it('loads one trip page and opens a real detail route without fetching each row'
|
||||
const wrapper = mount(TripsView); await flushPromises()
|
||||
expect(api.listTrips).toHaveBeenCalledTimes(1); expect(api.getTrip).not.toHaveBeenCalled()
|
||||
await button(wrapper, '详情').trigger('click')
|
||||
expect(state.push).toHaveBeenCalledWith({ name: 'overseas-master-data-trip-detail', params: { tripNo: 'TR-TEST' } })
|
||||
expect(state.push).toHaveBeenCalledWith({ name: 'overseas-master-data-trip-detail', params: { tripNo: 'TR-TEST' }, query: {} })
|
||||
wrapper.findComponent({ name: 'DataTable' }).vm.$emit('update:page', 2); await flushPromises()
|
||||
expect(api.listTrips).toHaveBeenLastCalledWith(expect.objectContaining({ page: 2 }))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user