import test from 'node:test' import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' test('web contract detail embeds customer cert panel and renamed tab', () => { const source = readFileSync( new URL('../src/views/crm/contract/components/ContractDetailDialog.vue', import.meta.url), 'utf8' ) assert.match(source, /label="客户证件与额度"/) assert.match(source, /CustomerCertQuotaPanel/) assert.doesNotMatch(source, /ContractQuotaPanel/) assert.match(source, /:customer-id="detailContract\.customerId"/) }) test('h5 contract detail includes customer cert tab', () => { const source = readFileSync( new URL('../src/views/m/crm/contract/detail.vue', import.meta.url), 'utf8' ) assert.match(source, /CustomerCertQuotaTab/) assert.match(source, /客户证件与额度/) assert.match(source, /canViewQuotaCert/) assert.match(source, /:customer-id="contract\.customerId"/) }) test('customer cert panel lists by customerId without contract bindings', () => { const source = readFileSync( new URL('../src/views/pl/contract-quota/CustomerCertQuotaPanel.vue', import.meta.url), 'utf8' ) assert.match(source, /quotaCertApi\.list\('purchase', \{ customerId \}\)/) assert.match(source, /quotaCertApi\.list\('transport', \{ customerId \}\)/) assert.match(source, /有效次数/) assert.match(source, /singleUseConsumed/) assert.doesNotMatch(source, /saveBindings|openCreate|bindings\(/) }) test('standalone contract-quota page is customer quota list', () => { const panel = readFileSync( new URL('../src/views/pl/contract-quota/CustomerQuotaPanel.vue', import.meta.url), 'utf8' ) const wrapper = readFileSync( new URL('../src/views/pl/contract-quota/ContractQuotaPanel.vue', import.meta.url), 'utf8' ) const router = readFileSync(new URL('../src/router/modules/pl.ts', import.meta.url), 'utf8') assert.match(panel, /客户用证/) assert.match(panel, /quotaStatisticsApi\.customers/) assert.match(wrapper, /CustomerQuotaPanel/) assert.match(router, /title: '客户用证'/) }) test('web customer quota panel uses toQueryParams from useServerColumnFilters', () => { const panel = readFileSync( new URL('../src/views/pl/contract-quota/CustomerQuotaPanel.vue', import.meta.url), 'utf8' ) assert.match(panel, /toQueryParams/) assert.match(panel, /\.\.\.toQueryParams\(\)/) assert.doesNotMatch(panel, /\bbuildQuery\b/) assert.doesNotMatch(panel, /\bresetFilters\b/) assert.match(panel, /clearAllFilters/) assert.match(panel, /watchVisibleColumns/) }) test('h5 customer quota tab does not call buildQuery', () => { const tab = readFileSync( new URL('../src/views/m/pl/plan-cert/CustomerTab.vue', import.meta.url), 'utf8' ) assert.doesNotMatch(tab, /\bbuildQuery\b/) assert.match(tab, /quotaStatisticsApi\.customers/) })