This commit is contained in:
seb
2026-10-12 13:52:16 +02:00
parent c614a67b97
commit 3d6bc97411
5 changed files with 127 additions and 38 deletions

View File

@@ -142,13 +142,25 @@ async function run() {
const untrackedLedger = await store.ledger.listBySku(googleAuthId, untrackedArt.sku);
assert.equal(untrackedLedger.length, 0, 'Untracked article should not have warehouse ledger entries');
// Assert article history
// Assert article history: order goes into history, shipment does NOT
const history = await store.article.getHistoryBySku(googleAuthId, trackedArt.sku);
console.log('Tracked article history:', history.map((h) => h.text));
const shippingHistory = history.find((h) => h.text.includes('Versand Auftrag O-2026-001'));
assert(shippingHistory, 'Article history should contain shipping entry');
assert(shippingHistory.text.includes('Max Mustermann'), 'Article history should mention customer');
assert(shippingHistory.text.includes('Hauptlager'), 'Article history should mention warehouse');
const orderHistory = history.find((h) => h.text === 'Auftrag O-2026-001 (Kunde: "Max Mustermann", Menge: 3)');
assert(orderHistory, 'Article history should contain order creation entry');
const shippingHistory = history.find((h) => h.text.includes('Versand Auftrag'));
assert(!shippingHistory, 'Article history should NOT report the shipment');
// Untracked article also has the order in history, but not the shipment
const untrackedHistory = await store.article.getHistoryBySku(googleAuthId, untrackedArt.sku);
console.log('Untracked article history:', untrackedHistory.map((h) => h.text));
assert(
untrackedHistory.some((h) => h.text === 'Auftrag O-2026-001 (Kunde: "Max Mustermann", Menge: 2)'),
'Untracked article history should contain order creation entry',
);
assert(
!untrackedHistory.some((h) => h.text.includes('Versand Auftrag')),
'Untracked article history should NOT report the shipment',
);
// 6. Test immutability: once shipped, cannot be deleted
console.log('6. Testing cannot delete shipped shipping...');