9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
265 lines
10 KiB
Dart
265 lines
10 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import 'dart:ui' show Tristate;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/shell/list_detail.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 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: '
|
|
'$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(
|
|
destinationBodies: {
|
|
AppDestination.pipelines: (_) =>
|
|
PipelinesScreen(gateway: gateway, embedded: true),
|
|
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
|
|
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
|
},
|
|
);
|
|
await tester.pumpWidget(
|
|
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));
|
|
// 60% of the window, or more once the list reaches its cap.
|
|
expect(
|
|
bodyBefore,
|
|
lessThanOrEqualTo(
|
|
math.max(width * 0.6, width - 1 - kListPaneMaxWidth) + 0.5,
|
|
),
|
|
);
|
|
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));
|
|
// 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 retains shared row semantics; features may supply their own fill.
|
|
final context = tester.element(row);
|
|
expect(tester.widget<AppListRow>(row).selected, selected);
|
|
final surface = find.descendant(
|
|
of: row,
|
|
matching: find.byKey(appListRowSurfaceKey),
|
|
);
|
|
expect(
|
|
tester.widget<Material>(surface).color,
|
|
selected
|
|
? tester.widget<AppListRow>(row).selectedFill ??
|
|
AppListRow.selectedColor(context)
|
|
: 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());
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|