This commit is contained in:
seb
2026-10-22 23:33:00 +02:00
parent d6e5da93cb
commit e31566e6ee
4 changed files with 121 additions and 2 deletions

View File

@@ -240,6 +240,47 @@ async function run() {
console.log('Obituaries after setOnAll:', obituariesAfterSetOnAll);
assert.equal(obituariesAfterSetOnAll.length, 0);
// 14. Test setCategoryIdsBySku generates obituary when removed from POS-enabled category
console.log('14. Testing setCategoryIdsBySku obituary generation and clearing...');
// Setup terminal: only has Cat A enabled
await store.posterminal.setOffAll(googleAuthId, terminal.id);
// Clear obituaries from setOffAll to start clean
provider.db.prepare('DELETE FROM posterminalobituary WHERE posterminal_id = ?').run(terminal.id);
await store.posterminal.setOn(googleAuthId, terminal.id, catA.id);
// Create article in Cat A
const artMoving = await store.article.createUnderParent({
googleAuthId,
parentId: catA.id,
name: 'Moving Article',
});
// Should have 0 obituaries on terminal
let obits = provider.db
.prepare('SELECT entity_type, entity_id FROM posterminalobituary WHERE posterminal_id = ?')
.all(terminal.id);
assert.equal(obits.length, 0);
// Move article from Cat A to Cat B (which is not enabled on terminal)
console.log('Moving article to Cat B (not on terminal)...');
await store.article.setCategoryIdsBySku(googleAuthId, artMoving.sku, [catB.id]);
obits = provider.db
.prepare('SELECT entity_type, entity_id FROM posterminalobituary WHERE posterminal_id = ?')
.all(terminal.id);
console.log('Obituaries after moving to Cat B:', obits);
assert.equal(obits.length, 1);
assert.deepEqual(obits[0], { entity_type: 'article', entity_id: artMoving.id });
// Move article back to Cat A (enabled on terminal)
console.log('Moving article back to Cat A (on terminal)...');
await store.article.setCategoryIdsBySku(googleAuthId, artMoving.sku, [catA.id]);
obits = provider.db
.prepare('SELECT entity_type, entity_id FROM posterminalobituary WHERE posterminal_id = ?')
.all(terminal.id);
console.log('Obituaries after moving back to Cat A:', obits);
assert.equal(obits.length, 0);
console.log('✅ ALL POSTERMINALOBITUARY TESTS PASSED');
} finally {
try {