feat(app): ask 'how did it do?' when a harvest is noted (schema v13)
The note growers most wish they had two seasons later — did it do well, was it worth keeping — never had a home. New append-only GardenOutcomes table (lotId, season year, three-face rating, free note); the question appears ONCE, inline, right after recording a harvest in the batch story, and is skippable without a trace. The answer shows as one more story line. Rides backups/sync like every mutable table (JSON codec, LWW import, HLC clock absorb). Migration v12→v13 guarded + verified from every historical version.
This commit is contained in:
parent
92fd84590b
commit
bb5b3d4a43
20 changed files with 6030 additions and 15 deletions
|
|
@ -68,6 +68,12 @@ void main() {
|
|||
containerCount: 2,
|
||||
desiccantState: DesiccantState.dry,
|
||||
);
|
||||
await source.addGardenOutcome(
|
||||
lotId: lotId,
|
||||
year: 2024,
|
||||
rating: GardenOutcomeRating.good,
|
||||
notes: 'kept it',
|
||||
);
|
||||
await source.addVernacularName(
|
||||
varietyId,
|
||||
'tomate de la abuela',
|
||||
|
|
@ -126,6 +132,7 @@ void main() {
|
|||
expect(targetRows.externalLinks, sourceRows.externalLinks);
|
||||
expect(targetRows.germinationTests, sourceRows.germinationTests);
|
||||
expect(targetRows.conditionChecks, sourceRows.conditionChecks);
|
||||
expect(targetRows.gardenOutcomes, sourceRows.gardenOutcomes);
|
||||
expect(targetRows.movements, sourceRows.movements);
|
||||
expect(targetRows.attachments, sourceRows.attachments);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@ void main() {
|
|||
verifier = SchemaVerifier(GeneratedHelper());
|
||||
});
|
||||
|
||||
test('freshly created database matches the exported schema v12', () async {
|
||||
final schema = await verifier.schemaAt(12);
|
||||
test('freshly created database matches the exported schema v13', () async {
|
||||
final schema = await verifier.schemaAt(13);
|
||||
final db = AppDatabase(schema.newConnection());
|
||||
await verifier.migrateAndValidate(db, 12);
|
||||
await verifier.migrateAndValidate(db, 13);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
// Every historical version upgrades cleanly to the current schema (v12).
|
||||
for (var from = 1; from <= 11; from++) {
|
||||
test('upgrades v$from → v12 and matches the fresh schema', () async {
|
||||
// Every historical version upgrades cleanly to the current schema (v13).
|
||||
for (var from = 1; from <= 12; from++) {
|
||||
test('upgrades v$from → v13 and matches the fresh schema', () async {
|
||||
final connection = await verifier.startAt(from);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 12);
|
||||
await verifier.migrateAndValidate(db, 13);
|
||||
await db.close();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import 'schema_v9.dart' as v9;
|
|||
import 'schema_v10.dart' as v10;
|
||||
import 'schema_v11.dart' as v11;
|
||||
import 'schema_v12.dart' as v12;
|
||||
import 'schema_v13.dart' as v13;
|
||||
|
||||
class GeneratedHelper implements SchemaInstantiationHelper {
|
||||
@override
|
||||
|
|
@ -45,10 +46,12 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
|||
return v11.DatabaseAtV11(db);
|
||||
case 12:
|
||||
return v12.DatabaseAtV12(db);
|
||||
case 13:
|
||||
return v13.DatabaseAtV13(db);
|
||||
default:
|
||||
throw MissingSchemaException(version, versions);
|
||||
}
|
||||
}
|
||||
|
||||
static const versions = const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
static const versions = const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
|
||||
}
|
||||
|
|
|
|||
2223
apps/app_seeds/test/db/schema/schema_v13.dart
Normal file
2223
apps/app_seeds/test/db/schema/schema_v13.dart
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -139,6 +139,23 @@ void main() {
|
|||
}
|
||||
});
|
||||
|
||||
test('includes garden outcomes as story lines', () async {
|
||||
final lotId = await newLot();
|
||||
await repo.addGardenOutcome(
|
||||
lotId: lotId,
|
||||
year: 2026,
|
||||
rating: GardenOutcomeRating.good,
|
||||
notes: 'true to type, keeping it',
|
||||
);
|
||||
final history = await repo.lotHistory(lotId);
|
||||
final outcome = history.singleWhere(
|
||||
(e) => e.kind == LotHistoryKind.gardenOutcome,
|
||||
);
|
||||
expect(outcome.rating, GardenOutcomeRating.good);
|
||||
expect(outcome.year, 2026);
|
||||
expect(outcome.notes, 'true to type, keeping it');
|
||||
});
|
||||
|
||||
test('ignores other lots', () async {
|
||||
final lotId = await newLot();
|
||||
final otherLot = await newLot();
|
||||
|
|
|
|||
|
|
@ -79,6 +79,80 @@ void main() {
|
|||
await disposeTree(tester);
|
||||
});
|
||||
|
||||
testWidgets('harvesting asks "how did it do?" once, a face tap saves it', (
|
||||
tester,
|
||||
) async {
|
||||
final repo = newTestRepository(db);
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
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();
|
||||
|
||||
// Sowing does NOT ask; harvesting does.
|
||||
await tester.tap(find.byKey(const Key('history.sowToday')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('history.outcomeQuestion')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('history.harvestToday')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('history.outcomeQuestion')), findsOneWidget);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('history.outcomeNote')),
|
||||
'true to type',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('history.outcomeGood')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Question gone, answer saved, story shows it.
|
||||
expect(find.byKey(const Key('history.outcomeQuestion')), findsNothing);
|
||||
final outcomes = await db.select(db.gardenOutcomes).get();
|
||||
expect(outcomes.single.rating, GardenOutcomeRating.good);
|
||||
expect(outcomes.single.notes, 'true to type');
|
||||
expect(outcomes.single.year, DateTime.now().year);
|
||||
expect(find.text('It did well'), findsOneWidget);
|
||||
await disposeTree(tester);
|
||||
});
|
||||
|
||||
testWidgets('the harvest question can be dismissed without a trace', (
|
||||
tester,
|
||||
) async {
|
||||
final repo = newTestRepository(db);
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
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.harvestToday')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('history.outcomeDismiss')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('history.outcomeQuestion')), findsNothing);
|
||||
expect(await db.select(db.gardenOutcomes).get(), isEmpty);
|
||||
await disposeTree(tester);
|
||||
});
|
||||
|
||||
testWidgets('a plant lot offers harvest but not sowing', (tester) async {
|
||||
final repo = newTestRepository(db);
|
||||
final id = await repo.addQuickVariety(label: 'Rosemary');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue