优化
This commit is contained in:
@@ -14,8 +14,8 @@ test('fixed customer supplier selection paginates and never creates a fallback',
|
||||
async request(method, path) {
|
||||
calls.push({ method, path })
|
||||
const data = path.includes('/123?') ? supplier : path.includes('page=2')
|
||||
? { records: [supplier], total: 101 }
|
||||
: { records: Array.from({ length: 100 }, () => ({ id: '99', status: 'ACTIVE', category: 'BOOKING' })), total: 101 }
|
||||
? { records: [supplier], size: 20, total: 21 }
|
||||
: { records: Array.from({ length: 20 }, () => ({ id: '99', status: 'ACTIVE', category: 'BOOKING' })), size: 20, total: 21 }
|
||||
return { body: { data } }
|
||||
},
|
||||
apiSuccess(_module, _name, response) { return response.body.data },
|
||||
@@ -30,6 +30,22 @@ test('fixed customer supplier selection paginates and never creates a fallback',
|
||||
})
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url))
|
||||
test('reused suppliers must match carrier and trucking scope in both list and detail', async () => {
|
||||
for (const criteria of [{ carrierCode: 'MATSON' }, { truckingScope: 'OVERSEAS' }]) {
|
||||
const good = { id: '123', category: 'BOOKING', status: 'ACTIVE', carrierCodes: ['MATSON'], truckingScope: 'OVERSEAS' }
|
||||
let detail = good
|
||||
const context = { options: { fixedCustomerId: '456' }, marker: 'REUSE',
|
||||
async request(method, path) {
|
||||
assert.equal(method, 'GET')
|
||||
return { body: { data: path.includes('/123?') ? detail : { records: [
|
||||
{ ...good, id: '999', carrierCodes: [], truckingScope: 'DOMESTIC' }, good], total: 2 } } }
|
||||
}, apiSuccess(_module, _name, response) { return response.body.data }, addStep() {},
|
||||
}
|
||||
assert.equal((await loadSupplier(context, 'BOOKING', criteria)).id, '123')
|
||||
detail = { ...good, carrierCodes: [], truckingScope: 'DOMESTIC' }
|
||||
assert.equal(await loadSupplier(context, 'BOOKING', criteria), null)
|
||||
}
|
||||
})
|
||||
const source = fs.readFileSync(path.join(here, 'finance-full-fixtures.mjs'), 'utf8')
|
||||
|
||||
test('finance fixture module is independently exported and marker isolated', () => {
|
||||
|
||||
Reference in New Issue
Block a user