fix(overseas): restore first-leg before and after sailing tabs
This commit is contained in:
@@ -12,6 +12,7 @@ import { listAllPlatformWarehouses } from '@/modules/warehouses'
|
||||
import {
|
||||
changeContainerReceivingWarehouse,
|
||||
createManualInboundPlan,
|
||||
downloadLastMileOrders,
|
||||
convertLastMileContainerToInboundPlans,
|
||||
getContainerInboundPlanPreview,
|
||||
getContainerPlanProgress,
|
||||
@@ -27,6 +28,7 @@ import LastMileOrdersView from './LastMileOrdersView.vue'
|
||||
|
||||
const canAccess = vi.hoisted(() => vi.fn<(permissionCode: string) => boolean>(() => true))
|
||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: canAccess }) }))
|
||||
vi.mock('@/shared/downloadCsv', () => ({ saveCsv: vi.fn() }))
|
||||
vi.mock('vue-router', () => ({ useRouter: () => ({ push: vi.fn() }) }))
|
||||
vi.mock('@/modules/warehouses', () => ({ listAllPlatformWarehouses: vi.fn() }))
|
||||
vi.mock('../api/lastMileOrders', () => ({
|
||||
@@ -140,7 +142,7 @@ async function mountView() {
|
||||
|
||||
async function openPending() {
|
||||
const wrapper = await mountView()
|
||||
const pendingTab = wrapper.findAll('[role="tab"]').find((item) => item.text() === '待分配')
|
||||
const pendingTab = wrapper.findAll('[role="tab"]').find((item) => item.text() === '开船前')
|
||||
await pendingTab!.trigger('click')
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
@@ -148,7 +150,7 @@ async function openPending() {
|
||||
|
||||
async function openHiddenContainerWorkbench(wrapper: Awaited<ReturnType<typeof mountView>>) {
|
||||
const view = wrapper.vm as unknown as {
|
||||
statusTab: '全部' | '待分配' | '柜子'
|
||||
statusTab: '全部' | '开船前' | '开船后' | '柜子'
|
||||
changeStatusTab(): void
|
||||
}
|
||||
view.statusTab = '柜子'
|
||||
@@ -187,7 +189,7 @@ describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
it('supports keyboard status switching and keeps selection and queries in sync', async () => {
|
||||
const wrapper = await mountView()
|
||||
const tabs = wrapper.findAll('[role="tab"]')
|
||||
expect(tabs.map((tab) => tab.text())).toEqual(['全部', '待分配'])
|
||||
expect(tabs.map((tab) => tab.text())).toEqual(['全部', '开船前', '开船后'])
|
||||
expect(tabs[0]!.attributes('aria-selected')).toBe('true')
|
||||
expect(tabs[1]!.attributes('tabindex')).toBe('-1')
|
||||
await selectRows(wrapper, [selectedRow()])
|
||||
@@ -196,7 +198,7 @@ describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
expect(tabs[1]!.attributes('aria-selected')).toBe('true')
|
||||
expect(tabs[1]!.classes()).toContain('is-active')
|
||||
expect(document.activeElement).toBe(tabs[1]!.element)
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1, currentStatus: 'PENDING_ASSIGNMENT' }))
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1, orderType: 'FIRST_LEG', sailingStage: 'BEFORE_DEPARTURE', currentStatus: undefined }))
|
||||
expect((wrapper.vm as unknown as { selectedRows: unknown[] }).selectedRows).toEqual([])
|
||||
const callCount = vi.mocked(listLastMileOrders).mock.calls.length
|
||||
await tabs[1]!.trigger('click')
|
||||
@@ -205,10 +207,31 @@ describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
await tabs[1]!.trigger('keydown', { key: 'Home' })
|
||||
await flushPromises()
|
||||
expect(tabs[0]!.attributes('aria-selected')).toBe('true')
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ currentStatus: undefined }))
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ currentStatus: undefined, sailingStage: undefined, orderType: undefined }))
|
||||
await tabs[0]!.trigger('keydown', { key: 'End' })
|
||||
await flushPromises()
|
||||
expect(tabs[1]!.attributes('aria-selected')).toBe('true')
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ sailingStage: 'AFTER_DEPARTURE', orderType: 'FIRST_LEG' }))
|
||||
expect(tabs[2]!.attributes('aria-selected')).toBe('true')
|
||||
})
|
||||
|
||||
it('exports the same stage and filters as the list and restores other types in all', async () => {
|
||||
const wrapper = await mountView()
|
||||
const toolbar = wrapper.findComponent(QueryToolbar)
|
||||
toolbar.vm.$emit('update:modelValue', { ...toolbar.props('modelValue'), orderType: 'RETURN_RELABEL', detained: 'false' })
|
||||
await wrapper.vm.$nextTick()
|
||||
for (const [label, stage] of [['开船前', 'BEFORE_DEPARTURE'], ['开船后', 'AFTER_DEPARTURE']] as const) {
|
||||
await wrapper.findAll('[role="tab"]').find((tab) => tab.text() === label)!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ orderType: 'FIRST_LEG', sailingStage: stage, detained: false }))
|
||||
expect(toolbar.props('availableFields')?.some((field) => field.key === 'orderType')).toBe(false)
|
||||
await button(wrapper, '导出订单')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(downloadLastMileOrders).toHaveBeenLastCalledWith(vi.mocked(listLastMileOrders).mock.lastCall![0])
|
||||
}
|
||||
await wrapper.findAll('[role="tab"]').find((tab) => tab.text() === '全部')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ orderType: 'RETURN_RELABEL', sailingStage: undefined }))
|
||||
expect(toolbar.props('availableFields')?.some((field) => field.key === 'orderType')).toBe(true)
|
||||
})
|
||||
|
||||
it('preserves advanced conditions when collapsed and clears them on reset', async () => {
|
||||
@@ -448,7 +471,7 @@ describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
expect(wrapper.text()).not.toContain('按订单')
|
||||
expect(wrapper.text()).not.toContain('待分配整柜')
|
||||
expect(wrapper.text()).not.toContain('柜子工作台')
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1, size: 10, currentStatus: 'PENDING_ASSIGNMENT' }))
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1, size: 10, currentStatus: undefined, orderType: 'FIRST_LEG', sailingStage: 'BEFORE_DEPARTURE' }))
|
||||
expect(listContainerPlanProgress).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -481,9 +504,9 @@ describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
]))
|
||||
expect(availableFields.map((field) => field.key)).not.toEqual(expect.arrayContaining(['planNo', 'inboundOrderNo']))
|
||||
|
||||
await wrapper.findAll('[role="tab"]').find((item) => item.text() === '待分配')!.trigger('click')
|
||||
await wrapper.findAll('[role="tab"]').find((item) => item.text() === '开船前')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ currentStatus: 'PENDING_ASSIGNMENT', lxCode: 'LX-SEARCH' }))
|
||||
expect(listLastMileOrders).toHaveBeenLastCalledWith(expect.objectContaining({ currentStatus: 'DELIVERED', sailingStage: 'BEFORE_DEPARTURE', orderType: 'FIRST_LEG', lxCode: 'LX-SEARCH' }))
|
||||
|
||||
await openHiddenContainerWorkbench(wrapper)
|
||||
expect(listContainerPlanProgress).toHaveBeenLastCalledWith({
|
||||
|
||||
Reference in New Issue
Block a user