This commit is contained in:
seb
2026-10-16 12:35:07 +02:00
parent 70e3ae7a87
commit 796f6a3272
23 changed files with 193 additions and 38 deletions

View File

@@ -157,14 +157,27 @@ async function runTests() {
parentId: cat.id,
name: 'Test Article',
});
assert.equal(article.track_stock, true, 'Default track_stock must be true');
assert.equal(article.track_stock, false, 'Default track_stock must be false');
const fetchedArt = await store.article.getBySku(googleAuthId, article.sku);
assert.equal(fetchedArt.article.track_stock, true, 'getBySku must return track_stock: true');
assert.equal(fetchedArt.article.track_stock, false, 'getBySku must return track_stock: false');
await store.article.setTrackStockBySku(googleAuthId, article.sku, false);
// Enabling track_stock without a warehouse must fail
await assert.rejects(
async () => store.article.setTrackStockBySku(googleAuthId, article.sku, true),
/At least one warehouse is required to enable stock tracking/,
);
// Create warehouse to allow enabling track_stock
await store.warehouse.create(googleAuthId, { name: 'Storage WH' });
await store.article.setTrackStockBySku(googleAuthId, article.sku, true);
const afterSet = await store.article.getBySku(googleAuthId, article.sku);
assert.equal(afterSet.article.track_stock, false, 'setTrackStockBySku false must update track_stock');
assert.equal(afterSet.article.track_stock, true, 'setTrackStockBySku true must update track_stock');
await store.article.updateBySku(googleAuthId, article.sku, { track_stock: false });
const afterDisable = await store.article.getBySku(googleAuthId, article.sku);
assert.equal(afterDisable.article.track_stock, false, 'updateBySku track_stock: false must update track_stock');
await store.article.updateBySku(googleAuthId, article.sku, { track_stock: true });
const afterUpdate = await store.article.getBySku(googleAuthId, article.sku);