2026-08-10 15:36:53 +08:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import { resolve } from 'node:path'
|
|
|
|
|
|
|
|
|
|
const source = readFileSync(resolve(process.cwd(), 'src/modules/loading-lists/components/LoadingListsView.vue'), 'utf8')
|
|
|
|
|
const detailSource = readFileSync(resolve(process.cwd(), 'src/modules/loading-lists/components/LoadingListDetailDrawer.vue'), 'utf8')
|
|
|
|
|
|
|
|
|
|
describe('LoadingListsView', () => {
|
|
|
|
|
it('keeps the operation column first and fixed left in both lists', () => {
|
|
|
|
|
const actionColumns = [...source.matchAll(/key: 'actions', label: '操作', fixed: 'left'/g)]
|
|
|
|
|
expect(actionColumns).toHaveLength(2)
|
|
|
|
|
expect(source.indexOf("key: 'actions'")).toBeLessThan(source.indexOf("key: 'preloadNo'"))
|
|
|
|
|
expect(source.indexOf("key: 'actions'", source.indexOf("key: 'actions'") + 1)).toBeLessThan(source.indexOf("key: 'loadingListNo'"))
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-10 18:07:33 +08:00
|
|
|
it('queries all warehouses without exposing a warehouse selector', () => {
|
|
|
|
|
expect(source).not.toContain('listAllPlatformWarehouses')
|
|
|
|
|
expect(source).not.toContain("key: 'warehouseId'")
|
|
|
|
|
expect(source).not.toContain('loadingWarehouses')
|
|
|
|
|
expect(source).not.toContain('warehouseId: warehouseId || undefined')
|
|
|
|
|
expect(source).toContain("selectedWarehouseId.value = String(row.warehouseId || '')")
|
2026-08-10 17:42:17 +08:00
|
|
|
expect(source).not.toContain("ElMessage.warning('请先选择仓库')")
|
|
|
|
|
expect(source).not.toContain("'请先选择仓库后查询'")
|
2026-08-11 11:15:44 +08:00
|
|
|
expect(source).toContain('MISSING_WAREHOUSE_CONTEXT')
|
2026-08-10 15:36:53 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('uses the shared query, table, drawer, dialog and error components', () => {
|
|
|
|
|
expect(source).toContain('QueryToolbar')
|
|
|
|
|
expect(source).toContain('DataTable')
|
|
|
|
|
expect(source).toContain('AppDialog')
|
|
|
|
|
expect(source).toContain('LoadErrorState')
|
|
|
|
|
expect(source).toContain('ApiErrorMeta')
|
|
|
|
|
expect(detailSource).toContain('AppDrawer')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('only exposes transport editing for LOADING preload details', () => {
|
|
|
|
|
expect(detailSource).toContain("mode === 'preload' && canEdit && summary.status === 'LOADING'")
|
|
|
|
|
expect(detailSource).toContain('装柜完成后清单、明细和运输信息永久只读')
|
|
|
|
|
expect(source).toContain('expectedVersion: detail.value.summary.version')
|
|
|
|
|
})
|
2026-08-11 10:35:39 +08:00
|
|
|
|
2026-08-11 11:52:30 +08:00
|
|
|
it('renders business labels instead of raw loading-plan status codes', () => {
|
|
|
|
|
expect(source).toContain("LOADING: '拣货中'")
|
|
|
|
|
expect(source).toContain("COMPLETED: '装柜完成'")
|
|
|
|
|
expect(source).toContain(':status="statusLabel(row.status)"')
|
|
|
|
|
expect(detailSource).toContain("EDITING: '预装柜中'")
|
|
|
|
|
expect(detailSource).toContain(':status="statusLabel(summary.status)"')
|
|
|
|
|
expect(detailSource).not.toContain(':status="summary.status"')
|
|
|
|
|
expect(source).not.toContain('仅装柜中允许修改')
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-11 10:35:39 +08:00
|
|
|
it('exposes a row edit action only for loading preload plans', () => {
|
|
|
|
|
expect(source).toContain("isPreload && canEdit && row.status === 'LOADING'")
|
|
|
|
|
expect(source).toContain('openEditFromRow(row)')
|
|
|
|
|
expect(source).toContain('await loadDetail()')
|
|
|
|
|
})
|
2026-08-11 11:15:44 +08:00
|
|
|
|
|
|
|
|
it('refreshes the detail version on A0409 while preserving transport input', () => {
|
|
|
|
|
expect(source).toContain("details.code === 'A0409'")
|
|
|
|
|
expect(source).toContain('await loadDetail()')
|
|
|
|
|
expect(source).toContain('当前输入已保留,请核对后重新保存')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('opens a validated plan and warehouse deep link without mixing list modes', () => {
|
|
|
|
|
expect(source).toContain('useRoute()')
|
|
|
|
|
expect(source).toContain('route.query.planId')
|
|
|
|
|
expect(source).toContain('route.query.warehouseId')
|
|
|
|
|
expect(source).toContain("const expectedStatus = isPreload.value ? 'LOADING' : 'COMPLETED'")
|
|
|
|
|
expect(source).toContain('MODE_STATUS_MISMATCH')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('passes translated status text directly to the badge', () => {
|
|
|
|
|
expect(source).toContain('<StatusBadge :status="statusLabel(row.status)" />')
|
|
|
|
|
expect(source).not.toContain('<StatusBadge :status="row.status" />')
|
|
|
|
|
expect(detailSource).toContain('<StatusBadge :status="statusLabel(summary.status)" />')
|
|
|
|
|
})
|
2026-08-10 15:36:53 +08:00
|
|
|
})
|