checkpoint: focus seed 1.0.1 localized dev switch

This commit is contained in:
2026-06-11 23:35:49 +08:00
parent c51abdfb73
commit d06dc35ee6
72 changed files with 6155 additions and 1390 deletions
+91 -3
View File
@@ -1,16 +1,104 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:focus_seed/src/app/focus_seed_app.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
testWidgets('Focus Seed opens to the today screen', (tester) async {
setUp(() {
SharedPreferences.setMockInitialValues({});
});
test('locale policy defaults to English for release and Chinese for dev', () {
expect(focusSeedDefaultLocale(isRelease: true), const Locale('en'));
expect(focusSeedDefaultLocale(), const Locale('zh'));
});
testWidgets('Today guides the user from intention to focus', (tester) async {
await tester.pumpWidget(const FocusSeedApp(locale: Locale('en')));
await tester.pumpAndSettle();
expect(find.text('Focus Seed'), findsOneWidget);
expect(find.text("TODAY'S INTENTION"), findsOneWidget);
expect(find.text("Set today's intention"), findsOneWidget);
await tester.tap(find.text('Choose one outcome'));
await tester.pumpAndSettle();
await tester.enterText(
find.byType(TextField),
'Finish the launch checklist',
);
await tester.tap(find.text('Save'));
await tester.pumpAndSettle();
expect(find.text('Finish the launch checklist'), findsOneWidget);
expect(find.text('Start 25 min'), findsOneWidget);
});
testWidgets('bottom navigation exposes Journey and Me', (tester) async {
await tester.pumpWidget(const FocusSeedApp(locale: Locale('en')));
await tester.pumpAndSettle();
await tester.tap(find.text('Journey'));
await tester.pumpAndSettle();
expect(find.text("Today's journey"), findsOneWidget);
await tester.tap(find.text('Me'));
await tester.pumpAndSettle();
expect(find.text('Your space'), findsOneWidget);
expect(find.text('Appearance'), findsOneWidget);
});
testWidgets('Today remains usable at narrow width and 200 percent text', (
tester,
) async {
tester.view.physicalSize = const Size(320, 700);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(() {
tester.view.resetPhysicalSize();
tester.view.resetDevicePixelRatio();
tester.platformDispatcher.clearTextScaleFactorTestValue();
});
await tester.pumpWidget(const FocusSeedApp(locale: Locale('en')));
await tester.pumpAndSettle();
expect(find.text('Focus Seed'), findsOneWidget);
expect(find.byType(Scrollable), findsWidgets);
expect(tester.takeException(), isNull);
});
testWidgets('development default uses concise Chinese copy', (tester) async {
await tester.pumpWidget(const FocusSeedApp());
await tester.pumpAndSettle();
expect(find.text('Focus Seed'), findsOneWidget);
expect(find.text('Today anchor'), findsOneWidget);
expect(find.text('Start focus'), findsOneWidget);
expect(find.text('\u4eca\u65e5\u76ee\u6807'), findsOneWidget);
expect(find.text('\u8bbe\u7f6e\u4eca\u65e5\u76ee\u6807'), findsOneWidget);
await tester.scrollUntilVisible(
find.text('\u8ba1\u5212\u4e00\u4e2a\u660e\u786e\u4efb\u52a1'),
180,
);
expect(
find.text('\u8ba1\u5212\u4e00\u4e2a\u660e\u786e\u4efb\u52a1'),
findsOneWidget,
);
});
testWidgets('development language switch changes the active locale', (
tester,
) async {
await tester.pumpWidget(const FocusSeedApp());
await tester.pumpAndSettle();
await tester.tap(find.text('\u6211\u7684'));
await tester.pumpAndSettle();
expect(find.text('\u8bed\u8a00'), findsOneWidget);
await tester.tap(find.text('English'));
await tester.pumpAndSettle();
expect(find.text('Your space'), findsOneWidget);
expect(find.text('Language'), findsOneWidget);
});
}