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') describe('CustomsCasesView', () => { 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") }) it('uses shared list and dialog components', () => { expect(source).toContain('QueryToolbar'); expect(source).toContain('DataTable'); expect(source).toContain('AppDialog'); expect(source).toContain("fixed: 'left'") }) it('supports detail, history and agent submission', () => { expect(source).toContain('getCustomsCase'); expect(source).toContain('submitCustomsCase'); expect(source).toContain('detail.history') }) 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 || '服务端未返回名称快照'") }) 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']") }) 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'") }) 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: '入库单标识'") }) it('keeps the detail dialog responsive with internal scrolling', () => { 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(') }) 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") expect(source).toContain(':total="total" stripe row-key="id"') }) 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'") expect(source).toContain("label: customer.tenantName") expect(source).toContain("customerId: String(filters.value.customerId || '') || undefined") expect(source).not.toContain('customer.tenantCode') }) })