74 lines
2.3 KiB
Dart
74 lines
2.3 KiB
Dart
import 'package:alt_client/src/app/app.dart';
|
|
import 'package:alt_client/src/integrations/socket/socket_connection_controller.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
class FakeSocketConnectionController extends SocketConnectionController {
|
|
final SocketConnectionState initialState;
|
|
|
|
FakeSocketConnectionController(this.initialState);
|
|
|
|
@override
|
|
SocketConnectionState build() {
|
|
return initialState;
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('shows ALT dashboard shell with default disconnected socket state', (tester) async {
|
|
await tester.pumpWidget(const ProviderScope(child: AltClientApp()));
|
|
|
|
expect(find.text('ALT'), findsOneWidget);
|
|
expect(find.text('Backtests'), findsWidgets);
|
|
expect(find.text('Korea Daily Pipeline'), findsOneWidget);
|
|
expect(find.text('Disconnected'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows ALT dashboard with socket state Connecting', (tester) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
socketConnectionControllerProvider.overrideWith(
|
|
() => FakeSocketConnectionController(SocketConnectionState.connecting),
|
|
),
|
|
],
|
|
child: const AltClientApp(),
|
|
),
|
|
);
|
|
|
|
expect(find.text('Socket Contract'), findsOneWidget);
|
|
expect(find.text('Connecting'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows ALT dashboard with socket state Connected', (tester) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
socketConnectionControllerProvider.overrideWith(
|
|
() => FakeSocketConnectionController(SocketConnectionState.connected),
|
|
),
|
|
],
|
|
child: const AltClientApp(),
|
|
),
|
|
);
|
|
|
|
expect(find.text('Socket Contract'), findsOneWidget);
|
|
expect(find.text('Connected'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows ALT dashboard with socket state Error', (tester) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
socketConnectionControllerProvider.overrideWith(
|
|
() => FakeSocketConnectionController(SocketConnectionState.error),
|
|
),
|
|
],
|
|
child: const AltClientApp(),
|
|
),
|
|
);
|
|
|
|
expect(find.text('Socket Contract'), findsOneWidget);
|
|
expect(find.text('Error'), findsOneWidget);
|
|
});
|
|
}
|