优化
This commit is contained in:
@@ -28,9 +28,8 @@ export function beijingDate(now = new Date()) {
|
||||
return `${parts.year}${parts.month}${parts.day}`
|
||||
}
|
||||
|
||||
export function matchesProcurementNo(orderNo, prefix, now = new Date()) {
|
||||
return typeof prefix === 'string' && prefix.length > 0
|
||||
&& new RegExp(`^${prefix}${beijingDate(now)}\\d{4}$`).test(String(orderNo || ''))
|
||||
export function matchesProcurementNo(orderNo, now = new Date()) {
|
||||
return new RegExp(`^CG${beijingDate(now)}\\d{4}$`).test(String(orderNo || ''))
|
||||
}
|
||||
|
||||
async function poll(action, predicate, attempts = 60, intervalMs = 1_000) {
|
||||
@@ -133,8 +132,8 @@ async function procurementFlow(context, fixture, token, warehouseId) {
|
||||
customerName: fixture.tenantName, customerToken: token, warehouseId, upload,
|
||||
readWallet: async () => { const result = await platformAccount(context, customerId); if (!success(result.response) || !result.account) throw new Error('本轮客户钱包查询失败'); return result.account } })
|
||||
assert(context, '采购正常全链路及资金完成', null, proof.status === 'PASSED', `orderNo=${proof.orderNo}`)
|
||||
assert(context, '采购单号日期和客户前缀正确', null,
|
||||
fixture.expectedProcurementPrefix ? matchesProcurementNo(proof.orderNo, fixture.expectedProcurementPrefix) : /^[A-Z0-9]{1,8}\d{8}\d{4}$/.test(proof.orderNo), `orderNo=${proof.orderNo}`)
|
||||
assert(context, '采购单号为CG加北京时间日期和流水', null,
|
||||
matchesProcurementNo(proof.orderNo), `orderNo=${proof.orderNo}`)
|
||||
return { orderNo: proof.orderNo, walletBusinessNos: proof.walletBusinessNos, settledAmountCny: proof.settledAmountCny }
|
||||
} finally {
|
||||
for (const check of context.createdResources.procurementSample?.checks || []) assert(context, check.label, null, check.passed)
|
||||
|
||||
Reference in New Issue
Block a user