feat(inventory): edit and delete existing lots
Lots could only be created; now they can be edited and removed: - Repository: updateLot (LWW) + softDeleteLot (tombstone). - Cubit: updateLot / deleteLot. - The add-lot sheet is now a shared add/edit sheet — tapping a lot opens it prefilled (type, year, quantity), with a trash action to delete. The reactive detail view refreshes on save/delete. Tests: repo updateLot/softDeleteLot + widget edit-lot and delete-lot. 42 green.
This commit is contained in:
parent
7e92410728
commit
f8d4d9a778
10 changed files with 192 additions and 16 deletions
|
|
@ -200,4 +200,59 @@ void main() {
|
|||
expect(find.text('90%'), findsOneWidget); // germination badge on the lot
|
||||
await disposeTree(tester);
|
||||
});
|
||||
|
||||
testWidgets('editing a lot updates its line', (tester) async {
|
||||
final repo = newTestRepository(db);
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
await repo.addLot(
|
||||
varietyId: id,
|
||||
harvestYear: 2020,
|
||||
quantity: const Quantity(kind: QuantityKind.packet, count: 1),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
wrapDetail(
|
||||
repository: repo,
|
||||
varietyId: id,
|
||||
species: newTestSpeciesRepository(db),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('Year 2020 · 1 packet')); // open the lot
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('addLot.year')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('2024').last);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('addLot.save')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Year 2024 · 1 packet'), findsOneWidget);
|
||||
await disposeTree(tester);
|
||||
});
|
||||
|
||||
testWidgets('deleting a lot removes it', (tester) async {
|
||||
final repo = newTestRepository(db);
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
await repo.addLot(varietyId: id, harvestYear: 2020);
|
||||
|
||||
await tester.pumpWidget(
|
||||
wrapDetail(
|
||||
repository: repo,
|
||||
varietyId: id,
|
||||
species: newTestSpeciesRepository(db),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.textContaining('Year 2020')); // open the lot
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('lot.delete')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('No lots yet.'), findsOneWidget);
|
||||
await disposeTree(tester);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue