feat(quick-add): save & add another for rapid manual entry

The quick-add sheet no longer closes on every save: a new 'Save & add
another' action saves the seed, clears the form (keeping the chosen lot
type), refocuses the name field and shows an 'N added' running count, so
a whole shelf can be entered without reopening the sheet each time.
Plain Save still closes it. Adds a dedicated label field with its own
controller, submitAndAddAnother() on the cubit, and cubit + widget tests.
This commit is contained in:
vjrj 2026-07-09 14:45:48 +02:00
parent 89b61bc9e4
commit d3711e39b0
9 changed files with 240 additions and 18 deletions

View file

@ -19,6 +19,7 @@ void main() {
child: TaneApp(
repository: repo,
species: newTestSpeciesRepository(db),
onboarding: newTestOnboardingStore(),
),
),
);
@ -57,4 +58,61 @@ void main() {
await disposeTree(tester);
},
);
testWidgets(
'save & add another keeps the sheet open and accumulates a count',
(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),
onboarding: newTestOnboardingStore(),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('home.inventory')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('inventory.addFab')));
await tester.pumpAndSettle();
// First seed via "save & add another": the sheet stays open.
await tester.enterText(
find.byKey(const Key('quickAdd.labelField')),
'Alpha',
);
await tester.tap(find.byKey(const Key('quickAdd.saveAndAddAnother')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('quickAdd.labelField')), findsOneWidget);
expect(find.text('1 added'), findsOneWidget);
// The field was cleared; add a second one.
await tester.enterText(
find.byKey(const Key('quickAdd.labelField')),
'Beta',
);
await tester.tap(find.byKey(const Key('quickAdd.saveAndAddAnother')));
await tester.pumpAndSettle();
expect(find.text('2 added'), findsOneWidget);
// A third one via plain Save closes the sheet.
await tester.enterText(
find.byKey(const Key('quickAdd.labelField')),
'Gamma',
);
await tester.tap(find.byKey(const Key('quickAdd.save')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('quickAdd.labelField')), findsNothing);
// All three landed in the inventory.
expect(await db.select(db.varieties).get(), hasLength(3));
await disposeTree(tester);
},
);
}