feat(block1): germination tests per lot with derived rate
Record germination tests on a lot and surface the result. - GerminationEntry model with a derived rate (germinated / sample). VarietyLot carries its tests (most-recent first) and exposes latestGerminationRate. - VarietyRepository.addGerminationTest; watchVariety now also re-emits on germination-test changes, so the detail refreshes live. - Detail UI: each lot shows a germination % badge and a grass action that opens a sheet listing past tests and adding a new one (germinated + sample size). i18n strings (ES/EN). Tests: derived-rate + reactivity at the repository, and a widget test for the record-test → badge flow. Full suite: 35 passing, 0 skipped.
This commit is contained in:
parent
4e8b8293e0
commit
37427fa738
10 changed files with 405 additions and 6 deletions
|
|
@ -97,4 +97,42 @@ void main() {
|
|||
final detail = await repo.watchVariety(id).first;
|
||||
expect(detail!.category, 'My tomatoes');
|
||||
});
|
||||
|
||||
test(
|
||||
'addGerminationTest surfaces the latest derived rate on the lot',
|
||||
() async {
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
final lotId = await repo.addLot(varietyId: id, harvestYear: 2024);
|
||||
await repo.addGerminationTest(
|
||||
lotId: lotId,
|
||||
testedOn: 1000,
|
||||
sampleSize: 20,
|
||||
germinatedCount: 18,
|
||||
);
|
||||
|
||||
final lot = (await repo.watchVariety(id).first)!.lots.single;
|
||||
expect(lot.germinationTests, hasLength(1));
|
||||
expect(lot.latestGerminationRate, closeTo(0.9, 1e-9));
|
||||
},
|
||||
);
|
||||
|
||||
test('watchVariety reacts to a germination test being added', () async {
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
final lotId = await repo.addLot(varietyId: id);
|
||||
final queue = StreamQueue(repo.watchVariety(id));
|
||||
|
||||
final initial = await queue.next;
|
||||
expect(initial!.lots.single.germinationTests, isEmpty);
|
||||
|
||||
await repo.addGerminationTest(
|
||||
lotId: lotId,
|
||||
sampleSize: 10,
|
||||
germinatedCount: 9,
|
||||
);
|
||||
|
||||
final updated = await queue.next;
|
||||
expect(updated!.lots.single.latestGerminationRate, closeTo(0.9, 1e-9));
|
||||
|
||||
await queue.cancel();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue