fixes before build

This commit is contained in:
gitea
2026-08-31 16:51:31 +02:00
parent 7692809219
commit 756f9db356
34 changed files with 3542 additions and 837 deletions
+35 -9
View File
@@ -6,8 +6,29 @@ import 'test_helpers.dart';
void main() {
ensureTestSqlite();
test('deleting a product keeps the trip line and drops the catalog row',
() async {
test(
'deleting a product keeps the trip line and drops the catalog row',
() async {
final repository = memoryRepository();
final shopId = await repository.saveShop(
supermarket: 'Jumbo',
shoppedAt: DateTime(2026, 8, 12),
items: [LineItem(id: '1', name: 'Milk', price: 1.5)],
);
final products = await repository.getAll();
expect(products, hasLength(1));
await repository.deleteProduct(products.single.id);
expect(await repository.getAll(), isEmpty);
final items = await repository.getShopItems(shopId);
expect(items, hasLength(1));
expect(items.single.name, 'Milk');
expect(items.single.productId, isNull);
},
);
test('addShopItem appends a line and updates the trip total', () async {
final repository = memoryRepository();
final shopId = await repository.saveShop(
supermarket: 'Jumbo',
@@ -15,15 +36,20 @@ void main() {
items: [LineItem(id: '1', name: 'Milk', price: 1.5)],
);
final products = await repository.getAll();
expect(products, hasLength(1));
await repository.deleteProduct(products.single.id);
await repository.addShopItem(
shopId: shopId,
item: LineItem(id: '2', name: 'Bread', price: 2),
);
expect(await repository.getAll(), isEmpty);
final shop = (await repository.getShop(shopId))!;
expect(shop.total, 3.5);
final items = await repository.getShopItems(shopId);
expect(items, hasLength(1));
expect(items.single.name, 'Milk');
expect(items.single.productId, isNull);
expect(items, hasLength(2));
expect(items.map((item) => item.name), ['Milk', 'Bread']);
expect((await repository.getAll()).map((product) => product.name).toSet(), {
'Milk',
'Bread',
});
});
test('deleting all products leaves shopping trips in place', () async {