Polish adaptive app chrome

This commit is contained in:
2026-10-31 06:02:02 +00:00
parent 06f6eda360
commit 480f8843eb
14 changed files with 228 additions and 53 deletions
@@ -147,6 +147,11 @@ void main() {
),
findsOneWidget,
);
final pagerPill = find.ancestor(
of: find.byKey(ChangesVisitPager.nextKey),
matching: find.byType(GlassPill),
);
expect(tester.getRect(pagerPill).width, lessThan(400));
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
@@ -206,5 +206,45 @@ void main() {
);
}
});
testWidgets('Cupertino mode is icon-only below 600px', (tester) async {
if (!cupertino) return;
final semantics = tester.ensureSemantics();
_size(tester, const Size(560, 800));
await _pump(
tester,
cupertino: true,
messages: 1,
session: const {
'id': 's',
'backend': 'opencode',
'model': 'p/sonnet-4-5',
'mode': 'default',
'mode_name': 'Ask for permission',
},
);
final mode = find.byKey(const Key('chat-mode'));
expect(mode, findsOneWidget);
expect(
find.descendant(of: mode, matching: find.text('Ask for permission')),
findsNothing,
);
expect(
tester.getSemantics(mode).label,
contains('Change mode, currently Ask for permission'),
);
await tester.tap(mode);
await tester.pumpAndSettle();
expect(find.byKey(const Key('chat-mode-sheet')), findsOneWidget);
// The fixture has no chat_modes catalog, but the recorded session mode
// remains visible in the sheet.
expect(
find.byKey(const ValueKey('chat-mode-option-default')),
findsOneWidget,
);
expect(find.text('Ask for permission'), findsOneWidget);
semantics.dispose();
});
}
}
@@ -1,9 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/graph/viewport/graph_expanded_view.dart';
import 'package:pipelines_app/features/graph/viewport/graph_viewport.dart';
import 'package:pipelines_app/features/graph/viewport/graph_viewport_math.dart';
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
@@ -103,7 +105,7 @@ void main() {
isTrue,
);
await tester.tap(find.byKey(const Key('graph-expanded-close')));
await tester.tap(find.byType(BackButton));
await tester.pumpAndSettle();
expect(find.byType(GraphExpandedView), findsNothing);
@@ -195,14 +197,18 @@ void main() {
await tester.tap(find.byKey(const Key('graph-expand')));
await tester.pumpAndSettle();
expect(find.byType(GraphExpandedView), findsOneWidget);
expect(_inExpanded(find.text(graphExpandedClose)), findsOneWidget);
expect(
_inExpanded(find.byType(CupertinoNavigationBarBackButton)),
findsOneWidget,
);
expect(_inExpanded(find.byKey(const Key('graph-fit'))), findsOneWidget);
expect(
tester.widget<GraphStageNode>(_inExpanded(_node('build'))).selected,
isTrue,
);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const Key('graph-expanded-close')));
await tester.tap(find.byType(CupertinoNavigationBarBackButton));
await tester.pumpAndSettle();
expect(find.byType(GraphExpandedView), findsNothing);
expect(tester.widget<GraphStageNode>(_node('build')).selected, isTrue);
@@ -210,4 +216,43 @@ void main() {
expect(picked, isEmpty);
expect(tester.takeException(), isNull);
});
testWidgets('expanded Fit is an activatable labelled button on both hosts', (
tester,
) async {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: DefinitionGraphView(
graph: linearGraph(),
selectedStage: 'build',
onSelected: (_) {},
),
),
)
: _materialHost(
graph: linearGraph(),
selected: 'build',
onSelected: (_) {},
),
);
await _settle(tester);
await tester.tap(find.byKey(const Key('graph-expand')));
await tester.pumpAndSettle();
final fit = tester
.getSemantics(_inExpanded(find.byKey(const Key('graph-fit'))))
.getSemanticsData();
expect(fit.label, graphFitLabel, reason: '$host Fit must be labelled');
expect(fit.flagsCollection.isButton, isTrue);
expect(
fit.hasAction(SemanticsAction.tap),
isTrue,
reason: '$host Fit must expose its tap action on the labelled node',
);
}
});
}
@@ -82,6 +82,16 @@ void main() {
expect(_text('error'), findsOneWidget);
});
testWidgets('the rendered/raw control remains compact', (tester) async {
tester.view.physicalSize = const Size(800, 700);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(_material(_view()));
final control = find.byKey(const Key('markdown-source-mode'));
expect(tester.getRect(control).width, lessThan(221));
});
testWidgets('the raw section keeps unknown fields exact and selectable', (
tester,
) async {
@@ -128,7 +128,7 @@ void main() {
isTrue,
);
await tester.tap(find.byKey(const Key('graph-expanded-close')));
await tester.tap(find.byType(BackButton));
await tester.pumpAndSettle();
expect(find.byType(GraphExpandedView), findsNothing);
@@ -149,7 +149,7 @@ void main() {
await tester.tap(find.byKey(const Key('graph-expand')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('graph-expanded-close')));
await tester.tap(find.byType(BackButton));
await tester.pumpAndSettle();
expect(find.byType(GraphExpandedView), findsNothing);