test(acceptance): reuse fixed customers and align native fulfillment flows
This commit is contained in:
@@ -34,7 +34,7 @@ function fixture(fault = '') {
|
||||
} else if (method === 'GET' && path.endsWith('/OF-1')) data = { offer }
|
||||
else if (method === 'GET' && path.endsWith('/BK-1')) data = created.inquiry
|
||||
else if (method === 'POST' && path.endsWith('/OF-1/inquiries')) {
|
||||
assert.equal(body.sourceOrderNo, 'LB-1'); assert.equal(body.sourceOrderVersion, 2)
|
||||
assert.equal(body.sourceOrderNo, 'LB-1'); assert.equal(Number(body.sourceOrderVersion), 2)
|
||||
assert.equal(body.customerId, '101'); assert.equal(body.expectedPalletCount, 2)
|
||||
assert.equal(body.cargo.packageCount, 3)
|
||||
if (fault === 'network') return { http: 0 }
|
||||
@@ -68,6 +68,21 @@ test('pool binding preserves original demand and confirms only one commercial or
|
||||
assert.equal(f.writes(), 4)
|
||||
})
|
||||
|
||||
for (const native of [true, false]) test(`native Long inquiry versions remain bounded: ${native ? 'encoded strings' : 'invalid empty value'}`, async () => {
|
||||
const f = fixture()
|
||||
// 生产 fixture 已将版本规范为JS整数;HTTP的Long版本仍为规范十进制字符串。
|
||||
if (!native) f.args.demand.version = ''
|
||||
const request = f.context.request
|
||||
f.context.request = async (...args) => {
|
||||
const response = await request(...args)
|
||||
response.body.data = JSON.parse(JSON.stringify(response.body.data, (key, value) =>
|
||||
/^(version|recordVersion|tripRecordVersion|offerRecordVersion)$/.test(key) ? native ? String(value) : '' : value))
|
||||
return response
|
||||
}
|
||||
if (native) assert.equal((await bindLooseboardDemand(f.context, f.args)).status, 'CONFIRMED_ORIGINAL_ORDER')
|
||||
else { await assert.rejects(bindLooseboardDemand(f.context, f.args), /散板原单/); assert.equal(f.writes(), 0) }
|
||||
})
|
||||
|
||||
for (const [fault, maxWrites] of [['customer', 0], ['capacity', 0], ['network', 1], ['replay', 2], ['new order', 3], ['price', 3], ['binding', 4], ['disk', 0]]) {
|
||||
test(`pool binding stops on ${fault} without another order or automatic retry`, async () => {
|
||||
const f = fixture(fault)
|
||||
|
||||
Reference in New Issue
Block a user