import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' import test from 'node:test' const entry = new URL('../admin-test-env-acceptance.mjs', import.meta.url) const moduleFile = new URL('./inbound-fees.mjs', import.meta.url) test('admin full acceptance registers inbound fee lifecycle after measurement', async () => { const source = await readFile(entry, 'utf8') assert.match(source, /'inbound-measurement', 'inbound-fees', 'phase3-container-loading'/) assert.match(source, /normalized\.includes\('inbound-fees'\)/) assert.match(source, /\['merchant-qualification-fixture', 'orders', 'inbound-measurement'\]/) }) test('inbound fee lifecycle covers frozen source, version, publication and WAIT_SPLIT contracts', async () => { const source = await readFile(moduleFile, 'utf8') for (const token of [ '/fees/latest', '/fees/calculate', '/fees/published', '/fees/confirm', '/fees/send', '/fee-details', 'FBA_PRICING', 'MANUAL', 'CALCULATED', 'CONFIRMED', 'SENT', 'PUBLISHED', 'sourceFeeVersion', 'reviewStatus', 'publicationStatus', 'WAIT_SPLIT', 'toleranceConfirmed: true', ]) assert.match(source, new RegExp(token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))) assert.match(source, /人工发布头程费用并触发 Finance Outbox/) assert.match(source, /String\(initialResponse\?\.body\?\.code\) === 'A0404'/) assert.match(source, /对客合计仅含已发布头程与已审核其他应收且其他应付单列/) assert.doesNotMatch(source, /settlementIncluded|是否结算|参与结算/) }) test('initial fee preparation is reusable without confirming or publishing the fee', async () => { const source = await readFile(moduleFile, 'utf8') assert.match(source, /export async function ensureInitialCalculated/) const helper = source.slice(source.indexOf('export async function ensureInitialCalculated'), source.indexOf('export async function run')) assert.match(helper, /\/fees\/latest/) assert.match(helper, /\/fees\/calculate/) assert.match(helper, /feeStatus === 'CALCULATED'/) assert.doesNotMatch(helper, /\/fees\/confirm|\/fees\/send/) })