feat: sync shop icons and continue imports in v1.1.4

This commit is contained in:
fatequod
2026-09-10 11:40:15 +02:00
parent b232d3f18f
commit e5b2a90fc3
10 changed files with 490 additions and 14 deletions
+16 -6
View File
@@ -29,9 +29,10 @@ test('first run safely starts at the newest order without backfilling history',
assert.deepEqual(result, { status: 'initialized', cursor: 812, processed: 0 });
});
test('cursor advances only through confirmed successes and stops before failed order', async () => {
test('a failed order is skipped so later orders can still be imported', async () => {
const writes = [];
const imported = [];
const errors = [];
const config = { _id: 'default', lastOrderId: 10 };
const api = { makeRequest: async () => ({ orders: [oldOrder(11), oldOrder(12), oldOrder(13)] }) };
const result = await importOrdersForShop(config, api, {
@@ -43,14 +44,23 @@ test('cursor advances only through confirmed successes and stops before failed o
return { status: 'imported', psOrderId: id, orbitoOrderId: `orbito-${id}` };
},
setLastOrderId: async id => writes.push(id),
Log: silentLog,
Log: { ...silentLog, error: (message, details) => errors.push({ message, details }) },
now: () => new Date('2026-01-02T00:00:00Z').getTime(),
});
assert.deepEqual(imported, [11, 12]);
assert.deepEqual(writes, [11]);
assert.equal(config.lastOrderId, 11);
assert.deepEqual(result, { status: 'processed', cursor: 11, processed: 1 });
assert.deepEqual(imported, [11, 12, 13]);
assert.deepEqual(writes, [13]);
assert.equal(config.lastOrderId, 13);
assert.deepEqual(result, { status: 'processed', cursor: 13, processed: 2 });
assert.deepEqual(errors, [{
message: 'Failed to import PS order; skipping order and continuing',
details: {
orderId: 12,
previousCursor: 11,
cursor: 12,
error: 'invalid order',
},
}]);
});
test('existing Orbito order repairs a missing mapping before advancing the cursor', async () => {