This commit is contained in:
seb
2026-10-12 19:48:07 +02:00
parent 64d1772842
commit 28e62093b3
25 changed files with 979 additions and 125 deletions

View File

@@ -106,10 +106,17 @@ async function run() {
});
assert.equal(order.lines.length, 2);
// 4. Create shipping with state 'open' (not shipped yet)
console.log('4. Creating shipping with state "open"...');
// 4. Create shipment and shipping with state 'open' (not shipped yet)
console.log('4. Creating shipment and shipping with state "open"...');
const shipment = await store.shipment.create(googleAuthId, {
orderId: order.id,
lines: [
{ sku: trackedArt.sku, amount: 3 },
{ sku: untrackedArt.sku, amount: 2 },
],
});
const shippingOpen = await store.shipping.create(googleAuthId, {
manifestId: order.id,
manifestId: shipment.id,
type: 'parcel',
state: 'open',
});
@@ -200,8 +207,8 @@ async function run() {
{ message: 'Shipped shipping cannot be undone' },
);
// 8. Test order cannot be shipped again
console.log('8. Testing order cannot be shipped twice...');
// 8. Test order manifest cannot be used directly for shipping
console.log('8. Testing order manifest cannot be used directly for shipping...');
await assert.rejects(
async () => {
await store.shipping.create(googleAuthId, {
@@ -210,10 +217,10 @@ async function run() {
state: 'shipped',
});
},
{ message: 'Order already shipped' },
{ message: 'Manifest is not a shipment' },
);
// 9. Test direct creation with state 'shipped'
// 9. Test direct creation with state 'shipped' on shipment manifest
console.log('9. Testing direct creation with state "shipped"...');
const order2 = await store.order.create(googleAuthId, {
number: 'O-2026-002',
@@ -231,8 +238,13 @@ async function run() {
],
});
const shipment2 = await store.shipment.create(googleAuthId, {
orderId: order2.id,
lines: [{ sku: trackedArt.sku, amount: 2 }],
});
const directShipped = await store.shipping.create(googleAuthId, {
manifestId: order2.id,
manifestId: shipment2.id,
type: 'parcel',
state: 'shipped',
});