A bundled, curated knowledge layer — the differentiator of a serious seed app. For a variety's crop it shows how the plant reproduces and what it takes to keep the variety true: life cycle, pollination (self/cross + insect/wind), isolation distance, how many plants to save from, dry/wet processing, a difficulty pill, and a short tip — all in human words. - assets/catalog/seed_saving.json: curated public-domain data (Seed to Seed / Seed Savers), keyed by botanical FAMILY (defaults) with per-species/genus OVERRIDES that win — so e.g. Vicia faba is correctly insect-cross-pollinated despite the selfing Fabaceae default, and maize is wind-pollinated with a large population. Notes are locale-keyed (es/en), extensible to any language — a starter set, not a ceiling. - domain/seed_saving.dart (pure): enums + SeedSavingGuide (merge, note fallback) + SeedSavingData.guideFor (species → genus → family). - data/seed_saving_catalog.dart: loads the asset once into an in-memory singleton (no DB table, no migration); injector loads it at startup. - VarietyDetail gains (from the linked species — the reliable key, vs the editable category); detail screen shows a _SeedSavingView when a guide resolves. - i18n seedSaving block (labels + enum values + params) in en/es/pt/ast. - Tests: domain lookup/merge, the real asset's key corrections, and the detail section shows/hides. 314 suite tests green; analyze clean.
51 lines
1.8 KiB
Dart
51 lines
1.8 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:tane/domain/seed_saving.dart';
|
|
|
|
/// Guards the committed bundled seed-saving asset: it must parse, cover the
|
|
/// major families, and carry the notable per-species corrections the UI relies
|
|
/// on. Reads the file directly — no Flutter asset bundle — so it runs as a
|
|
/// plain VM test.
|
|
void main() {
|
|
final data =
|
|
parseSeedSaving(File('assets/catalog/seed_saving.json').readAsStringSync());
|
|
|
|
test('resolves the major families', () {
|
|
for (final family in const [
|
|
'Solanaceae',
|
|
'Fabaceae',
|
|
'Cucurbitaceae',
|
|
'Brassicaceae',
|
|
'Asteraceae',
|
|
'Apiaceae',
|
|
'Amaranthaceae',
|
|
'Poaceae',
|
|
]) {
|
|
expect(data.guideFor(family: family)?.hasAny, isTrue, reason: family);
|
|
}
|
|
});
|
|
|
|
test('faba bean is corrected to insect cross-pollination', () {
|
|
// The whole point of species overrides: unlike other legumes, Vicia faba
|
|
// crosses — the guidance must not inherit Fabaceae "self".
|
|
final g = data.guideFor(scientificName: 'Vicia faba', family: 'Fabaceae');
|
|
expect(g?.pollination, Pollination.cross);
|
|
expect(g?.vector, PollinationVector.insect);
|
|
expect(g?.noteFor('es'), isNotNull);
|
|
});
|
|
|
|
test('tomato self-pollinates and is wet-processed', () {
|
|
final g = data.guideFor(
|
|
scientificName: 'Solanum lycopersicum', family: 'Solanaceae');
|
|
expect(g?.pollination, Pollination.self);
|
|
expect(g?.processing, SeedProcessing.wet);
|
|
expect(g?.difficulty, SavingDifficulty.easy);
|
|
});
|
|
|
|
test('maize is wind-pollinated with a large population', () {
|
|
final g = data.guideFor(scientificName: 'Zea mays', family: 'Poaceae');
|
|
expect(g?.vector, PollinationVector.wind);
|
|
expect(g?.recommendedPlants, greaterThanOrEqualTo(50));
|
|
});
|
|
}
|