u
This commit is contained in:
@@ -145,8 +145,13 @@ async function run() {
|
||||
// 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 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 orderHistory = history.find((h) => h.text === 'Auftrag O-2026-001 (Kunde: "Max Mustermann", Menge: 3, € 59,50)');
|
||||
assert(orderHistory, 'Article history should contain order creation entry with formatted gross price');
|
||||
assert(orderHistory.meta, 'Article history entry should have meta');
|
||||
const parsedMeta = JSON.parse(orderHistory.meta);
|
||||
assert.equal(parsedMeta.type, 'order');
|
||||
assert.equal(parsedMeta.orderId, order.id);
|
||||
assert.equal(parsedMeta.gross, 59.5);
|
||||
const shippingHistory = history.find((h) => h.text.includes('Versand Auftrag'));
|
||||
assert(!shippingHistory, 'Article history should NOT report the shipment');
|
||||
|
||||
@@ -154,14 +159,29 @@ async function run() {
|
||||
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',
|
||||
untrackedHistory.some((h) => h.text === 'Auftrag O-2026-001 (Kunde: "Max Mustermann", Menge: 2, € 23,80)'),
|
||||
'Untracked article history should contain order creation entry with formatted gross price',
|
||||
);
|
||||
assert(
|
||||
!untrackedHistory.some((h) => h.text.includes('Versand Auftrag')),
|
||||
'Untracked article history should NOT report the shipment',
|
||||
);
|
||||
|
||||
// Test order import with historical date preserves date in article history
|
||||
const historicalDate = '2023-04-15T10:30:00.000Z';
|
||||
await store.order.create(googleAuthId, {
|
||||
number: 'O-HIST-001',
|
||||
date: historicalDate,
|
||||
createdAt: historicalDate,
|
||||
lines: [{ sku: trackedArt.sku, amount: 1, net: 10, taxrate: 19 }],
|
||||
});
|
||||
const histWithOld = await store.article.getHistoryBySku(googleAuthId, trackedArt.sku);
|
||||
const oldEntry = histWithOld.find((h) => h.text.startsWith('Auftrag O-HIST-001'));
|
||||
assert(oldEntry, 'Historical order entry should exist in article history');
|
||||
assert.equal(new Date(oldEntry.date).toISOString(), historicalDate, 'History entry should preserve historical order date');
|
||||
const oldMeta = JSON.parse(oldEntry.meta);
|
||||
assert.equal(oldMeta.orderNumber, 'O-HIST-001');
|
||||
|
||||
// 6. Test immutability: once shipped, cannot be deleted
|
||||
console.log('6. Testing cannot delete shipped shipping...');
|
||||
await assert.rejects(
|
||||
|
||||
Reference in New Issue
Block a user