Files
admin-web/src/modules/customs/pages/CustomsCasesView.test.ts
T

62 lines
4.0 KiB
TypeScript
Raw Normal View History

import { describe, expect, it } from 'vitest'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
const source = readFileSync(resolve(process.cwd(), 'src/modules/customs/pages/CustomsCasesView.vue'), 'utf8')
2026-08-11 18:06:35 +08:00
describe('CustomsCasesView', () => {
2026-09-01 14:27:22 +08:00
it('uses a wide customer filter and compact status filter', () => {
expect(source).toContain("key: 'customerId', type: 'select', label: '客户', placeholder: '全部客户', width: 220")
expect(source).toContain("key: 'status', type: 'select', label: '状态', width: 160")
})
2026-08-11 18:06:35 +08:00
it('uses shared list and dialog components', () => { expect(source).toContain('QueryToolbar'); expect(source).toContain('DataTable'); expect(source).toContain('AppDialog'); expect(source).toContain("fixed: 'left'") })
2026-08-11 19:59:15 +08:00
it('supports detail, history and agent submission', () => { expect(source).toContain('getCustomsCase'); expect(source).toContain('submitCustomsCase'); expect(source).toContain('detail.history') })
2026-08-15 11:12:22 +08:00
it('selects an active customs supplier and submits its stable identity and name snapshot', () => {
expect(source).toContain("listSuppliers({ page: 1, size: 200, category: 'CUSTOMS', status: 'ACTIVE' })")
expect(source).toContain("supplier.category === 'CUSTOMS' && supplier.status === 'ACTIVE'")
expect(source).toContain(':model-value="submitForm.customsAgentId" filterable clearable')
expect(source).toContain("submitForm.customsAgentId = supplier?.id || ''")
expect(source).toContain("submitForm.customsAgentName = supplier?.name || ''")
expect(source).not.toContain('v-model="submitForm.customsAgentName"')
expect(source).toContain("batch.customsAgentName || '服务端未返回名称快照'")
})
2026-08-11 18:43:56 +08:00
it('localizes backend statuses and timeline actions throughout the page', () => {
expect(source).toContain('customsCaseStatusOptions')
expect(source).toContain(':status="customsStatusLabel(row.status)"')
expect(source).toContain(':status="customsStatusLabel(detail.customsCase.status)"')
expect(source).toContain('customsHistoryActionLabel(entry.action)')
expect(source).toContain('customsStatusLabel(entry.fromStatus)')
expect(source).toContain("detail.value?.customsCase.status === 'READY_TO_SUBMIT'")
expect(source).not.toContain("['DRAFT', 'COLLECTING', 'READY', 'SUBMITTED', 'RELEASED', 'REJECTED']")
})
2026-08-11 19:59:15 +08:00
it('does not expose internal id inputs while resource query APIs are unavailable', () => {
expect(source).not.toContain('createCustomsCase')
expect(source).not.toContain('新增报关')
expect(source).not.toContain('资料清单版本 ID')
expect(source).not.toContain("key: 'orderId', type: 'input'")
expect(source).not.toContain("key: 'inboundId', type: 'input'")
2026-08-11 18:06:35 +08:00
})
2026-08-12 10:59:49 +08:00
it('does not render technical order or inbound ids in the list', () => {
expect(source).toContain("label: '订单关联'")
expect(source).toContain("label: '入库单关联'")
expect(source).toContain("return value ? '已关联' : '未关联'")
expect(source).not.toContain("label: '订单标识'")
expect(source).not.toContain("label: '入库单标识'")
})
2026-08-12 17:34:06 +08:00
it('keeps the detail dialog responsive with internal scrolling', () => {
2026-10-20 23:34:11 +08:00
expect(source).toContain('width="min(900px, calc(100vw - 28px))"')
expect(source).toContain('admin-density-dialog admin-workbench is-dialog')
expect(source).not.toContain(':global(.el-dialog:has(')
2026-08-12 17:34:06 +08:00
})
2026-08-12 17:45:49 +08:00
it('uses a bordered view action instead of a text link', () => {
expect(source).toContain('size="small" type="primary" plain')
expect(source).not.toContain("customs:view')\" link")
2026-08-12 18:16:44 +08:00
expect(source).toContain(':total="total" stripe row-key="id"')
2026-08-12 17:45:49 +08:00
})
2026-08-14 12:50:50 +08:00
it('uses an active name-only customer selector backed by customerId', () => {
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
expect(source).toContain("customer.status === 'ACTIVE'")
2026-08-14 14:27:03 +08:00
expect(source).toContain("label: customer.tenantName")
2026-08-14 12:50:50 +08:00
expect(source).toContain("customerId: String(filters.value.customerId || '') || undefined")
expect(source).not.toContain('customer.tenantCode')
})
2026-08-11 18:06:35 +08:00
})