This commit is contained in:
2026-09-03 10:41:09 +08:00
parent bbe8b73cd4
commit 9b3664c532
2 changed files with 25 additions and 1 deletions
@@ -245,6 +245,31 @@ describe('GlobalSmartLoadingView', () => {
expect(listSmartLoadingCandidates).toHaveBeenLastCalledWith(dongguanContainer.id, dongguanContainer.warehouseId) expect(listSmartLoadingCandidates).toHaveBeenLastCalledWith(dongguanContainer.id, dongguanContainer.warehouseId)
}) })
it('keeps the selected channel when the warehouse changes even if that warehouse has no matching container', async () => {
const dongguanOvertimeContainer = {
...container,
id: '9007199254740998',
planId: '9007199254740999',
cabinetNo: 'CB-DG-MAX',
containerNo: 'MSCU-DG-MAX',
warehouseId: '18',
warehouseName: '东莞仓',
channelCode: 'MATSON_MAX_TRUCK',
channelName: '美森加班海卡',
}
vi.mocked(listContainers).mockResolvedValue({ records: [container, dongguanOvertimeContainer], page: 1, size: 100, total: 2, pages: 1 })
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
await flushPromises()
await (wrapper.vm as unknown as { selectWarehouse: (code: string) => Promise<void> }).selectWarehouse('DONGGUAN')
await flushPromises()
expect(wrapper.get('.channel-tabs [role="tab"][aria-selected="true"]').text()).toBe('美森正班')
expect(wrapper.findAll('.container-option')).toHaveLength(0)
expect(wrapper.text()).not.toContain('MSCU-DG-MAX')
expect(listSmartLoadingCandidates).toHaveBeenCalledTimes(1)
})
it('filters candidates by an active name-only customer selector and accountId', () => { it('filters candidates by an active name-only customer selector and accountId', () => {
const source = readFileSync(resolve(process.cwd(), 'src/modules/container-loading/pages/GlobalSmartLoadingView.vue'), 'utf8') const source = readFileSync(resolve(process.cwd(), 'src/modules/container-loading/pages/GlobalSmartLoadingView.vue'), 'utf8')
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })") expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
@@ -399,7 +399,6 @@ async function selectContainer(containerId: string) {
async function selectWarehouse(warehouseCode: string) { async function selectWarehouse(warehouseCode: string) {
if (activeWarehouseCode.value === warehouseCode) return if (activeWarehouseCode.value === warehouseCode) return
activeWarehouseCode.value = warehouseCode activeWarehouseCode.value = warehouseCode
activeChannelCode.value = preferredChannelCode(warehouseCode)
selectedContainerId.value = preferredContainerId() selectedContainerId.value = preferredContainerId()
await loadSelectedData() await loadSelectedData()
} }