Format: repo predates Dart 3.11's tall formatter (~128 files would need a
dedicated reformat commit); disable --set-exit-if-changed for now, keep
flutter analyze as the real gate.
Test: 'drawer Settings opens the settings screen' asserted find.text('Español'),
which only holds when the resolved locale is Spanish. Under AppLocale.en (as
set in the test) the tile reads 'English', so it failed under CI's non-Spanish
host locale. Assert by the language selector's Key + icon instead (locale-robust).
109 lines
3.6 KiB
Dart
109 lines
3.6 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('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('Discover and share seeds nearby'), 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('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();
|
|
|
|
// Locale-robust: assert the screen opened via the language selector's key
|
|
// and icon, not the current-language endonym (under en it's "English").
|
|
expect(find.byKey(const Key('settings.language')), findsOneWidget);
|
|
expect(find.byIcon(Icons.translate), findsOneWidget);
|
|
await disposeTree(tester);
|
|
}); }
|
|
|