checkpoint: focus seed 1.0.1 localized dev switch
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:focus_seed/src/core/ambience.dart';
|
||||
|
||||
void main() {
|
||||
group('dayPhaseFor', () {
|
||||
test('uses the documented local time boundaries', () {
|
||||
expect(dayPhaseFor(DateTime(2026, 6, 11, 4, 59)), DayPhase.night);
|
||||
expect(dayPhaseFor(DateTime(2026, 6, 11, 5)), DayPhase.dawn);
|
||||
expect(dayPhaseFor(DateTime(2026, 6, 11, 10)), DayPhase.day);
|
||||
expect(dayPhaseFor(DateTime(2026, 6, 11, 17)), DayPhase.dusk);
|
||||
expect(dayPhaseFor(DateTime(2026, 6, 11, 21)), DayPhase.night);
|
||||
});
|
||||
|
||||
test('schedules the next boundary without background polling', () {
|
||||
expect(
|
||||
nextDayPhaseBoundary(DateTime(2026, 6, 11, 21, 15)),
|
||||
DateTime(2026, 6, 12, 5),
|
||||
);
|
||||
expect(
|
||||
nextDayPhaseBoundary(DateTime(2026, 6, 11, 8)),
|
||||
DateTime(2026, 6, 11, 10),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:focus_seed/src/models/app_state.dart';
|
||||
import 'package:focus_seed/src/models/focus_session.dart';
|
||||
import 'package:focus_seed/src/models/growth_stage.dart';
|
||||
import 'package:focus_seed/src/models/habit.dart';
|
||||
import 'package:focus_seed/src/models/mood.dart';
|
||||
import 'package:focus_seed/src/models/reflection_entry.dart';
|
||||
|
||||
void main() {
|
||||
const key = '2026-06-11';
|
||||
final date = DateTime(2026, 6, 11, 10);
|
||||
|
||||
test('growth stage follows real daily progress', () {
|
||||
const seed = AppState(
|
||||
anchor: '',
|
||||
anchorDateKey: key,
|
||||
habits: [],
|
||||
sessions: [],
|
||||
reflections: [],
|
||||
);
|
||||
expect(growthStageFor(seed, key), GrowthStage.seed);
|
||||
|
||||
final sprout = seed.copyWith(anchor: 'Ship one useful thing');
|
||||
expect(growthStageFor(sprout, key), GrowthStage.sprout);
|
||||
|
||||
final leaves = sprout.copyWith(
|
||||
sessions: [FocusSession(id: 'session-1', minutes: 25, completedAt: date)],
|
||||
habits: [
|
||||
Habit(
|
||||
id: 'habit-1',
|
||||
title: 'Plan one task',
|
||||
createdAt: date,
|
||||
completedDates: const {key},
|
||||
),
|
||||
],
|
||||
);
|
||||
expect(growthStageFor(leaves, key), GrowthStage.leaves);
|
||||
|
||||
final flower = leaves.copyWith(
|
||||
reflections: [
|
||||
ReflectionEntry(
|
||||
id: 'reflection-1',
|
||||
dateKey: key,
|
||||
note: 'A smaller scope made the work clearer.',
|
||||
mood: Mood.clear,
|
||||
createdAt: date,
|
||||
),
|
||||
],
|
||||
);
|
||||
expect(growthStageFor(flower, key), GrowthStage.flower);
|
||||
});
|
||||
|
||||
test('version one anchor data migrates to the current day', () {
|
||||
final state = AppState.fromJson(const {
|
||||
'version': 1,
|
||||
'anchor': 'Legacy intention',
|
||||
'habits': <Object>[],
|
||||
'sessions': <Object>[],
|
||||
'reflections': <Object>[],
|
||||
});
|
||||
|
||||
expect(state.anchorDateKey, isNotEmpty);
|
||||
expect(state.toJson()['version'], 2);
|
||||
});
|
||||
}
|
||||
+91
-3
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user