Files
TPSchedule/mobile/test/widgets/startup_test.dart
T

64 lines
2.1 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:timezone/data/latest.dart' as tzdata;
import 'package:hepan_everyday/main.dart';
import 'package:hepan_everyday/app/app_controller.dart';
import 'package:hepan_everyday/app/hepan_app.dart';
import 'package:hepan_everyday/domain/app_snapshot.dart';
import 'package:hepan_everyday/domain/app_settings.dart';
import 'package:hepan_everyday/domain/semester.dart';
import 'package:hepan_everyday/widgets/glass_dock.dart';
import '../support/fakes.dart';
import '../domain/schedule_engine_test.dart' show course;
void main() {
setUpAll(tzdata.initializeTimeZones);
testWidgets(
'actual startup connects both tabs and reminder tap opens saved course',
(tester) async {
final selection = ValueNotifier<String?>(null);
final controller = AppController(
MemoryStore(
AppSnapshot(
courses: [course(last: 2)],
settings: AppSettings(
semester: Semester(
startDate: DateTime(2026, 9, 9),
totalWeeks: 5,
),
),
),
),
FakeNotifications(),
FakeCalendar(),
() => DateTime.utc(2026, 9, 8),
);
await controller.initialize();
await tester.pumpWidget(
buildApplication(controller, notificationSelection: selection),
);
await tester.pumpAndSettle();
expect(
find.descendant(
of: find.byType(GlassDock),
matching: find.bySemanticsLabel('课表'),
),
findsOneWidget,
);
expect(find.bySemanticsLabel('个人设置'), findsOneWidget);
await tester.tap(find.bySemanticsLabel('个人设置'));
await tester.pumpAndSettle();
selection.value = 'math/2026-09-09';
await tester.pumpAndSettle();
expect(find.text('知道了'), findsOneWidget);
expect(find.textContaining('08:30–10:05'), findsOneWidget);
await tester.tap(find.text('知道了'));
await tester.pumpAndSettle();
expect(find.byType(HepanApp), findsOneWidget);
controller.dispose();
selection.dispose();
},
);
}