tane/apps/app_seeds/test/ui/share_flow_test.dart
vjrj ceb606ae57 polish(detail): TODO review — calendar intro, drop abundance, collapse seed-saving
From the owner's TODO.org review of the shipped features:
- Crop calendar now says the months are YOUR notes: a hint line in the
  editor (cropCalendar.editorHint) and a caption under the 'this month'
  screen (calendar.selfNote) — it read as if the app knew when to sow.
- Dropped the 'how much I have' (abundance) input + display: it competed
  with the lot quantity as a second 'how much'. Removed from the lot sheet
  and the lot summary; the DB column + backup/CSV/catalog plumbing stay
  dormant (no destructive migration). offer_status carries 'do I share'.
- Seed-saving guidance moved into a collapsed expander (detail.seedSaving)
  — reference facts about the species shouldn't sit open among the
  grower's own records; opt-in depth, per progressive disclosure.
- Condition checks already live behind the collapsed 'advanced' expander
  (seed lots only) — left as the discreet power-user surface.

Tests: dropped the obsolete abundance→share nudge test; the seed-saving
section test now expands before asserting. analyze clean; suites green.
2026-07-11 14:08:10 +02:00

78 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tane/db/database.dart';
import 'package:tane/db/enums.dart';
import 'package:tane/ui/inventory_list_screen.dart';
import '../support/test_support.dart';
void main() {
late AppDatabase db;
setUp(() => db = newTestDatabase());
tearDown(() => db.close());
testWidgets('marking a lot to give away shows on its tile', (tester) async {
final repo = newTestRepository(db);
final id = await repo.addQuickVariety(label: 'Maize');
await repo.addLot(varietyId: id, harvestYear: 2024);
await tester.pumpWidget(
wrapDetail(
repository: repo,
varietyId: id,
species: newTestSpeciesRepository(db),
),
);
await tester.pumpAndSettle();
await tester.tap(find.textContaining('Year 2024')); // open the lot
await tester.pumpAndSettle();
await tester.ensureVisible(find.byKey(const Key('lot.addShare')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('lot.addShare')));
await tester.pumpAndSettle();
await tester.ensureVisible(find.byKey(const Key('share.shared')));
await tester.tap(find.byKey(const Key('share.shared')));
await tester.pumpAndSettle();
await tester.ensureVisible(find.byKey(const Key('addLot.save')));
await tester.tap(find.byKey(const Key('addLot.save')));
await tester.pumpAndSettle();
// The lot line now carries the share terms.
expect(find.textContaining('To give away'), findsOneWidget);
await disposeTree(tester);
});
testWidgets('the sharing filter narrows the list to what I share', (
tester,
) async {
final repo = newTestRepository(db);
final sharedId = await repo.addQuickVariety(label: 'Shared bean');
await repo.addLot(varietyId: sharedId, offerStatus: OfferStatus.exchange);
final privateId = await repo.addQuickVariety(label: 'Private bean');
await repo.addLot(varietyId: privateId);
await tester.pumpWidget(
wrapScreen(repository: repo, child: const InventoryListScreen()),
);
await tester.pumpAndSettle();
// Both listed; the shared one carries its badge, and the print action and
// filter chip are offered.
expect(find.text('Shared bean'), findsOneWidget);
expect(find.text('Private bean'), findsOneWidget);
expect(find.byKey(Key('inventory.shared.$sharedId')), findsOneWidget);
expect(find.byKey(const Key('inventory.printCatalog')), findsOneWidget);
await tester.tap(find.byKey(const Key('inventory.filter.sharing')));
await tester.pumpAndSettle();
expect(find.text('Shared bean'), findsOneWidget);
expect(find.text('Private bean'), findsNothing);
await disposeTree(tester);
});
}