53 lines
2.0 KiB
TypeScript
53 lines
2.0 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|||
|
|
import { resolve } from 'node:path'
|
||
|
|
import { describe, expect, it } from 'vitest'
|
||
|
|
|
||
|
|
function source(path: string) {
|
||
|
|
return readFileSync(resolve(process.cwd(), path), 'utf8')
|
||
|
|
}
|
||
|
|
|
||
|
|
describe('finance five-page delivery contract', () => {
|
||
|
|
const routes = source('src/modules/finance/routes.ts')
|
||
|
|
const navigation = source('src/core/navigation/adminNavigation.ts')
|
||
|
|
const api = source('src/modules/finance/api/finance.ts')
|
||
|
|
|
||
|
|
const pages = [
|
||
|
|
['finance/customer-accounts', '客户账户'],
|
||
|
|
['finance/customer-arap', '客户应收应付'],
|
||
|
|
['finance/customer-statements', '客户对账单'],
|
||
|
|
['finance/settlement-receivables', '结算单应收'],
|
||
|
|
['finance/settlement-payables', '结算单应付'],
|
||
|
|
] as const
|
||
|
|
|
||
|
|
it('registers exactly the five formal routes and menu entries', () => {
|
||
|
|
for (const [path, title] of pages) {
|
||
|
|
expect(routes).toContain(`path: '${path}'`)
|
||
|
|
expect(routes).toContain(`title: '${title}'`)
|
||
|
|
expect(navigation).toContain(`path: '/${path}'`)
|
||
|
|
expect(navigation).toContain(`title: '${title}'`)
|
||
|
|
}
|
||
|
|
expect(routes.match(/path: 'finance\//g)).toHaveLength(5)
|
||
|
|
expect(navigation.match(/path: '\/finance\//g)).toHaveLength(5)
|
||
|
|
})
|
||
|
|
|
||
|
|
it('does not expose the old three routes or out-of-scope reports', () => {
|
||
|
|
for (const forbidden of ['/finance/bills', '/finance/receipts', '/finance/costs', '费用分析', '利润表']) {
|
||
|
|
expect(routes).not.toContain(forbidden)
|
||
|
|
expect(navigation).not.toContain(forbidden)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
it('keeps production reads on fixed DTO endpoints only', () => {
|
||
|
|
for (const endpoint of ['customer-accounts', 'fee-pool', 'statements', 'receivable-settlements', 'payable-settlements']) {
|
||
|
|
expect(api).toContain(`${basePathMarker(endpoint)}`)
|
||
|
|
}
|
||
|
|
expect(api).not.toContain('function listFinanceBills')
|
||
|
|
expect(api).not.toContain('function listFinanceReceipts')
|
||
|
|
expect(api).not.toContain('function listFinanceCosts')
|
||
|
|
})
|
||
|
|
})
|
||
|
|
|
||
|
|
function basePathMarker(endpoint: string) {
|
||
|
|
return '${basePath}/' + endpoint
|
||
|
|
}
|