fix(shopping): NULLIF-Guard gegen servings_default=0 in Aggregation
Some checks failed
Build & Publish Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
hsiegeln
2026-04-21 23:06:19 +02:00
parent c31a9c6110
commit 494b672e8d
2 changed files with 13 additions and 1 deletions

View File

@@ -172,4 +172,16 @@ describe('listShoppingList aggregation', () => {
addRecipeToCart(db, id, null);
expect(listShoppingList(db).uncheckedCount).toBe(2);
});
it('does not blow up when servings_default is zero (silent NULL total_quantity)', () => {
const db = openInMemoryForTest();
const id = insertRecipe(db, recipe({
servings_default: 0,
ingredients: [{ position: 1, quantity: 100, unit: 'g', name: 'Mehl', note: null, raw_text: '', section_heading: null }]
}));
addRecipeToCart(db, id, null, 4);
const rows = listShoppingList(db).rows;
expect(rows).toHaveLength(1);
expect(rows[0].total_quantity).toBeNull();
});
});