import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/settings/settings_controls.dart'; Widget _actions({required bool connected}) => MaterialApp( home: Scaffold( body: SettingsActions( primaryLabel: connected ? 'Disconnect' : 'Connect', secondaryLabel: 'Reconnect', primaryKey: const Key('primary'), secondaryKey: const Key('secondary'), primaryOutlined: connected, onPrimary: () {}, onSecondary: () {}, ), ), ); void main() { testWidgets('connected: Reconnect is tonal and leads, Disconnect outlined', ( tester, ) async { await tester.pumpWidget(_actions(connected: true)); final disconnect = find.byKey(const Key('primary')); final reconnect = find.byKey(const Key('secondary')); expect(tester.widget(disconnect), isA()); expect(tester.widget(reconnect), isA()); // Never the filled primary emphasis on the action that drops the link. expect(find.byType(OutlinedButton), findsOneWidget); expect( tester.getTopLeft(reconnect).dx, lessThan(tester.getTopLeft(disconnect).dx), ); }); testWidgets('disconnected: Connect is filled, Reconnect outlined', ( tester, ) async { await tester.pumpWidget(_actions(connected: false)); final connect = find.byKey(const Key('primary')); final reconnect = find.byKey(const Key('secondary')); expect(tester.widget(connect), isA()); expect(tester.widget(reconnect), isA()); expect( tester.getTopLeft(connect).dx, lessThan(tester.getTopLeft(reconnect).dx), ); }); }