ModernMemoires/test/ui_calender_screen_test.dart

38 lines
1.4 KiB
Dart
Raw Permalink Normal View History

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:moody/main.dart' as app;
import 'icon_finder.dart';
import 'package:moody/views/statistic/widget/calendar_widget.dart';
import 'package:moody/views/statistic/widget/streak_widget.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
SharedPreferences.setMockInitialValues({});
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('StatisticPage UI Test', (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
await tester.tap(find.text('skip'));
await tester.pumpAndSettle();
// Navigate to the StatisticPage if it's not the initial page
await tester.tap(findIconByAsset('icon-analyze.png'));
await tester.pumpAndSettle();
// Check for a CircularProgressIndicator while data is loading
expect(find.byType(StreakWidget), findsWidgets);
// Wait for FutureBuilder to complete and StreakWidget to be displayed
await tester.pumpAndSettle(const Duration(seconds: 2));
expect(find.byType(StreakWidget), findsOneWidget);
// Check for the presence of CalendarWidget
expect(find.byType(CalendarWidget), findsWidgets);
// Verify the text "browse your memories!" is present
expect(find.text("browse your memories!"), findsOneWidget);
});
}