Files
kaptan/ground-suite/test/widget_test.dart
T

97 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ground_suite/app/app.dart';
import 'package:ground_suite/app/app_shell.dart';
import 'package:ground_suite/shared/widgets/surfaces.dart';
void main() {
testWidgets('replay workspace keeps diagnostics distinct and read-only', (
tester,
) async {
await tester.pumpWidget(const ProviderScope(child: GroundSuiteApp()));
await tester.pumpAndSettle();
final app = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(app.themeMode, ThemeMode.system);
expect(app.theme?.brightness, Brightness.light);
expect(app.darkTheme?.brightness, Brightness.dark);
expect(find.byType(FrostedChrome), findsAtLeastNWidgets(1));
expect(find.text('OBSERVATION ONLY'), findsOneWidget);
expect(find.text('Replay fixture'), findsAtLeastNWidgets(1));
expect(find.text('LAST REPORTED HEARTBEAT'), findsOneWidget);
await tester.tap(find.byTooltip('Appearance: System default'));
await tester.pumpAndSettle();
await tester.tap(find.text('Dark'));
await tester.pumpAndSettle();
expect(
tester.widget<MaterialApp>(find.byType(MaterialApp)).themeMode,
ThemeMode.dark,
);
await tester.tap(find.byIcon(Icons.segment_outlined));
await tester.pumpAndSettle();
expect(find.text('Event timeline'), findsOneWidget);
await tester.tap(find.text('Errors 1'));
await tester.pumpAndSettle();
expect(
find.text('kaptan_drivers::lidar_lite_v3::error::Error::TransferFault'),
findsOneWidget,
);
await tester.tap(find.text('Shutdown reports 1'));
await tester.pumpAndSettle();
expect(find.text('Orderly shutdown report'), findsOneWidget);
});
testWidgets(
'compact desktop layout uses bottom navigation without overflow',
(tester) async {
await tester.binding.setSurfaceSize(const Size(480, 800));
addTearDown(() => tester.binding.setSurfaceSize(null));
await tester.pumpWidget(const ProviderScope(child: GroundSuiteApp()));
await tester.pumpAndSettle();
expect(find.byKey(const Key('compact-navigation')), findsOneWidget);
expect(tester.takeException(), isNull);
},
);
testWidgets('follows a dark system preference', (tester) async {
tester.binding.platformDispatcher.platformBrightnessTestValue =
Brightness.dark;
addTearDown(
tester.binding.platformDispatcher.clearPlatformBrightnessTestValue,
);
await tester.pumpWidget(const ProviderScope(child: GroundSuiteApp()));
await tester.pumpAndSettle();
final context = tester.element(find.byType(AppShell));
expect(Theme.of(context).brightness, Brightness.dark);
});
testWidgets('large desktop text uses the compact session strip', (
tester,
) async {
await tester.binding.setSurfaceSize(const Size(1280, 900));
tester.binding.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(() {
tester.binding.setSurfaceSize(null);
tester.binding.platformDispatcher.clearTextScaleFactorTestValue();
});
await tester.pumpWidget(const ProviderScope(child: GroundSuiteApp()));
await tester.pumpAndSettle();
expect(find.text('OBSERVATION ONLY'), findsOneWidget);
expect(find.text('Replay ended 12:00:06Z'), findsNothing);
expect(tester.takeException(), isNull);
});
}