fix(fleet): align capacity availability and dispatch review navigation

This commit is contained in:
2026-10-08 14:11:54 +08:00
parent f24b592705
commit 6551b703cb
12 changed files with 184 additions and 19 deletions
@@ -1,3 +1,4 @@
const tripQuery = vi.hoisted(() => ({ tab: '' }))
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { shallowMount, flushPromises, type VueWrapper } from '@vue/test-utils'
import { ElMessage, ElMessageBox } from 'element-plus'
@@ -9,7 +10,7 @@ import * as api from '../api/trips'
import type { FleetTrip, TripDetail, TripLoading } from '../tripTypes'
const state = vi.hoisted(() => ({ writable: true, push: vi.fn() }))
vi.mock('vue-router', () => ({ useRoute: () => ({ params: { tripNo: 'TR-TEST' } }), useRouter: () => ({ push: state.push }) }))
vi.mock('vue-router', () => ({ useRoute: () => ({ params: { tripNo: 'TR-TEST' }, query: tripQuery }), useRouter: () => ({ push: state.push }) }))
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: (code: string) => code.endsWith(':list') || state.writable }) }))
vi.mock('element-plus', () => ({ ElMessage: { success: vi.fn(), warning: vi.fn() }, ElMessageBox: { confirm: vi.fn().mockResolvedValue(undefined), prompt: vi.fn().mockResolvedValue({ value: '请核对预约时间' }) } }))
vi.mock('../api/drivers', () => ({ listDriverWarehouses: vi.fn().mockResolvedValue([{ id: '92', name: '海外仓', code: 'WH-US' }]) }))
@@ -39,7 +40,7 @@ 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
vi.clearAllMocks(); state.writable = true; tripQuery.tab = ''
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 })
@@ -166,3 +167,12 @@ it('refreshes trip members and loading review after external dispatch binding wi
expect(api.getTrip).toHaveBeenCalledTimes(2)
expect(wrapper.findComponent({ name: 'ElTabs' }).props('modelValue')).toBe('bookings')
})
it('opens the loading review section from the dispatch list deep link', async () => {
tripQuery.tab = 'loading'
const wrapper = mount(TripDetailView)
await flushPromises()
expect(wrapper.findComponent({ name: 'ElTabs' }).props('modelValue')).toBe('loading')
expect(wrapper.findComponent({ name: 'TripLoadingPanel' }).exists()).toBe(true)
expect(wrapper.text()).toContain('理货审核')
})