Merge main into unexpected failure notifications
This commit is contained in:
@@ -6,6 +6,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_mode_control.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||
show segmentedMoreKey;
|
||||
|
||||
/// A chat destination gateway whose listing can change between reads, as it
|
||||
/// does when the server learns a row's mode after the row was first opened.
|
||||
@@ -101,13 +103,33 @@ Future<void> _pump(
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// The mode the drawn control names, or null when the bar has none. A
|
||||
/// A narrow phone bar draws only the shield, so read the control itself.
|
||||
String? _shown(WidgetTester tester) {
|
||||
if (_modeControl.evaluate().isEmpty) return null;
|
||||
/// The mode the drawn control names, or null when there is none. A phone bar
|
||||
/// keeps its selectors in the More menu's settings sheet, so the sheet is
|
||||
/// opened to read the control and then dismissed again.
|
||||
Future<String?> _shown(WidgetTester tester) async {
|
||||
if (_modeControl.evaluate().isNotEmpty) {
|
||||
final control = find.byType(ChatModeControl);
|
||||
expect(control, findsOneWidget);
|
||||
return tester.widget<ChatModeControl>(control).modeName;
|
||||
}
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
if (find.text('Chat settings').evaluate().isEmpty) {
|
||||
// No selectors for this chat: nothing to read; close the menu.
|
||||
await tester.tapAt(const Offset(5, 5));
|
||||
await tester.pumpAndSettle();
|
||||
return null;
|
||||
}
|
||||
await tester.tap(find.text('Chat settings'));
|
||||
await tester.pumpAndSettle();
|
||||
final control = find.byType(ChatModeControl);
|
||||
expect(control, findsOneWidget);
|
||||
return tester.widget<ChatModeControl>(control).modeName;
|
||||
final name = control.evaluate().isEmpty
|
||||
? null
|
||||
: tester.widget<ChatModeControl>(control).modeName;
|
||||
// Dismiss the sheet through its barrier, above the bar.
|
||||
await tester.tapAt(const Offset(5, 5));
|
||||
await tester.pumpAndSettle();
|
||||
return name;
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -123,7 +145,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_shown(tester), 'Ask for permission');
|
||||
expect(await _shown(tester), 'Ask for permission');
|
||||
},
|
||||
);
|
||||
|
||||
@@ -135,7 +157,7 @@ void main() {
|
||||
await _pump(tester, gateway, platform: platform);
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), isNull);
|
||||
expect(await _shown(tester), isNull);
|
||||
|
||||
// A reconnect re-reads the list; the open chat follows that row
|
||||
// without being closed and opened again.
|
||||
@@ -151,7 +173,7 @@ void main() {
|
||||
_app(gateway, platform: platform, syncToken: 1),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), 'Ask for permission');
|
||||
expect(await _shown(tester), 'Ask for permission');
|
||||
|
||||
// Another device chose Auto; the next re-read keeps the bar in sync.
|
||||
gateway.sessions = [
|
||||
@@ -161,7 +183,7 @@ void main() {
|
||||
_app(gateway, platform: platform, syncToken: 2),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), 'Auto');
|
||||
expect(await _shown(tester), 'Auto');
|
||||
},
|
||||
);
|
||||
|
||||
@@ -171,7 +193,7 @@ void main() {
|
||||
final gateway = _ModeScreenGateway();
|
||||
await _pump(tester, gateway, platform: platform, initialSessionId: 's');
|
||||
|
||||
expect(_shown(tester), 'Ask for permission');
|
||||
expect(await _shown(tester), 'Ask for permission');
|
||||
});
|
||||
|
||||
testWidgets('$style: switching chats shows each chat its own mode', (
|
||||
@@ -198,19 +220,19 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), 'Ask for permission');
|
||||
expect(await _shown(tester), 'Ask for permission');
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-row-t')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), 'Auto');
|
||||
expect(await _shown(tester), 'Auto');
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-row-u')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), isNull);
|
||||
expect(await _shown(tester), isNull);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), 'Ask for permission');
|
||||
expect(await _shown(tester), 'Ask for permission');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,7 +274,7 @@ void main() {
|
||||
await runNew(tester);
|
||||
|
||||
expect(find.text('New chat'), findsWidgets);
|
||||
expect(_shown(tester), 'Plan');
|
||||
expect(await _shown(tester), 'Plan');
|
||||
gateway.listGate!.complete();
|
||||
await tester.pumpAndSettle();
|
||||
},
|
||||
@@ -277,11 +299,11 @@ void main() {
|
||||
await runNew(tester);
|
||||
// The row is open on the /new reply, which names no mode.
|
||||
expect(find.text('New chat'), findsWidgets);
|
||||
expect(_shown(tester), isNull);
|
||||
expect(await _shown(tester), isNull);
|
||||
|
||||
gateway.listGate!.complete();
|
||||
await tester.pumpAndSettle();
|
||||
expect(_shown(tester), 'Plan');
|
||||
expect(await _shown(tester), 'Plan');
|
||||
},
|
||||
variant: _desktop,
|
||||
);
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import '../../native_back.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||
show segmentedMoreKey;
|
||||
|
||||
/// A chat destination gateway: one listed session whose harness offers models.
|
||||
class _ScreenGateway implements ApiGateway {
|
||||
@@ -77,6 +79,22 @@ Future<void> _pumpScreen(
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// A phone bar keeps the model in the More menu's settings sheet: opens it
|
||||
/// (a wide bar shows the control already).
|
||||
Future<void> _openSettings(WidgetTester tester) async {
|
||||
if (find.byKey(const Key('chat-model')).evaluate().isNotEmpty) return;
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Chat settings'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Dismisses that sheet through its barrier, above the bar.
|
||||
Future<void> _closeSettings(WidgetTester tester) async {
|
||||
await tester.tapAt(const Offset(5, 5));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('an accepted switch survives leaving and reopening the chat', (
|
||||
tester,
|
||||
@@ -86,6 +104,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
await _openSettings(tester);
|
||||
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-model')));
|
||||
@@ -93,6 +112,7 @@ void main() {
|
||||
await tester.tap(find.text('Model Beta'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
||||
await _closeSettings(tester);
|
||||
|
||||
await tester.tap(findNativeBack());
|
||||
await tester.pumpAndSettle();
|
||||
@@ -102,6 +122,7 @@ void main() {
|
||||
// still show the model the server accepted.
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
await _openSettings(tester);
|
||||
|
||||
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
||||
expect(find.byTooltip('Change model (currently model-a)'), findsNothing);
|
||||
@@ -133,6 +154,7 @@ void main() {
|
||||
// The deep link opened before any row was tapped: the list's own read
|
||||
// supplies the title and the recorded model, with no second list request.
|
||||
expect(find.text('Wire chat'), findsOneWidget);
|
||||
await _openSettings(tester);
|
||||
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||
expect(gateway.count('chat_sessions'), 1);
|
||||
|
||||
@@ -673,11 +673,18 @@ void main() {
|
||||
});
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
expect(find.byTooltip('2 tasks, 12 automations'), findsOneWidget);
|
||||
expect(find.byTooltip('Background tasks (2 running)'), findsOneWidget);
|
||||
final counter = find.byKey(const Key('chat-background-tasks-button'));
|
||||
// One '2' is the count inside the ring, one is the compact caption.
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(find.byKey(const Key('chat-background-tasks-count')))
|
||||
.data,
|
||||
'2',
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: counter, matching: find.text('2')),
|
||||
findsOneWidget,
|
||||
findsNWidgets(2),
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: counter, matching: find.text('12')),
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_reading_width.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||
show segmentedMoreKey;
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar_pieces.dart';
|
||||
|
||||
import 'chat_thread_fixtures.dart';
|
||||
@@ -149,7 +151,8 @@ void main() {
|
||||
final header = find.byKey(const Key('chat-thread-header'));
|
||||
expect(find.byKey(const Key('chat-mode')), findsNothing);
|
||||
// The round Back, the title pill and the actions pill, which always
|
||||
// carries the Files toggle, so it is never drawn empty.
|
||||
// carries the More menu, so it is never drawn empty. A narrow bar moves
|
||||
// the Files toggle into that menu.
|
||||
expect(
|
||||
find.descendant(of: header, matching: find.byType(SegmentedPill)),
|
||||
findsNWidgets(3),
|
||||
@@ -159,7 +162,12 @@ void main() {
|
||||
of: header,
|
||||
matching: find.bySemanticsIdentifier('chat-files-toggle'),
|
||||
),
|
||||
findsOneWidget,
|
||||
findsNothing,
|
||||
);
|
||||
// The bar's own disabled More beside the actions' one.
|
||||
expect(
|
||||
find.descendant(of: header, matching: find.byKey(segmentedMoreKey)),
|
||||
findsWidgets,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_models.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
|
||||
show segmentedMoreKey;
|
||||
|
||||
/// A chat thread gateway with scripted model catalog and switch replies.
|
||||
class _ModelGateway implements ApiGateway {
|
||||
@@ -91,6 +93,13 @@ Future<void> _openThread(
|
||||
}
|
||||
|
||||
Future<void> _openChooser(WidgetTester tester) async {
|
||||
// A narrow bar keeps the model in the More menu's settings sheet.
|
||||
if (find.byKey(const Key('chat-model')).evaluate().isEmpty) {
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Chat settings'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
await tester.tap(find.byKey(const Key('chat-model')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -6,19 +6,23 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_background_tasks.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_task_spinner.dart';
|
||||
|
||||
RotationTransition _rotation(WidgetTester tester) =>
|
||||
tester.widget<RotationTransition>(
|
||||
find.byKey(const Key('chat-background-tasks-spinner')),
|
||||
final _spinnerFinder = find.byKey(const Key('chat-background-tasks-spinner'));
|
||||
|
||||
CircularProgressIndicator _ring(WidgetTester tester) =>
|
||||
tester.widget<CircularProgressIndicator>(
|
||||
find.descendant(
|
||||
of: _spinnerFinder,
|
||||
matching: find.byType(CircularProgressIndicator),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _spinner(bool spinning) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ChatTaskSpinner(
|
||||
spinning: spinning,
|
||||
child: const Icon(Icons.layers_outlined, size: 16),
|
||||
),
|
||||
),
|
||||
);
|
||||
Widget _spinner(int running, {Brightness brightness = Brightness.light}) =>
|
||||
MaterialApp(
|
||||
theme: ThemeData(colorSchemeSeed: Colors.indigo, brightness: brightness),
|
||||
home: Scaffold(
|
||||
body: Center(child: ChatTaskSpinner(running: running)),
|
||||
),
|
||||
);
|
||||
|
||||
void _reducedMotion(bool reduced) =>
|
||||
TestWidgetsFlutterBinding.ensureInitialized()
|
||||
@@ -51,58 +55,99 @@ class _TasksGateway implements ApiGateway {
|
||||
void main() {
|
||||
tearDown(() => _reducedMotion(false));
|
||||
|
||||
testWidgets('turns once every period while spinning', (tester) async {
|
||||
testWidgets(
|
||||
'a running task shows an indeterminate primary ring with the count',
|
||||
(tester) async {
|
||||
_reducedMotion(false);
|
||||
await tester.pumpWidget(_spinner(2));
|
||||
final ring = _ring(tester);
|
||||
expect(ring.value, isNull);
|
||||
expect(ring.strokeWidth, 2);
|
||||
expect(
|
||||
ring.color,
|
||||
ThemeData(colorSchemeSeed: Colors.indigo).colorScheme.primary,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: _spinnerFinder, matching: find.text('2')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: _spinnerFinder,
|
||||
matching: find.byIcon(Icons.layers_outlined),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
// The ring keeps turning: time advances the animation.
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
expect(tester.binding.transientCallbackCount, greaterThan(0));
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('dark theme uses the dark primary for the ring', (tester) async {
|
||||
_reducedMotion(false);
|
||||
await tester.pumpWidget(_spinner(true));
|
||||
expect(_rotation(tester).turns.value, 0);
|
||||
await tester.pump(ChatTaskSpinner.period ~/ 4);
|
||||
expect(_rotation(tester).turns.value, closeTo(0.25, 0.01));
|
||||
// Past one full lap the turn starts again from the top.
|
||||
await tester.pump(
|
||||
ChatTaskSpinner.period ~/ 4 * 3 + const Duration(milliseconds: 100),
|
||||
await tester.pumpWidget(_spinner(1, brightness: Brightness.dark));
|
||||
expect(
|
||||
_ring(tester).color,
|
||||
ThemeData(
|
||||
colorSchemeSeed: Colors.indigo,
|
||||
brightness: Brightness.dark,
|
||||
).colorScheme.primary,
|
||||
);
|
||||
expect(_rotation(tester).turns.value, closeTo(0.04, 0.01));
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('stays still when not spinning, and stops when it stops', (
|
||||
testWidgets('no running task shows the static icon with no ring', (
|
||||
tester,
|
||||
) async {
|
||||
_reducedMotion(false);
|
||||
await tester.pumpWidget(_spinner(false));
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
expect(_rotation(tester).turns.value, 0);
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
|
||||
await tester.pumpWidget(_spinner(true));
|
||||
await tester.pump(const Duration(milliseconds: 625));
|
||||
expect(_rotation(tester).turns.value, greaterThan(0));
|
||||
|
||||
await tester.pumpWidget(_spinner(false));
|
||||
await tester.pump();
|
||||
expect(_rotation(tester).turns.value, 0);
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
expect(_rotation(tester).turns.value, 0);
|
||||
await tester.pumpWidget(_spinner(0));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: _spinnerFinder,
|
||||
matching: find.byType(CircularProgressIndicator),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: _spinnerFinder,
|
||||
matching: find.byIcon(Icons.layers_outlined),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('reduced motion keeps the icon static even while spinning', (
|
||||
testWidgets('every state keeps the same square size', (tester) async {
|
||||
_reducedMotion(false);
|
||||
for (final running in [0, 1, 12]) {
|
||||
await tester.pumpWidget(_spinner(running));
|
||||
expect(tester.getSize(_spinnerFinder), const Size(16, 16));
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('reduced motion holds one static ring segment while running', (
|
||||
tester,
|
||||
) async {
|
||||
_reducedMotion(true);
|
||||
await tester.pumpWidget(_spinner(true));
|
||||
await tester.pumpWidget(_spinner(3));
|
||||
expect(_ring(tester).value, ChatTaskSpinner.reducedSegment);
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
expect(_rotation(tester).turns.value, 0);
|
||||
expect(_ring(tester).value, ChatTaskSpinner.reducedSegment);
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('the tasks icon rotates only while a task runs', (tester) async {
|
||||
testWidgets('the composer button shows the count ring and its tooltip', (
|
||||
tester,
|
||||
) async {
|
||||
_reducedMotion(false);
|
||||
final gateway = _TasksGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.running = const [
|
||||
{'id': 'sh1', 'status': 'running', 'command': 'go test ./...'},
|
||||
{'id': 'sh2', 'status': 'running', 'command': 'make'},
|
||||
];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -111,12 +156,15 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
// The spinning icon repeats forever, so settle by pumping, never by waiting.
|
||||
// The ring repeats forever, so settle by pumping, never by waiting.
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.text('1 task'), findsOneWidget);
|
||||
final before = _rotation(tester).turns.value;
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
expect(_rotation(tester).turns.value, greaterThan(before));
|
||||
expect(find.text('2 tasks'), findsOneWidget);
|
||||
expect(find.byTooltip('Background tasks (2 running)'), findsOneWidget);
|
||||
expect(_ring(tester).value, isNull);
|
||||
expect(
|
||||
find.descendant(of: _spinnerFinder, matching: find.text('2')),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_bar_control_style.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_header.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/window_margins.dart';
|
||||
|
||||
import '../../../native_back.dart';
|
||||
import 'chat_thread_fixtures.dart';
|
||||
@@ -104,10 +107,9 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(
|
||||
find.byKey(const Key('chat-model-permission-island')),
|
||||
findsOneWidget,
|
||||
);
|
||||
// Narrow: the two selectors wait in the More menu's settings entry.
|
||||
expect(find.byKey(const Key('chat-model')), findsNothing);
|
||||
expect(find.byKey(const Key('chat-model-permission-island')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
@@ -136,11 +138,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final title = find.text(_title);
|
||||
final model = find.byKey(const Key('chat-model'));
|
||||
final more = find.byKey(segmentedMoreKey);
|
||||
final info = find.byKey(const Key('chat-info'));
|
||||
final back = find.byKey(const Key('chat-back'));
|
||||
expect(title, findsOneWidget);
|
||||
expect(model, findsOneWidget);
|
||||
// A narrow bar keeps its selectors in the More menu's settings entry.
|
||||
expect(more, findsWidgets);
|
||||
expect(find.byKey(const Key('chat-model')), findsNothing);
|
||||
expect(info, findsOneWidget);
|
||||
expect(back, findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -155,14 +159,11 @@ void main() {
|
||||
// selector island in the trailing row.
|
||||
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
||||
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
||||
expect((centerY(model) - centerY(info)).abs(), lessThan(16));
|
||||
expect((centerY(more.first) - centerY(info)).abs(), lessThan(16));
|
||||
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
||||
double right(Finder finder) => tester.getTopRight(finder).dx;
|
||||
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
||||
final modelSemantics = tester.getSemantics(model);
|
||||
expect(modelSemantics.label, contains('Change model'));
|
||||
expect(modelSemantics.label, contains('currently'));
|
||||
expect(find.byIcon(Icons.tune), findsNothing);
|
||||
expect(
|
||||
find.textContaining('an-extremely-long-recorded-model-id'),
|
||||
findsNothing,
|
||||
@@ -216,41 +217,31 @@ void main() {
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final selectors = find.byKey(const Key('chat-model-permission-island'));
|
||||
final actions = find.byKey(const Key('chat-actions-island'));
|
||||
expect(selectors, findsOneWidget);
|
||||
expect(actions, findsOneWidget);
|
||||
expect(
|
||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(),
|
||||
lessThan(16),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-next')), findsNothing);
|
||||
expect(find.text('Next chat'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
|
||||
if (width < 600) {
|
||||
if (width < chatHeaderNarrowWidth) {
|
||||
// The selectors wait in the More menu's settings entry.
|
||||
expect(find.byKey(const Key('chat-model')), findsNothing);
|
||||
expect(find.byKey(const Key('chat-mode')), findsNothing);
|
||||
expect(find.text('model-a'), findsNothing);
|
||||
expect(find.text('Ask before making changes'), findsNothing);
|
||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
||||
expect(find.byIcon(Icons.shield_outlined), findsOneWidget);
|
||||
expect(
|
||||
tester.getSemantics(find.byKey(const Key('chat-model'))).label,
|
||||
contains('Change model, currently'),
|
||||
);
|
||||
expect(
|
||||
tester.getSemantics(find.byKey(const Key('chat-mode'))).label,
|
||||
contains('Change mode, currently'),
|
||||
);
|
||||
} else {
|
||||
final selectors = find.byKey(const Key('chat-model-permission-island'));
|
||||
expect(selectors, findsOneWidget);
|
||||
expect(
|
||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(),
|
||||
lessThan(16),
|
||||
);
|
||||
}
|
||||
for (final key in ['chat-model', 'chat-mode']) {
|
||||
expect(
|
||||
tester.getSize(find.byKey(Key(key))).width,
|
||||
greaterThanOrEqualTo(48),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
|
||||
for (final key in ['chat-model', 'chat-mode']) {
|
||||
expect(
|
||||
tester.getSize(find.byKey(Key(key))).width,
|
||||
greaterThanOrEqualTo(48),
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(find.text('Sidebar action'), findsNothing);
|
||||
expect(find.text('Pane action'), findsNothing);
|
||||
@@ -354,4 +345,145 @@ void main() {
|
||||
expect(chatBarButtonPadding.left, 12);
|
||||
expect(chatBarButtonPadding.right, 12);
|
||||
});
|
||||
|
||||
group('narrow title priority at 430px', () {
|
||||
const width = 430.0;
|
||||
const longTitle =
|
||||
'A conversation title long enough to need an ellipsis at 430px';
|
||||
|
||||
void useWidth(WidgetTester tester) {
|
||||
tester.view.physicalSize = const Size(width, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
}
|
||||
|
||||
Widget bar({
|
||||
required String title,
|
||||
bool showTitle = true,
|
||||
Widget? identity,
|
||||
}) => _host(
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: ChatThreadHeader(
|
||||
title: title,
|
||||
folder: 'demo',
|
||||
onInfo: () {},
|
||||
showTitle: showTitle,
|
||||
showBack: true,
|
||||
onBack: () {},
|
||||
identity: identity,
|
||||
controls: const [
|
||||
SizedBox(key: Key('header-control-1'), width: 48, height: 48),
|
||||
SizedBox(key: Key('header-control-2'), width: 48, height: 48),
|
||||
],
|
||||
actions: [
|
||||
ChatBarAction(
|
||||
label: 'Files',
|
||||
onPressed: () {},
|
||||
materialIcon: Icons.folder_outlined,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// The bar's own width: the window less its phone side margins.
|
||||
double barWidth() => width - 2 * WindowMargins.narrowSide;
|
||||
|
||||
bool truncated(WidgetTester tester, String text) {
|
||||
final render = tester.renderObject<RenderParagraph>(find.text(text));
|
||||
final painter = TextPainter(
|
||||
text: render.text,
|
||||
textDirection: TextDirection.ltr,
|
||||
textScaler: render.textScaler,
|
||||
maxLines: 1,
|
||||
)..layout();
|
||||
final full = painter.width;
|
||||
painter.dispose();
|
||||
return full > render.size.width + 1;
|
||||
}
|
||||
|
||||
testWidgets('a short title reads whole and the selectors collapse', (
|
||||
tester,
|
||||
) async {
|
||||
useWidth(tester);
|
||||
await tester.pumpWidget(bar(title: 'Fixture chat 1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(truncated(tester, 'Fixture chat 1'), isFalse);
|
||||
expect(find.byKey(const Key('header-control-1')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('a long title ellipsizes and keeps 60% of the bar', (
|
||||
tester,
|
||||
) async {
|
||||
useWidth(tester);
|
||||
await tester.pumpWidget(bar(title: longTitle));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(truncated(tester, longTitle), isTrue);
|
||||
final info = tester.getSize(find.byKey(const Key('chat-info')));
|
||||
expect(info.width, greaterThanOrEqualTo(barWidth() * 0.6 - 1));
|
||||
});
|
||||
|
||||
testWidgets('the harness mark keeps its size beside the title', (
|
||||
tester,
|
||||
) async {
|
||||
useWidth(tester);
|
||||
await tester.pumpWidget(
|
||||
bar(
|
||||
title: 'Fixture chat 1',
|
||||
identity: ChatSessionAvatar(
|
||||
session: <String, dynamic>{'id': 's', 'backend': 'opencode'},
|
||||
selected: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
final mark = tester.getSize(find.byType(ImageIcon));
|
||||
expect(mark.width, greaterThanOrEqualTo(20));
|
||||
expect(mark.height, greaterThanOrEqualTo(20));
|
||||
});
|
||||
|
||||
testWidgets('the More menu opens the controls in a sheet', (tester) async {
|
||||
useWidth(tester);
|
||||
await tester.pumpWidget(bar(title: 'Fixture chat 1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('header-control-1')), findsNothing);
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Chat settings'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('header-control-1')), findsOneWidget);
|
||||
expect(find.byKey(const Key('header-control-2')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('a narrow bar moves Files into its More menu', (tester) async {
|
||||
useWidth(tester);
|
||||
await tester.pumpWidget(bar(title: 'Fixture chat 1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byTooltip('Files'), findsNothing);
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Files'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('a floating window bar shows no title pill', (tester) async {
|
||||
useWidth(tester);
|
||||
await tester.pumpWidget(bar(title: 'Fixture chat 1', showTitle: false));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Fixture chat 1'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-info')), findsNothing);
|
||||
expect(find.byKey(const Key('chat-back')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-actions-island')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_pane_dim.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
|
||||
Widget host(
|
||||
ChatWorkspaceController controller, {
|
||||
bool disableAnimations = false,
|
||||
}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
width: 1200,
|
||||
height: 900,
|
||||
child: Builder(
|
||||
builder: (context) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(disableAnimations: disableAnimations),
|
||||
child: ChatWorkspace(
|
||||
controller: controller,
|
||||
paneBuilder: (_, pane, active) =>
|
||||
TextField(key: ValueKey('input-${pane.sessionId}')),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/// The dim overlay wrapping the pane that shows [session].
|
||||
Finder dimOf(String session) => find.ancestor(
|
||||
of: find.byKey(ValueKey('input-$session')),
|
||||
matching: find.byType(ChatPaneDim),
|
||||
);
|
||||
|
||||
/// The alpha of the scrim over [session]'s pane: zero when the pane is clear.
|
||||
double scrimAlpha(WidgetTester tester, String session) {
|
||||
final scrim = find.descendant(
|
||||
of: dimOf(session),
|
||||
matching: find.byKey(const ValueKey('chat-pane-dim-scrim')),
|
||||
);
|
||||
// AnimatedContainer builds a Container whose BoxDecoration holds the colour.
|
||||
final container = tester.widget<Container>(
|
||||
find.descendant(of: scrim, matching: find.byType(Container)),
|
||||
);
|
||||
final decoration = container.decoration as BoxDecoration?;
|
||||
return (decoration?.color ?? container.color ?? const Color(0x00000000)).a;
|
||||
}
|
||||
|
||||
void usePhoneSizedView(WidgetTester tester) {
|
||||
tester.view.physicalSize = const Size(1200, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('two panes: the inactive pane is dimmed and the active is not', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = ChatWorkspaceController()
|
||||
..open('one')
|
||||
..splitActive('two', ChatSplitAxis.horizontal);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(controller.activePane?.sessionId, 'two');
|
||||
expect(scrimAlpha(tester, 'one'), closeTo(chatPaneDimOpacity, 0.001));
|
||||
expect(scrimAlpha(tester, 'two'), 0);
|
||||
});
|
||||
|
||||
testWidgets('three panes: every inactive pane is dimmed, the active is not', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = ChatWorkspaceController()
|
||||
..open('one')
|
||||
..splitActive('two', ChatSplitAxis.horizontal)
|
||||
..splitActive('three', ChatSplitAxis.horizontal);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(controller.activePane?.sessionId, 'three');
|
||||
expect(scrimAlpha(tester, 'one'), closeTo(chatPaneDimOpacity, 0.001));
|
||||
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
|
||||
expect(scrimAlpha(tester, 'three'), 0);
|
||||
});
|
||||
|
||||
testWidgets('a single pane is never dimmed', (tester) async {
|
||||
final controller = ChatWorkspaceController()..open('one');
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(scrimAlpha(tester, 'one'), 0);
|
||||
});
|
||||
|
||||
testWidgets('tapping an inactive pane activates it and focuses its input', (
|
||||
tester,
|
||||
) async {
|
||||
usePhoneSizedView(tester);
|
||||
final controller = ChatWorkspaceController()
|
||||
..open('one')
|
||||
..splitActive('two', ChatSplitAxis.horizontal);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
final first = controller.panes.first.id;
|
||||
expect(controller.activePaneId, isNot(first));
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('input-one')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(controller.activePaneId, first);
|
||||
expect(scrimAlpha(tester, 'one'), 0);
|
||||
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
|
||||
final editable = tester.widget<EditableText>(
|
||||
find.descendant(
|
||||
of: find.byKey(const ValueKey('input-one')),
|
||||
matching: find.byType(EditableText),
|
||||
),
|
||||
);
|
||||
expect(editable.focusNode.hasFocus, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('a tap on bare space in an inactive pane activates it', (
|
||||
tester,
|
||||
) async {
|
||||
usePhoneSizedView(tester);
|
||||
final controller = ChatWorkspaceController()
|
||||
..open('one')
|
||||
..splitActive('two', ChatSplitAxis.horizontal);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
final first = controller.panes.first.id;
|
||||
|
||||
final corner = tester.getTopLeft(dimOf('one')) + const Offset(2, 2);
|
||||
await tester.tapAt(corner);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(controller.activePaneId, first);
|
||||
});
|
||||
|
||||
testWidgets('reduced motion switches the dim at once, without a fade', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = ChatWorkspaceController()
|
||||
..open('one')
|
||||
..splitActive('two', ChatSplitAxis.horizontal);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(host(controller, disableAnimations: true));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final scrim = find.byKey(const ValueKey('chat-pane-dim-scrim')).first;
|
||||
expect(tester.widget<AnimatedContainer>(scrim).duration, Duration.zero);
|
||||
|
||||
controller.activate(controller.panes.first.id);
|
||||
await tester.pump();
|
||||
expect(scrimAlpha(tester, 'one'), 0);
|
||||
expect(scrimAlpha(tester, 'two'), closeTo(chatPaneDimOpacity, 0.001));
|
||||
});
|
||||
|
||||
testWidgets('motion is on by default: the dim fades over the standard time', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = ChatWorkspaceController()
|
||||
..open('one')
|
||||
..splitActive('two', ChatSplitAxis.horizontal);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final scrim = find.byKey(const ValueKey('chat-pane-dim-scrim')).first;
|
||||
expect(
|
||||
tester.widget<AnimatedContainer>(scrim).duration,
|
||||
Motion.standard,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -604,4 +604,28 @@ void main() {
|
||||
expect(find.text('Nightly review'), findsWidgets);
|
||||
expect(launches, 0);
|
||||
});
|
||||
|
||||
testWidgets('the labelled Run button on the detail starts the flow', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final navigated = <int>[];
|
||||
final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(79));
|
||||
await pumpScreen(tester, gateway, navigated);
|
||||
await openDetail(tester);
|
||||
|
||||
final run = find.byKey(runPipelineActionKey);
|
||||
expect(
|
||||
find.descendant(of: run, matching: find.text(runPipelineActionLabel)),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(run);
|
||||
await tester.pumpAndSettle();
|
||||
await fillFields(tester);
|
||||
await tester.tap(find.byKey(runPipelineConfirmKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(gateway.callsOf('run_pipeline'), hasLength(1));
|
||||
expect(navigated, [79]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/screen.dart';
|
||||
|
||||
import '../../pipelines/fixtures.dart';
|
||||
|
||||
JsonMap _acceptedRun(int id) => {
|
||||
'type': 'run',
|
||||
'run_detail': {'id': id, 'status': 'running', 'title': 'Run $id'},
|
||||
};
|
||||
|
||||
/// Pipelines for the picker: the fixture's three active ones plus one archived
|
||||
/// pipeline, which must never be offered for a new run.
|
||||
List<Map<String, dynamic>> _pipelines(PipelineFixture fixture) => [
|
||||
...fixture.summaries,
|
||||
{
|
||||
...pipelineSummary(id: 4, name: 'Retired build'),
|
||||
'archived_at': '2026-10-01T10:00:00',
|
||||
},
|
||||
];
|
||||
|
||||
FakeGateway _gateway(PipelineFixture fixture, {required int launchedRunId}) =>
|
||||
FakeGateway(
|
||||
(type, fields) => switch (type) {
|
||||
'list_runs' => runListReply(fixture.runs),
|
||||
'list_pipelines' => pipelineListReply(_pipelines(fixture)),
|
||||
'get_pipeline' => pipelineDetailReply(
|
||||
fixture.detailFor(
|
||||
fields['pipeline_id'] as int,
|
||||
fields['version'] as int,
|
||||
)!,
|
||||
),
|
||||
'chat_directories' => {
|
||||
'type': 'chat_directories',
|
||||
'chat_directories': ['/work/recent'],
|
||||
},
|
||||
'run_pipeline' => _acceptedRun(launchedRunId),
|
||||
_ => errorReply('unexpected $type'),
|
||||
},
|
||||
);
|
||||
|
||||
/// Pumps the Runs screen. With [withNavigationBar] the screen sits in a
|
||||
/// scaffold with `extendBody` and a bottom NavigationBar, as the shell does on
|
||||
/// a phone, so the body scrolls under the bar.
|
||||
Future<void> _pumpRuns(
|
||||
WidgetTester tester,
|
||||
FakeGateway gateway, {
|
||||
required Size size,
|
||||
required List<int> selected,
|
||||
bool withNavigationBar = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final screen = RunsScreen(gateway: gateway, onRunSelected: selected.add);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: withNavigationBar
|
||||
? Scaffold(
|
||||
extendBody: true,
|
||||
body: screen,
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: 0,
|
||||
onDestinationSelected: (_) {},
|
||||
destinations: const [
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.play_arrow),
|
||||
label: 'Runs',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.settings),
|
||||
label: 'Settings',
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Scaffold(body: screen),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
for (final size in const [Size(430, 900), Size(1100, 900)]) {
|
||||
testWidgets('New run is labelled on the Runs list at ${size.width} wide', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
|
||||
await _pumpRuns(tester, gateway, size: size, selected: []);
|
||||
|
||||
final button = find.byKey(const Key('runs-new-run'));
|
||||
expect(button, findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: button, matching: find.text('New run')),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('New run clears the bottom bar and opens the picker on a phone', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
|
||||
await _pumpRuns(
|
||||
tester,
|
||||
gateway,
|
||||
size: const Size(430, 900),
|
||||
selected: [],
|
||||
withNavigationBar: true,
|
||||
);
|
||||
|
||||
final button = find.byKey(const Key('runs-new-run'));
|
||||
final bar = find.byType(NavigationBar);
|
||||
expect(button, findsOneWidget);
|
||||
// The button sits wholly above the bar, not beneath it.
|
||||
expect(
|
||||
tester.getRect(button).bottom,
|
||||
lessThanOrEqualTo(tester.getRect(bar).top),
|
||||
);
|
||||
|
||||
// A tap at the button reaches the button, not the bar behind it.
|
||||
await tester.tap(button);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('new-run-search')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'New run picks an active pipeline, starts it and opens the new run',
|
||||
(tester) async {
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = _gateway(fixture, launchedRunId: 91);
|
||||
final selected = <int>[];
|
||||
await _pumpRuns(
|
||||
tester,
|
||||
gateway,
|
||||
size: const Size(1100, 900),
|
||||
selected: selected,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('runs-new-run')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The picker lists active pipelines only; the archived one is withheld.
|
||||
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('new-run-pipeline-4')), findsNothing);
|
||||
|
||||
// Search narrows the list by name.
|
||||
await tester.enterText(find.byKey(const Key('new-run-search')), 'beta');
|
||||
await tester.pump();
|
||||
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('new-run-pipeline-2')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The chosen pipeline's latest version is read, then the start dialog
|
||||
// opens for it: the same flow as the pipeline's own Run action.
|
||||
expect(gateway.callsOf('get_pipeline').single.fields, {
|
||||
'pipeline_id': 2,
|
||||
'version': 0,
|
||||
});
|
||||
await tester.enterText(
|
||||
find.byKey(runPipelinePromptKey),
|
||||
'Ship the beta.',
|
||||
);
|
||||
await tester.enterText(find.byKey(runPipelineWorkspaceKey), '/work/beta');
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(runPipelineConfirmKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final launch = gateway.callsOf('run_pipeline').single.fields;
|
||||
expect(launch['pipeline_id'], 2);
|
||||
expect(launch['version'], 1);
|
||||
expect(selected, [91]);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('dismissing the picker starts nothing', (tester) async {
|
||||
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
|
||||
final selected = <int>[];
|
||||
await _pumpRuns(
|
||||
tester,
|
||||
gateway,
|
||||
size: const Size(430, 900),
|
||||
selected: selected,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('runs-new-run')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('new-run-search')), findsNothing);
|
||||
expect(gateway.callsOf('get_pipeline'), isEmpty);
|
||||
expect(gateway.callsOf('run_pipeline'), isEmpty);
|
||||
expect(selected, isEmpty);
|
||||
});
|
||||
}
|
||||
@@ -4,6 +4,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/screen.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||
|
||||
/// The list's row titles only: the New run button carries the same words.
|
||||
Finder _rowTitled(String title) =>
|
||||
find.descendant(of: find.byType(RunsList), matching: find.text(title));
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final listRequests = <Completer<JsonMap>>[];
|
||||
@@ -53,7 +58,7 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(gateway.listRequests, hasLength(2));
|
||||
// No row is invented while the fresh read is outstanding.
|
||||
expect(find.text('New run'), findsNothing);
|
||||
expect(_rowTitled('New run'), findsNothing);
|
||||
gateway.listRequests[1].complete({
|
||||
'runs': [
|
||||
{'id': 2, 'title': 'New run', 'status': 'running'},
|
||||
@@ -63,7 +68,7 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('New run'), findsOneWidget);
|
||||
expect(_rowTitled('New run'), findsOneWidget);
|
||||
expect(gateway.listRequests, hasLength(2));
|
||||
expect(gateway.detailRequests, isEmpty);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/navigation_rail.dart';
|
||||
|
||||
/// The rail's surface runs from the window's top edge. The system's top inset
|
||||
/// is kept clear for the rail's content, but it is painted with the rail's
|
||||
/// surface, so no unpainted strip (white in the app's canvas) shows above it.
|
||||
void main() {
|
||||
for (final brightness in Brightness.values) {
|
||||
testWidgets('the rail top under a system inset is the rail surface '
|
||||
'(${brightness.name})', (tester) async {
|
||||
tester.view.physicalSize = const Size(1000, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final theme = ThemeData(
|
||||
colorSchemeSeed: Colors.purple,
|
||||
brightness: brightness,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: theme,
|
||||
home: Scaffold(
|
||||
body: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ShellNavigationRail(
|
||||
selected: AppDestination.pipelines,
|
||||
icon: (destination) =>
|
||||
Icon(destinationDetails(destination).icon),
|
||||
onSelected: (_) {},
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final surface = theme.colorScheme.surface;
|
||||
final cover = find.byKey(const ValueKey('shell.navigation-rail.surface'));
|
||||
final rail = find.byKey(const ValueKey('shell.navigation-rail'));
|
||||
|
||||
// The cover and the rail's own background are the same surface colour.
|
||||
expect(tester.widget<ColoredBox>(cover).color, surface);
|
||||
expect(tester.widget<NavigationRail>(rail).backgroundColor, surface);
|
||||
|
||||
// The rail's content starts below the inset, and the cover starts at the
|
||||
// window's top edge, so the inset strip is covered.
|
||||
final coverRect = tester.getRect(cover);
|
||||
final railRect = tester.getRect(rail);
|
||||
expect(coverRect.top, 0);
|
||||
expect(railRect.top, 8);
|
||||
expect(
|
||||
coverRect.contains(Offset(railRect.center.dx, 2)),
|
||||
isTrue,
|
||||
reason: 'the strip above the rail content is painted',
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_manager.dart';
|
||||
|
||||
import 'windows/window_test_harness.dart';
|
||||
|
||||
/// The shell bar's trailing action island is drawn only with actions. The
|
||||
/// Windows button is one of them only while a floating window is open, so
|
||||
/// Search and Settings (and every other route) show no empty pill at any size.
|
||||
void main() {
|
||||
Future<void> pumpShell(
|
||||
WidgetTester tester, {
|
||||
required AppDestination destination,
|
||||
required double width,
|
||||
WindowManager? windowManager,
|
||||
}) async {
|
||||
tester.view.physicalSize = Size(width, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destination: destination,
|
||||
windowManager: windowManager,
|
||||
destinationBodies: {
|
||||
for (final value in AppDestination.values)
|
||||
value: (_) => Text('${value.name} body'),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
final actionIsland = find.byKey(const ValueKey('segmented.actions'));
|
||||
|
||||
for (final width in [1000.0, 430.0]) {
|
||||
for (final destination in [
|
||||
AppDestination.search,
|
||||
AppDestination.settings,
|
||||
AppDestination.pipelines,
|
||||
]) {
|
||||
testWidgets(
|
||||
'${destination.name} at width ${width.toInt()} draws no empty action '
|
||||
'island with no floating window',
|
||||
(tester) async {
|
||||
await pumpShell(
|
||||
tester,
|
||||
destination: destination,
|
||||
width: width,
|
||||
windowManager: probeManager(),
|
||||
);
|
||||
expect(actionIsland, findsNothing);
|
||||
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
testWidgets('a shell without a window manager draws no action island', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpShell(tester, destination: AppDestination.settings, width: 1000);
|
||||
expect(actionIsland, findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the Windows button is the island only while a window is open', (
|
||||
tester,
|
||||
) async {
|
||||
final manager = probeManager();
|
||||
await pumpShell(
|
||||
tester,
|
||||
destination: AppDestination.search,
|
||||
width: 1000,
|
||||
windowManager: manager,
|
||||
);
|
||||
expect(actionIsland, findsNothing);
|
||||
|
||||
final entry = manager.open('probe', 'a');
|
||||
await tester.pumpAndSettle();
|
||||
expect(actionIsland, findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: actionIsland,
|
||||
matching: find.byKey(const ValueKey('shell.windows')),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
manager.close(entry.id);
|
||||
await tester.pumpAndSettle();
|
||||
expect(actionIsland, findsNothing);
|
||||
expect(find.byKey(const ValueKey('shell.windows')), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user