import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/transport/pipelines_client.dart'; import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart'; import 'package:pipelines_app/features/terminal/terminal_shortcut_bubble.dart'; import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart'; import '../core/transport/pipelines_client_test.dart' show FakeChannel; import 'pipelines_app_test.dart' show pumpApp; /// On a phone the Chat tab has exactly one terminal entry: the bar's own /// Terminal action. The floating shortcut bubble must not appear over the /// chat list's header, nor beside an open chat's bar that already has it. Future _pumpAt(WidgetTester tester, String location) async { tester.view.physicalSize = const Size(430, 900); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); final channel = FakeChannel()..readyCompleter.complete(); final client = PipelinesClient(channelFactory: (_) => channel); final provider = PlatformRouteInformationProvider( initialRouteInformation: RouteInformation(uri: Uri.parse(location)), ); addTearDown(provider.dispose); await pumpApp(tester, channel: channel, client: client, provider: provider); await tester.pump(); await tester.pump(); } /// The bar's Terminal actions on screen (a [ChatBarAction] carrying the /// terminal toggle's label). Finder _barTerminal() => find.byWidgetPredicate( (w) => w is ChatBarAction && w.label == TerminalToggleButton.label, ); void main() { testWidgets('phone chat list: one terminal entry, no floating bubble', ( tester, ) async { await _pumpAt(tester, '/chat'); expect(find.byType(TerminalShortcutBubble), findsNothing); expect(_barTerminal(), findsOneWidget); expect(tester.takeException(), isNull); }); testWidgets('phone open chat: one terminal entry, no floating bubble', ( tester, ) async { await _pumpAt(tester, '/chat/abc123'); expect(find.byType(TerminalShortcutBubble), findsNothing); expect(_barTerminal(), findsOneWidget); expect(tester.takeException(), isNull); }); }