diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts index 6d1ccb05..52429092 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts @@ -11,6 +11,11 @@ import { recommendSmartLoading, } from '../api/platformContainerLoading' +const { routerPush } = vi.hoisted(() => ({ routerPush: vi.fn() })) + +vi.mock('vue-router', () => ({ + useRouter: () => ({ push: routerPush }), +})) vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: () => true }), })) @@ -82,6 +87,40 @@ describe('GlobalSmartLoadingView', () => { expect(wrapper.text()).toContain('CB-1 装柜方案') }) + it('keeps pushed containers visible and routes them to the preload list without loading an editing draft', async () => { + const pushed = { ...container, id: '9007199254740995', planId: '9007199254740996', cabinetNo: 'CB-2', planStatus: 'LOADING' as const } + vi.mocked(listContainers).mockResolvedValue({ records: [pushed], page: 1, size: 100, total: 1, pages: 1 }) + const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } }) + await flushPromises() + + expect(getSmartLoadingPlanByBooking).not.toHaveBeenCalled() + expect(listSmartLoadingCandidates).not.toHaveBeenCalled() + expect(wrapper.text()).toContain('该柜次正在预装流程中') + expect(wrapper.text()).not.toContain('智能推荐') + expect(wrapper.findAll('button').some((item) => item.text().trim() === '推送预装')).toBe(false) + + await wrapper.findAll('button').find((item) => item.text().includes('查看预装清单'))!.trigger('click') + expect(routerPush).toHaveBeenCalledWith({ + name: 'loading-plans', + query: { planId: pushed.planId, warehouseId: pushed.warehouseId }, + }) + }) + + it('routes completed containers to the read-only loading list', async () => { + const completed = { ...container, id: '9007199254740997', planId: '9007199254740998', cabinetNo: 'CB-3', planStatus: 'COMPLETED' as const } + vi.mocked(listContainers).mockResolvedValue({ records: [completed], page: 1, size: 100, total: 1, pages: 1 }) + const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } }) + await flushPromises() + + expect(getSmartLoadingPlanByBooking).not.toHaveBeenCalled() + expect(wrapper.text()).toContain('该柜次已完成装柜') + await wrapper.findAll('button').find((item) => item.text().includes('查看装柜清单'))!.trigger('click') + expect(routerPush).toHaveBeenCalledWith({ + name: 'loading-lists', + query: { planId: completed.planId, warehouseId: completed.warehouseId }, + }) + }) + it('refreshes the latest plan after A0409 without losing the selected container', async () => { const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } }) await flushPromises() diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue index def8c584..31d2ad21 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue @@ -1,5 +1,6 @@