add traction import export
All checks were successful
Release / meta (push) Successful in 3s
Release / linux-build (push) Successful in 1m1s
Release / web-build (push) Successful in 1m22s
Release / android-build (push) Successful in 6m49s
Release / release-master (push) Successful in 5s
Release / release-dev (push) Successful in 8s
All checks were successful
Release / meta (push) Successful in 3s
Release / linux-build (push) Successful in 1m1s
Release / web-build (push) Successful in 1m22s
Release / android-build (push) Successful in 6m49s
Release / release-master (push) Successful in 5s
Release / release-dev (push) Successful in 8s
This commit is contained in:
83
test/pages/dashboard_page_test.dart
Normal file
83
test/pages/dashboard_page_test.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:mileograph_flutter/components/pages/dashboard.dart';
|
||||
|
||||
import '../helpers/fake_services.dart';
|
||||
import '../helpers/test_app.dart';
|
||||
import '../helpers/test_data.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUpAll(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
testWidgets('Dashboard renders stats and panels', (tester) async {
|
||||
final data = FakeDataService()
|
||||
..homepageStatsValue = TestData.homepageStats
|
||||
..tripsValue = TestData.tripSummaries
|
||||
..onThisDayValue = TestData.onThisDayLegs()
|
||||
..classClearanceProgressValue = TestData.classClearance
|
||||
..latestLocoChangesValue = TestData.latestLocoChanges
|
||||
..tractionValue = TestData.traction
|
||||
..currentYearMileageValue = 1200.5;
|
||||
final auth = FakeAuthService(api: FakeApiService());
|
||||
final router = GoRouter(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => const Dashboard(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
buildTestRouterApp(
|
||||
router: router,
|
||||
dataService: data,
|
||||
authService: auth,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Dashboard'), findsOneWidget);
|
||||
expect(find.textContaining('Welcome back, Alex Rider'), findsOneWidget);
|
||||
expect(find.text('Top traction'), findsOneWidget);
|
||||
expect(find.text('67 001'), findsOneWidget);
|
||||
expect(find.text('On this day'), findsOneWidget);
|
||||
expect(find.text('York → Durham'), findsOneWidget);
|
||||
expect(find.text('Latest Loco Changes'), findsOneWidget);
|
||||
expect(find.text('Status'), findsWidgets);
|
||||
expect(find.text('Active'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('Dashboard shows loading overlay without stats', (tester) async {
|
||||
final data = FakeDataService()
|
||||
..homepageStatsValue = null
|
||||
..isHomepageLoadingValue = true;
|
||||
final auth = FakeAuthService(api: FakeApiService());
|
||||
final router = GoRouter(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => const Dashboard(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
buildTestRouterApp(
|
||||
router: router,
|
||||
dataService: data,
|
||||
authService: auth,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Loading dashboard data...'), findsOneWidget);
|
||||
expect(find.byType(CircularProgressIndicator), findsWidgets);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user