tane/apps/app_seeds/test/ui/home_screen_test.dart
vjrj e852b569ce fix(nav): inventory is a spoke off the home hub — back arrow, no duplicate drawer
The inventory screen carried its own const AppDrawer() (no marketEnabled),
so opening the menu from inventory greyed out market/chat/profile — the
recurring 'phase 1' look. It was also reached via go() (route replace),
which is why it showed a hamburger instead of a back arrow like the market.

Make it coherent with the market: reach inventory via push() (from the
home card and the drawer), and drop its drawer so the AppBar shows a back
arrow returning to the home hub. The drawer now lives only on the home
screen, which always passes marketEnabled — the wrong-drawer bug class is
gone. Update the home_screen test to assert the spoke has a back arrow and
no hamburger.
2026-07-10 16:24:54 +02:00

104 lines
3.4 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() {
Widget app(db) => TranslationProvider(
child: TaneApp(
repository: newTestRepository(db),
species: newTestSpeciesRepository(db),
onboarding: newTestOnboardingStore(),
),
);
testWidgets('home shows the menu and navigates to inventory', (tester) async {
LocaleSettings.setLocaleSync(AppLocale.en);
final db = newTestDatabase();
addTearDown(db.close);
await tester.pumpWidget(app(db));
await tester.pumpAndSettle();
expect(find.text('Your inventory'), findsOneWidget);
expect(find.text('Open market'), findsOneWidget);
expect(find.text('COMING SOON'), findsOneWidget); // market is Block 2
// Redesign copy: tagline + the two destination subtitles.
expect(find.text('Share and grow local seeds'), findsOneWidget);
expect(find.text('Manage your seeds'), findsOneWidget);
expect(find.text('Browse and exchange'), findsOneWidget);
await tester.tap(find.byKey(const Key('home.inventory')));
await tester.pumpAndSettle();
expect(find.text('No seeds yet. Tap + to add your first.'), findsOneWidget);
await disposeTree(tester);
});
testWidgets('drawer opens and its Inventory item navigates', (tester) async {
LocaleSettings.setLocaleSync(AppLocale.en);
final db = newTestDatabase();
addTearDown(db.close);
await tester.pumpWidget(app(db));
await tester.pumpAndSettle();
await tester.tap(find.byIcon(Icons.menu)); // hamburger
await tester.pumpAndSettle();
// Social destinations are shown but disabled.
expect(find.text('Your profile'), findsOneWidget);
await tester.tap(find.text('Inventory')); // active drawer item
await tester.pumpAndSettle();
expect(find.text('No seeds yet. Tap + to add your first.'), findsOneWidget);
await disposeTree(tester);
});
testWidgets('inventory is a spoke: back arrow, no drawer, returns to home',
(tester) async {
LocaleSettings.setLocaleSync(AppLocale.en);
final db = newTestDatabase();
addTearDown(db.close);
await tester.pumpWidget(app(db));
await tester.pumpAndSettle();
// Push into inventory off the home hub.
await tester.tap(find.byKey(const Key('home.inventory')));
await tester.pumpAndSettle();
expect(find.text('No seeds yet. Tap + to add your first.'), findsOneWidget);
// The spoke shows a back arrow, not a hamburger — coherent with the market.
expect(find.byIcon(Icons.menu), findsNothing);
await tester.tap(find.byType(BackButton));
await tester.pumpAndSettle();
// Back on the home menu.
expect(find.text('Your inventory'), findsOneWidget);
expect(find.text('Open market'), findsOneWidget);
await disposeTree(tester);
});
testWidgets('drawer Settings opens the settings screen', (tester) async {
LocaleSettings.setLocaleSync(AppLocale.en);
final db = newTestDatabase();
addTearDown(db.close);
await tester.pumpWidget(app(db));
await tester.pumpAndSettle();
await tester.tap(find.byIcon(Icons.menu));
await tester.pumpAndSettle();
await tester.tap(find.text('Settings'));
await tester.pumpAndSettle();
expect(find.text('Language'), findsOneWidget);
expect(find.text('Español'), findsOneWidget);
await disposeTree(tester);
});
}