Merge branch 'worktree-agent-a77fe68a62a10ce30' into integrate/notify-marked

This commit is contained in:
2026-10-31 16:55:40 +00:00
9 changed files with 430 additions and 78 deletions
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_styles.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
void main() {
@@ -66,14 +67,15 @@ void main() {
findsOneWidget,
);
final pill = tester.getRect(find.byType(GlassPill));
if (width < 600) {
expect(pill.left, 16);
expect(pill.right, width - 16);
} else {
// Sized to its three tabs at the right edge.
expect(pill.right, width - 16);
expect(pill.width, lessThan(width * 0.6));
}
// Sized to its three tabs at the right edge, on a phone as when wide.
expect(pill.right, width - 16);
expect(
pill.width,
FloatingDestinationBar.pillWidth(
cupertino: cupertino,
tabs: PipelineDetailTab.values.length,
),
);
for (final tab in PipelineDetailTab.values) {
final rect = tester.getRect(
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
@@ -5,6 +5,7 @@ import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'run_detail_graph_support.dart';
@@ -91,8 +92,14 @@ void main() {
find.descendant(of: strip, matching: find.byType(GlassPill)),
);
final body = find.byKey(const Key('run-detail-tab-body-summary'));
// Full width minus the margins, floating above the bottom.
expect(pill.left, 16);
// Sized to its tabs at the right, floating above the bottom.
expect(
pill.width,
FloatingDestinationBar.pillWidth(
cupertino: platform != RunDetailTestPlatform.material,
tabs: renderedRunDetailTabs.length,
),
);
expect(pill.right, 390 - 16);
expect(pill.bottom, 844 - 16);
// The tab's content reaches the bottom edge, behind the bar.
@@ -245,8 +245,8 @@ void main() {
final strip = tester.getRect(find.byType(RunVisitSectionStrip));
expect(strip.bottom, size.height, reason: section.name);
}
// The floating glass bar: full width on a phone, sized to its tabs
// at the right edge of a wide page.
// The floating glass bar: sized to its tabs at the right edge, on
// a phone as on a wide page.
final pill = tester.getRect(
find.descendant(
of: find.byType(RunVisitSectionStrip),
@@ -255,12 +255,8 @@ void main() {
);
expect(pill.right, size.width - 16);
expect(pill.bottom, size.height - 16);
if (size.width < 600) {
expect(pill.left, 16);
} else {
// (The test font draws every glyph a full em wide.)
expect(pill.width, lessThan(size.width * 0.7));
}
// Sized to its tabs at the right on every width.
expect(pill.width, lessThan(size.width * 0.7));
},
);
}
+31 -9
View File
@@ -48,16 +48,25 @@ void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: phone bar spans the width minus its margins', (
tester,
) async {
testWidgets('$host: phone bar hugs its tabs at the bottom right too, and '
'taps beside it reach the content', (tester) async {
taps = 0;
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino));
final rect = tester.getRect(pill());
expect(rect.left, 16);
expect(
rect.width,
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
);
expect(rect.right, 390 - 16);
expect(rect.bottom, 844 - 16);
expect(find.byType(NavigationRail), findsNothing);
await tester.tapAt(Offset(rect.left - 40, rect.center.dy));
await tester.pump();
expect(taps, 1);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
testWidgets('$host: wide bar hugs its tabs at the right edge, content '
@@ -69,13 +78,17 @@ void main() {
expect(rect.right, 1200 - 16);
expect(rect.bottom, 800 - 16);
expect(rect.width, lessThan(1200 * 0.6));
// Four icon-only tabs (Settings opens from the Pipelines bar).
// Four icon-only tabs (Settings opens from the Pipelines bar) and one
// more edge gap, so the outer circles keep it from the sides.
expect(
rect.width,
4 *
(cupertino
? FloatingDestinationBar.cupertinoTabWidth
: FloatingDestinationBar.materialTabWidth) +
(cupertino
? FloatingDestinationBar.cupertinoTabWidth
: FloatingDestinationBar.materialTabWidth),
? FloatingDestinationBar.cupertinoEdgeGap
: FloatingDestinationBar.materialEdgeGap),
);
// No rail or sidebar: the content starts at the left edge.
expect(find.byType(NavigationRail), findsNothing);
@@ -127,7 +140,11 @@ void main() {
tester.view.physicalSize = const Size(390, 844);
await tester.pump();
expect(tester.getRect(pill()).width, 390 - 32);
expect(
tester.getRect(pill()).width,
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
);
expect(tester.getRect(pill()).right, 390 - 16);
expect(tester.state(find.byType(StatefulBuilder)), same(state));
});
@@ -186,7 +203,12 @@ void main() {
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(tester.getRect(pill()).width, 320 - 32);
// Sized to its four tabs at the right, as on any width.
expect(
tester.getRect(pill()).width,
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
);
expect(tester.getRect(pill()).right, 320 - 16);
}
});
}
+6 -1
View File
@@ -90,7 +90,12 @@ void main() {
of: find.byType(FloatingDestinationBar),
matching: find.byType(GlassPill),
);
expect(tester.getSize(destinationPill).width, 358);
// Sized to its four tabs at the bottom right.
expect(
tester.getSize(destinationPill).width,
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
);
expect(tester.getRect(destinationPill).right, 390 - 16);
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump();
expect(find.text('Chat — Not implemented'), findsOneWidget);
@@ -192,12 +192,16 @@ void main() {
expect(pill.width, lessThan(1200 * 0.6));
});
testWidgets('$host 390: the bar spans the phone', (tester) async {
testWidgets('$host 390: the bar hugs its tabs at the phone\'s bottom '
'right', (tester) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
await tester.pump();
final pill = destinationPill(tester);
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
expect(
pill.width,
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
);
expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5));
});
@@ -0,0 +1,219 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
/// The floating tab bar is sized to its tabs at the bottom right on every
/// width, and its selection circle keeps one gap everywhere: the first and
/// last circles sit as far from the pill's sides as from its top and bottom,
/// and neighbouring circles are that far apart too, on both hosts.
void main() {
const icons = [
Icons.account_tree_outlined,
Icons.play_circle_outline,
Icons.chat_bubble_outline,
Icons.search,
Icons.settings_outlined,
];
Key tabKey(int index) => ValueKey('tab-$index');
Widget bar({
required bool cupertino,
required int count,
required int selected,
ValueChanged<int>? onTap,
}) => FloatingDestinationBar(
cupertino: cupertino,
currentIndex: selected,
onTap: onTap ?? (_) {},
items: [
for (var index = 0; index < count; index += 1)
FloatingDestinationItem(
key: tabKey(index),
icon: Icon(icons[index]),
label: 'Tab $index',
),
],
);
Future<void> pump(
WidgetTester tester, {
required bool cupertino,
required Size size,
required Widget child,
double textScale = 1,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final body = MediaQuery(
data: MediaQueryData(
size: size,
textScaler: TextScaler.linear(textScale),
),
child: child,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body)),
);
await tester.pumpAndSettle();
}
Rect circle(WidgetTester tester, int index) => tester.getRect(
find
.descendant(
of: find.byKey(tabKey(index)),
matching: find.byWidgetPredicate(
(widget) =>
widget is DecoratedBox &&
widget.decoration is ShapeDecoration &&
(widget.decoration as ShapeDecoration).shape is CircleBorder,
),
)
.first,
);
Rect pill(WidgetTester tester) => tester.getRect(
find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.byType(GlassPill),
),
);
final placements = [
(name: 'wide 1200, 4 tabs', size: const Size(1200, 800), count: 4),
(name: 'phone 390, 3 tabs', size: const Size(390, 844), count: 3),
(name: 'phone 390, 4 tabs', size: const Size(390, 844), count: 4),
(name: 'phone 560, 5 tabs', size: const Size(560, 844), count: 5),
(name: 'phone 320, 5 tabs', size: const Size(320, 640), count: 5),
];
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final placement in placements) {
testWidgets('$host ${placement.name}: compact at the bottom right; the '
'outer circles keep the top gap from the sides and neighbours', (
tester,
) async {
final count = placement.count;
final size = placement.size;
final centres = <double>[];
for (final selected in [0, count - 1]) {
await pump(
tester,
cupertino: cupertino,
size: size,
child: Align(
alignment: Alignment.bottomCenter,
child: bar(
cupertino: cupertino,
count: count,
selected: selected,
),
),
);
final box = pill(tester);
expect(box.right, size.width - 16);
expect(box.bottom, size.height - 16);
final mark = circle(tester, selected);
expect(mark.width, mark.height);
final top = mark.top - box.top;
expect(box.bottom - mark.bottom, moreOrLessEquals(top, epsilon: 1));
final side = selected == 0
? mark.left - box.left
: box.right - mark.right;
expect(
side,
moreOrLessEquals(top, epsilon: 1),
reason: 'side gap $side vs top gap $top',
);
// The pill's round end is concentric with the outer circle.
expect(box.height / 2, moreOrLessEquals(top + mark.width / 2));
}
// Unselected icons sit where their circle would: neighbours are
// evenly spaced, one edge gap apart.
for (var index = 0; index < count; index += 1) {
centres.add(
tester
.getCenter(
find.descendant(
of: find.byKey(tabKey(index)),
matching: find.byIcon(icons[index]),
),
)
.dx,
);
}
final last = circle(tester, count - 1);
final gap = last.top - pill(tester).top;
for (var index = 1; index < count; index += 1) {
expect(
centres[index] - centres[index - 1] - last.width,
moreOrLessEquals(gap, epsilon: 1),
);
}
expect(last.center.dx, moreOrLessEquals(centres.last, epsilon: 1));
});
}
testWidgets('$host phone: taps beside the compact bar reach the content, '
'taps on it the tabs', (tester) async {
final tapped = <int>[];
var content = 0;
await pump(
tester,
cupertino: cupertino,
size: const Size(390, 844),
child: Stack(
children: [
Positioned.fill(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => content++,
),
),
Align(
alignment: Alignment.bottomCenter,
child: bar(
cupertino: cupertino,
count: 3,
selected: 1,
onTap: tapped.add,
),
),
],
),
);
final box = pill(tester);
expect(box.width, lessThan(390 / 2));
await tester.tapAt(Offset(box.left - 40, box.center.dy));
await tester.tapAt(box.centerLeft + const Offset(12, 0));
await tester.tapAt(box.centerRight - const Offset(12, 0));
await tester.pump();
expect(content, 1);
expect(tapped, [0, 2]);
});
testWidgets('$host: 5 tabs at 320 with 2x text do not overflow', (
tester,
) async {
await pump(
tester,
cupertino: cupertino,
size: const Size(320, 640),
textScale: 2,
child: Align(
alignment: Alignment.bottomCenter,
child: bar(cupertino: cupertino, count: 5, selected: 4),
),
);
expect(tester.takeException(), isNull);
expect(pill(tester).right, 320 - 16);
expect(pill(tester).left, greaterThanOrEqualTo(16));
});
}
}