Add a small curated catalog of Iberian horticultural species and let a variety be linked to it from the edit sheet. - assets/catalog/species.json: 14 species with botanical family and ES/EN common names (wikidata_qid/gbif_key deferred to the varilla enrichment). - SpeciesRepository: idempotent seedBundled (is_bundled rows, keyed by scientific name) + search by scientific/common name with a locale-best label. Seeded on startup from DI. - VarietyRepository.linkSpecies: sets species_id and prefills category from the species' family when empty (never overwrites an existing category). VarietyDetail now carries the scientific name. - Edit sheet gains a live species-search field; the detail view shows the scientific name (italic). i18n strings added (ES/EN). Tests: catalog parse, idempotent seeding, search by scientific/common name, linkSpecies prefill semantics, and a widget test for the autocomplete → link → scientific-name-shown flow. Full suite: 32 passing, 0 skipped.
56 lines
1.7 KiB
Dart
56 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:tane/app.dart';
|
|
import 'package:tane/i18n/strings.g.dart';
|
|
|
|
import '../support/test_support.dart';
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'quick-add: empty label errors; filling it saves and lists the seed',
|
|
(tester) async {
|
|
LocaleSettings.setLocaleSync(AppLocale.en);
|
|
final db = newTestDatabase();
|
|
addTearDown(db.close);
|
|
final repo = newTestRepository(db);
|
|
|
|
await tester.pumpWidget(
|
|
TranslationProvider(
|
|
child: TaneApp(
|
|
repository: repo,
|
|
species: newTestSpeciesRepository(db),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
// Starts empty.
|
|
expect(
|
|
find.text('No seeds yet. Tap + to add your first.'),
|
|
findsOneWidget,
|
|
);
|
|
|
|
// Open the quick-add sheet.
|
|
await tester.tap(find.byKey(const Key('inventory.addFab')));
|
|
await tester.pumpAndSettle();
|
|
|
|
// Saving with an empty label surfaces the validation message.
|
|
await tester.tap(find.byKey(const Key('quickAdd.save')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Give it a name'), findsOneWidget);
|
|
|
|
// Enter a name and save.
|
|
await tester.enterText(
|
|
find.byKey(const Key('quickAdd.labelField')),
|
|
'Grandma tomato',
|
|
);
|
|
await tester.tap(find.byKey(const Key('quickAdd.save')));
|
|
await tester.pumpAndSettle();
|
|
|
|
// Sheet closed and the seed shows in the list.
|
|
expect(find.byKey(const Key('quickAdd.labelField')), findsNothing);
|
|
expect(find.text('Grandma tomato'), findsOneWidget);
|
|
await disposeTree(tester);
|
|
},
|
|
);
|
|
}
|