Record where the guidance comes from (copyright/attribution) and make clear it is general, not local gospel — kept light: - seed_saving.json gains a top-level sources list (Seed to Seed / Seed Savers Exchange / Organic Seed Alliance); parsed into SeedSavingData.sources, exposed via SeedSavingCatalog.sources. - The detail section shows a small muted footer: an italic 'advisory — adapt to your climate' line plus a 'Source: …' credit. - i18n seedSaving.advisory + sourcePrefix (en/es/pt/ast). - Tests: asset carries sources; the section renders advisory + credit.
57 lines
2 KiB
Dart
57 lines
2 KiB
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/domain/seed_saving.dart';
|
|
|
|
import '../support/test_support.dart';
|
|
|
|
/// The variety detail shows "how to save this seed" when the bundled catalog
|
|
/// has guidance for the crop's family, and hides it otherwise.
|
|
void main() {
|
|
late AppDatabase db;
|
|
setUp(() {
|
|
db = newTestDatabase();
|
|
SeedSavingCatalog.data = parseSeedSaving('''
|
|
{
|
|
"sources": [ { "title": "Seed to Seed" } ],
|
|
"families": {
|
|
"Solanaceae": { "pollination": "self", "isolationMinM": 3, "isolationMaxM": 6, "processing": "wet", "difficulty": "easy" }
|
|
},
|
|
"species": {}
|
|
}
|
|
''');
|
|
});
|
|
tearDown(() {
|
|
SeedSavingCatalog.data = null;
|
|
return db.close();
|
|
});
|
|
|
|
Future<void> pumpDetailFor(WidgetTester tester, String? category) async {
|
|
final repo = newTestRepository(db);
|
|
final id = await repo.addQuickVariety(label: 'Tomate', category: category);
|
|
await tester.pumpWidget(wrapDetail(repository: repo, varietyId: id));
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
testWidgets('shows the seed-saving section for a known family', (tester) async {
|
|
await pumpDetailFor(tester, 'Solanaceae');
|
|
|
|
expect(find.text('Saving its seed'), findsOneWidget);
|
|
// The pollination line is a Text.rich (label + value), so match the run.
|
|
expect(find.textContaining('Self-pollinating'), findsOneWidget);
|
|
expect(find.text('Easy'), findsOneWidget); // the difficulty pill
|
|
// Advisory note + a light source credit.
|
|
expect(find.textContaining('adapt it to your climate'), findsOneWidget);
|
|
expect(find.textContaining('Seed to Seed'), findsOneWidget);
|
|
|
|
await disposeTree(tester);
|
|
});
|
|
|
|
testWidgets('hides the section when nothing matches', (tester) async {
|
|
await pumpDetailFor(tester, 'Unknownaceae');
|
|
|
|
expect(find.text('Saving its seed'), findsNothing);
|
|
|
|
await disposeTree(tester);
|
|
});
|
|
}
|