a1c4c1c402
Settings leaves the tab bar (Pipelines, Runs, Chat, Search) and opens as a page from a gear in the Pipelines bar, keeping /settings, its keys and a Back to Pipelines (also the system Back). Every floating tab bar shows icons only, named for assistive technology. On wide windows the shell's tab bar stays at the bottom right; a split detail learns its height plus a 12px gap, so its tabs or the chat composer float above it, and pages the detail opens (the stage page) stay in its pane through its own navigator.
275 lines
11 KiB
Dart
275 lines
11 KiB
Dart
import 'dart:ui' show Tristate;
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:pipelines_app/features/chat/screen.dart';
|
|
import 'package:pipelines_app/features/pipelines/screen.dart';
|
|
import 'package:pipelines_app/features/runs/screen.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
|
|
|
import '../features/pipelines/fixtures.dart';
|
|
|
|
void main() {
|
|
for (final cupertino in [false, true]) {
|
|
for (final brightness in Brightness.values) {
|
|
for (final width in [640.0, 840.0, 1280.0]) {
|
|
for (final scale in [1.0, 2.0]) {
|
|
testWidgets('shared body-priority panes and selected rows: $cupertino '
|
|
'$brightness at $width @${scale}x', (tester) async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
tester.view.physicalSize = Size(width, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
tester.platformDispatcher.textScaleFactorTestValue = scale;
|
|
addTearDown(
|
|
tester.platformDispatcher.clearTextScaleFactorTestValue,
|
|
);
|
|
final fixture = PipelineFixture();
|
|
final gateway = FakeGateway(
|
|
(type, fields) => switch (type) {
|
|
'list_pipelines' => pipelineListReply(fixture.summaries),
|
|
'get_pipeline' => pipelineDetailReply(
|
|
fixture.detailFor(
|
|
fields['pipeline_id'] as int,
|
|
fields['version'] as int,
|
|
)!,
|
|
),
|
|
'list_runs' => {
|
|
'runs': [
|
|
for (final id in [1, 2])
|
|
{
|
|
'id': id,
|
|
'title': 'Run item $id',
|
|
'status': 'succeeded',
|
|
},
|
|
],
|
|
},
|
|
'get_run' => {
|
|
'run_detail': {
|
|
'id': fields['run_id'],
|
|
'title': 'Run item ${fields['run_id']}',
|
|
'status': 'succeeded',
|
|
'input': {'prompt': 'Recorded input'},
|
|
},
|
|
},
|
|
'chat_sessions' => {
|
|
'chat_sessions': [
|
|
{
|
|
'id': 'a',
|
|
'title': 'Chat item a',
|
|
'backend': 'claude',
|
|
'model': 'claude-opus',
|
|
'mode': 'auto',
|
|
'mode_name': 'Auto',
|
|
},
|
|
{
|
|
'id': 'b',
|
|
'title': 'Chat item b',
|
|
'backend': 'claude',
|
|
'model': 'claude-opus',
|
|
'mode': 'auto',
|
|
'mode_name': 'Auto',
|
|
},
|
|
],
|
|
},
|
|
'chat_messages' => {
|
|
'chat_history': {'messages': []},
|
|
},
|
|
_ => {},
|
|
},
|
|
);
|
|
final shell = AdaptiveShell(
|
|
cupertino: cupertino,
|
|
destinationBodies: {
|
|
AppDestination.pipelines: (_) =>
|
|
PipelinesScreen(gateway: gateway, embedded: true),
|
|
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
|
|
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
|
},
|
|
);
|
|
await tester.pumpWidget(
|
|
cupertino
|
|
? CupertinoApp(
|
|
theme: CupertinoThemeData(brightness: brightness),
|
|
home: shell,
|
|
)
|
|
: MaterialApp(
|
|
theme: brightness == Brightness.dark
|
|
? appDarkTheme()
|
|
: appLightTheme(),
|
|
home: shell,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
final paneWidths = <double>[];
|
|
final bodyWidths = <double>[];
|
|
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
|
|
if (destination != 'Pipelines') {
|
|
await tester.tap(
|
|
find.byKey(
|
|
ValueKey('shell.destination.${destination.toLowerCase()}'),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
tester.takeException(),
|
|
isNull,
|
|
reason: '$destination list',
|
|
);
|
|
}
|
|
final list = find.byKey(const ValueKey('list-detail-list'));
|
|
final detail = find.byKey(const ValueKey('list-detail-body'));
|
|
expect(list, findsOneWidget);
|
|
expect(detail, findsOneWidget);
|
|
final before = tester.getSize(list).width;
|
|
final bodyBefore = tester.getSize(detail).width;
|
|
paneWidths.add(before);
|
|
bodyWidths.add(bodyBefore);
|
|
expect(bodyBefore, greaterThanOrEqualTo(width * 0.5));
|
|
expect(bodyBefore, lessThanOrEqualTo(width * 0.6));
|
|
expect(bodyBefore, greaterThan(before));
|
|
final rowKeys = switch (destination) {
|
|
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
|
|
'Runs' => ['run-row-1', 'run-row-2'],
|
|
_ => ['chat-row-a', 'chat-row-b'],
|
|
};
|
|
for (final key in rowKeys) {
|
|
final target = find.byKey(ValueKey(key));
|
|
// In a narrow Cupertino list the row center can be a star/menu
|
|
// control. Open the chat through its title, not a trailing action.
|
|
final opener = destination == 'Chat'
|
|
? find.descendant(
|
|
of: target,
|
|
matching: find.text('Chat item ${key.split('-').last}'),
|
|
)
|
|
: target;
|
|
await tester.ensureVisible(opener);
|
|
await tester.tap(opener);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
tester.takeException(),
|
|
isNull,
|
|
reason: '$destination after opening $key',
|
|
);
|
|
expect(tester.getSize(list).width, closeTo(before, 0.01));
|
|
expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01));
|
|
expect(
|
|
tester
|
|
.state<NavigatorState>(find.byType(Navigator).first)
|
|
.canPop(),
|
|
isFalse,
|
|
);
|
|
for (final rowKey in rowKeys) {
|
|
final row = find.byKey(ValueKey(rowKey));
|
|
expect(
|
|
row,
|
|
findsOneWidget,
|
|
reason: 'the list must remain visible',
|
|
);
|
|
final selected = rowKey == key;
|
|
expect(
|
|
tester.getSemantics(row).flagsCollection.isSelected ==
|
|
Tristate.isTrue,
|
|
selected,
|
|
reason: '$destination: $rowKey after opening $key',
|
|
);
|
|
// Every list uses the shared row and its highlight.
|
|
final context = tester.element(row);
|
|
expect(tester.widget<AppListRow>(row).selected, selected);
|
|
final surface = find.descendant(
|
|
of: row,
|
|
matching: find.byKey(appListRowSurfaceKey),
|
|
);
|
|
expect(
|
|
cupertino
|
|
? tester.widget<ColoredBox>(surface).color
|
|
: tester.widget<Material>(surface).color,
|
|
selected
|
|
? AppListRow.selectedColor(
|
|
context,
|
|
cupertino: cupertino,
|
|
)
|
|
: const Color(0x00000000),
|
|
);
|
|
}
|
|
}
|
|
if (destination == 'Chat') {
|
|
// Starring lives in the row's actions menu.
|
|
final menu = find.byKey(const Key('chat-actions-b'));
|
|
await tester.ensureVisible(menu);
|
|
await tester.tap(menu);
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Star'));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
gateway
|
|
.callsOf('chat_star')
|
|
.last
|
|
.fields['chat_query']['session_id'],
|
|
'b',
|
|
);
|
|
final actions = find.byKey(const Key('chat-actions-b'));
|
|
await tester.ensureVisible(actions);
|
|
await tester.tap(actions);
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Rename…'), findsOneWidget);
|
|
await tester.binding.handlePopRoute();
|
|
await tester.pumpAndSettle();
|
|
}
|
|
// A phone still uses stock page navigation; returning to a wide
|
|
// window must keep the selected item without clearing its route.
|
|
tester.view.physicalSize = const Size(390, 900);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
tester
|
|
.state<NavigatorState>(find.byType(Navigator).first)
|
|
.canPop(),
|
|
isTrue,
|
|
reason: '$destination should push its selected item on a phone',
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('list-detail-list')),
|
|
findsNothing,
|
|
);
|
|
tester.view.physicalSize = Size(width, 900);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
tester
|
|
.state<NavigatorState>(find.byType(Navigator).first)
|
|
.canPop(),
|
|
isFalse,
|
|
);
|
|
expect(tester.getSize(list).width, closeTo(before, 0.01));
|
|
expect(
|
|
tester
|
|
.getSemantics(find.byKey(ValueKey(rowKeys.last)))
|
|
.flagsCollection
|
|
.isSelected,
|
|
Tristate.isTrue,
|
|
);
|
|
}
|
|
expect(
|
|
paneWidths,
|
|
everyElement(closeTo(paneWidths.first, 0.01)),
|
|
reason: 'Pipelines, Runs and Chat must use identical pane widths',
|
|
);
|
|
expect(tester.takeException(), isNull);
|
|
expect(
|
|
bodyWidths,
|
|
everyElement(closeTo(bodyWidths.first, 0.01)),
|
|
reason:
|
|
'Every destination must share the body-priority sizing policy',
|
|
);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|