This commit is contained in:
2026-08-14 14:27:03 +08:00
parent 724848feb6
commit a81af4a664
64 changed files with 961 additions and 176 deletions
@@ -1,6 +1,19 @@
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
import type { PlatformTenantResource } from '@/modules/iam'
import { loadAllActiveCustomers } from '../task-list'
function activeCustomer(id: string, tenantName: string, legalName: string | null, tenantCode: string): PlatformTenantResource {
return {
id, tenantName, legalName, tenantCode, status: 'ACTIVE', legalRepresentative: null,
unifiedSocialCreditCode: null, contactName: null, contactPhone: null, contactEmail: null,
servicePackage: null, contactWechat: null, salesOwnerName: null, paymentTermDays: null,
enterpriseType: null, establishedDate: null, registeredCapital: null,
registeredCapitalCurrency: null, registeredAddress: null, internalRemark: null,
createdAt: null, approvedAt: null,
}
}
describe('InboundTaskList measurement scope', () => {
it('uses the inbound tenant isolation key for measurement and review requests', () => {
@@ -10,6 +23,42 @@ describe('InboundTaskList measurement scope', () => {
expect(source).not.toContain('selectedInbound.customerId || selectedInbound.tenantId')
})
it('loads only active customers and exposes a searchable name-only select', () => {
const source = readFileSync(resolve('src/modules/inbounds/components/InboundTaskList.vue'), 'utf8')
const queryFieldsSource = source.slice(source.indexOf('const queryFields'), source.indexOf('const columns'))
expect(source).toContain('loadAllActiveCustomers')
expect(queryFieldsSource).toContain("type: 'select'")
expect(queryFieldsSource).toContain('filterable: true')
expect(queryFieldsSource).toContain('label: customer.legalName?.trim() || customer.tenantName')
expect(queryFieldsSource).not.toContain('tenantCode')
expect(queryFieldsSource).not.toContain('客户编码')
})
it('requests every active-customer page and merges name-only options', async () => {
const calls: Array<{ page: number; size: number; status: 'ACTIVE' }> = []
const records = await loadAllActiveCustomers(async (query) => {
calls.push(query)
if (query.page === 1) {
return {
pages: 2,
records: [activeCustomer('10001', '客户一', '客户一有限公司', 'CUS-001')],
}
}
return {
pages: 2,
records: [activeCustomer('10002', '客户二', null, 'CUS-002')],
}
})
expect(calls).toEqual([
{ page: 1, size: 200, status: 'ACTIVE' },
{ page: 2, size: 200, status: 'ACTIVE' },
])
expect(records.map((customer) => customer.legalName?.trim() || customer.tenantName)).toEqual(['客户一有限公司', '客户二'])
expect(records.map((customer) => customer.legalName?.trim() || customer.tenantName).join(' ')).not.toContain('CUS-')
})
it('opens the shared unified order detail from the view action', () => {
const source = readFileSync(resolve('src/modules/inbounds/components/InboundTaskList.vue'), 'utf8')