feat(app): hint isolation distance when sowing a cross-pollinating crop
Some checks failed
ci / test-commons-core (push) Successful in 58s
ci / analyze (push) Successful in 1m49s
site / deploy (push) Successful in 38s
ci / test-app-seeds (push) Has been cancelled

One passive line in the batch story after a 'sown today' tap — 'this
species crosses, grow it ~400 m from others' — sourced from the bundled
seed-saving guidance (family default + species override). Selfers get
nothing: the trap is recording isolation religiously for beans where it
never mattered. No input fields, no schema change.
This commit is contained in:
vjrj 2026-07-18 12:31:42 +02:00
parent f1aa8f8e66
commit 1a826477f2
8 changed files with 116 additions and 7 deletions

View file

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tane/data/seed_saving_catalog.dart';
import 'package:tane/db/database.dart';
import 'package:tane/db/enums.dart';
import 'package:tane/domain/seed_saving.dart';
import '../support/test_support.dart';
@ -9,7 +11,10 @@ void main() {
late AppDatabase db;
setUp(() => db = newTestDatabase());
tearDown(() => db.close());
tearDown(() {
SeedSavingCatalog.data = null;
return db.close();
});
testWidgets('the lot tile opens the batch story, closed by its origin', (
tester,
@ -153,6 +158,52 @@ void main() {
await disposeTree(tester);
});
testWidgets('sowing a crosser drops the isolation hint; a selfer gets '
'nothing', (tester) async {
SeedSavingCatalog.data = SeedSavingData(
families: {
'Cucurbitaceae': const SeedSavingGuide(
pollination: Pollination.cross,
isolationMinM: 400,
),
'Solanaceae': const SeedSavingGuide(
pollination: Pollination.self,
isolationMinM: 3,
),
},
taxa: const {},
);
final repo = newTestRepository(db);
Future<void> sowAndCheck(String category, {required bool hinted}) async {
final id = await repo.addQuickVariety(label: 'x-$category');
await repo.updateVariety(id: id, label: 'x-$category', category: category);
final lotId = await repo.addLot(varietyId: id);
await tester.pumpWidget(
wrapDetail(
repository: repo,
varietyId: id,
species: newTestSpeciesRepository(db),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(Key('lot.history.$lotId')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('history.sowToday')));
await tester.pumpAndSettle();
expect(
find.byKey(const Key('history.isolationHint')),
hinted ? findsOneWidget : findsNothing,
);
await disposeTree(tester);
}
// The family drives it: squash (crosses, 400 m) hints; tomato does not.
await sowAndCheck('Cucurbitaceae', hinted: true);
expect(find.textContaining('400'), findsNothing); // tree disposed
await sowAndCheck('Solanaceae', hinted: false);
});
testWidgets('a plant lot offers harvest but not sowing', (tester) async {
final repo = newTestRepository(db);
final id = await repo.addQuickVariety(label: 'Rosemary');