91 lines
2.7 KiB
JavaScript
91 lines
2.7 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const OrderIndexService = require('../../../app/service/systemMethods/order/index');
|
|
const { buildRows, createOrderHarness } = require('../../support/order_service_test_helper');
|
|
|
|
describe('test/app/controller/system.order.outbound.exposure.test.js', () => {
|
|
it('should keep manualOutboundOrder exposed and remove deprecated outboundOrder alias', async () => {
|
|
const { service } = createOrderHarness(OrderIndexService, {
|
|
rowsByModule: {
|
|
order: buildRows(1, () => ({
|
|
step: 1,
|
|
dispatch_lane: 'm4',
|
|
})),
|
|
},
|
|
});
|
|
|
|
const methodNames = [
|
|
'markOutboundOrder',
|
|
'manualOutboundOrder',
|
|
];
|
|
|
|
assert.equal(typeof service.markOutboundOrder, 'undefined');
|
|
assert.equal(typeof service.outboundOrder, 'undefined');
|
|
assert.equal(typeof service.manualOutboundOrder, 'function');
|
|
|
|
const methodsManifest = require('../../../methods/system.json');
|
|
const exposedMethodNames = methodsManifest.methods.groups
|
|
.flatMap(group => (Array.isArray(group.list) ? group.list : []))
|
|
.map(item => item.method);
|
|
|
|
const hasInternalOutboundMethod = exposedMethodNames.some(methodName => {
|
|
return methodName === 'order.markOutboundOrder';
|
|
});
|
|
|
|
const hasDeprecatedOutboundAlias = exposedMethodNames.some(methodName => {
|
|
return methodName === 'order.outboundOrder';
|
|
});
|
|
|
|
assert.equal(hasInternalOutboundMethod, false);
|
|
assert.equal(hasDeprecatedOutboundAlias, false);
|
|
|
|
for (const methodName of methodNames) {
|
|
if (methodName === 'markOutboundOrder') {
|
|
continue;
|
|
}
|
|
|
|
assert.equal(typeof service[methodName], 'function');
|
|
}
|
|
});
|
|
|
|
it('should pass batch params through manualOutboundOrder to orderDeliveryMigration and return its result', async () => {
|
|
const { ctx, service } = createOrderHarness(OrderIndexService, {
|
|
rowsByModule: {
|
|
order: buildRows(1),
|
|
},
|
|
});
|
|
|
|
const requestData = {
|
|
warehouseId: 100000,
|
|
warehouseIds: [ 100000, 100001 ],
|
|
queryTimeoutMs: 12345,
|
|
executionTimeoutMs: 23456,
|
|
batchSize: 20,
|
|
customFlag: 'keep-as-is',
|
|
};
|
|
|
|
const expectedResult = {
|
|
ok: true,
|
|
totalCreated: 8,
|
|
};
|
|
|
|
let receivedPayload = null;
|
|
ctx.service = {
|
|
systems: {
|
|
orderDeliveryMigration: {
|
|
async syncOutboundOrdersToDelivery(data) {
|
|
receivedPayload = data;
|
|
return expectedResult;
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const result = await service.manualOutboundOrder(requestData);
|
|
|
|
assert.strictEqual(receivedPayload, requestData);
|
|
assert.deepEqual(result, expectedResult);
|
|
});
|
|
});
|