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
115 lines
3.1 KiB
Dart
115 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
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/traction.dart';
|
|
|
|
import '../helpers/fake_services.dart';
|
|
import '../helpers/test_app.dart';
|
|
import '../helpers/test_data.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
setUpAll(() {
|
|
SharedPreferences.setMockInitialValues({});
|
|
});
|
|
|
|
testWidgets('Traction page shows list data', (tester) async {
|
|
final data = FakeDataService()
|
|
..tractionValue = TestData.traction
|
|
..locoClassesValue = ['67', '68']
|
|
..eventFieldsValue = TestData.eventFields;
|
|
final auth = FakeAuthService(api: FakeApiService(), isElevatedValue: true);
|
|
final router = GoRouter(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/',
|
|
builder: (context, state) => const TractionPage(),
|
|
),
|
|
],
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
buildTestRouterApp(
|
|
router: router,
|
|
dataService: data,
|
|
authService: auth,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Traction'), findsOneWidget);
|
|
expect(find.text('67'), findsWidgets);
|
|
expect(find.text('001'), findsWidgets);
|
|
});
|
|
|
|
testWidgets('Traction page shows export when class filter set', (tester) async {
|
|
final data = FakeDataService()
|
|
..tractionValue = TestData.traction
|
|
..locoClassesValue = ['67', '68']
|
|
..eventFieldsValue = TestData.eventFields;
|
|
final auth = FakeAuthService(api: FakeApiService(), isElevatedValue: true);
|
|
final router = GoRouter(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/',
|
|
builder: (context, state) => const TractionPage(),
|
|
),
|
|
],
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
buildTestRouterApp(
|
|
router: router,
|
|
dataService: data,
|
|
authService: auth,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.textContaining('Export'), findsNothing);
|
|
|
|
final classField = find.byWidgetPredicate(
|
|
(widget) =>
|
|
widget is TextField && widget.decoration?.labelText == 'Class',
|
|
);
|
|
await tester.enterText(classField, '67');
|
|
await tester.pump();
|
|
|
|
expect(find.text('Export 67'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Traction page shows admin import option', (tester) async {
|
|
final data = FakeDataService()
|
|
..tractionValue = TestData.traction
|
|
..locoClassesValue = ['67', '68']
|
|
..eventFieldsValue = TestData.eventFields
|
|
..pendingLocoCountValue = 2;
|
|
final auth = FakeAuthService(api: FakeApiService(), isElevatedValue: true);
|
|
final router = GoRouter(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/',
|
|
builder: (context, state) => const TractionPage(),
|
|
),
|
|
],
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
buildTestRouterApp(
|
|
router: router,
|
|
dataService: data,
|
|
authService: auth,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byType(PopupMenuButton));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Import traction'), findsOneWidget);
|
|
});
|
|
}
|