Files
pipelines/app/test/features/runs/ui/run_detail_tabs_test.dart
T
alan 963adec122 Float glass tab bars everywhere the app has bottom tabs
One floating frosted tab bar (host NavigationBar / CupertinoTabBar in the
shared GlassPill) replaces the NavigationRail, the Cupertino sidebar and the
run detail, stage page and pipeline detail tab strips. Below 600px it spans
the width minus 16px margins; wider it is sized to its tabs at the right edge.
Content keeps the full width, scrolls behind the bar and learns its height as
bottom media padding; lists pad their end clear of it and FABs sit above it.

The bar now sizes itself from its own constraints instead of the screen size,
which fixes the widget_test failure where a MediaQuery without a size gave it
negative width constraints.
2026-10-31 01:50:42 +00:00

151 lines
5.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_graph_preview.dart';
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/glass_pill.dart';
import 'run_detail_graph_support.dart';
void main() {
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} tabs keep the web order and the actions', (
tester,
) async {
await pumpRunDetail(tester, platform);
// The graph is a preview on Summary; artifacts and changes are tabs.
expect(renderedRunDetailTabs, [
RunDetailTab.summary,
RunDetailTab.timeline,
RunDetailTab.artifacts,
RunDetailTab.changes,
]);
final strip = find.byKey(const Key('run-detail-tabs'));
for (final label in ['Summary', 'Timeline', 'Artifacts', 'Changes']) {
expect(
find.descendant(of: strip, matching: find.text(label)),
findsOneWidget,
);
}
expect(
find.descendant(of: strip, matching: find.text('Graph')),
findsNothing,
);
expect(find.byKey(runGraphPreviewKey), findsOneWidget);
// Input and Output are Summary sections now, never separate tabs.
for (final label in ['Input', 'Output']) {
expect(
find.descendant(of: strip, matching: find.text(label)),
findsNothing,
);
}
var previous = double.negativeInfinity;
for (final tab in renderedRunDetailTabs) {
final center = tester.getCenter(runDetailTab(tab));
expect(center.dx, greaterThan(previous));
previous = center.dx;
}
expect(find.byKey(runMoreMenuKey), findsOneWidget);
// The tabs are the floating glass bar: on this 900px detail it is sized
// to its tabs at the right edge, above the bottom.
final pill = tester.getRect(
find.descendant(of: strip, matching: find.byType(GlassPill)),
);
expect(pill.right, 900 - 16);
expect(pill.bottom, 1000 - 16);
// (The test font draws every glyph a full em wide.)
expect(pill.width, lessThan(900 * 0.7));
for (final tab in [
RunDetailTab.timeline,
RunDetailTab.artifacts,
RunDetailTab.changes,
RunDetailTab.summary,
]) {
await openRunDetailTab(tester, tab);
expect(find.byKey(runMoreMenuKey), findsOneWidget);
expect(find.text('Graph run'), findsOneWidget);
}
});
testWidgets('${platform.name} tabs float full width on a phone and at '
'the right edge when wide, over content that scrolls behind them', (
tester,
) async {
await pumpRunDetail(tester, platform, size: const Size(390, 844));
final strip = find.byKey(const Key('run-detail-tabs'));
final pill = tester.getRect(
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);
expect(pill.right, 390 - 16);
expect(pill.bottom, 844 - 16);
// The tab's content reaches the bottom edge, behind the bar.
expect(tester.getRect(body).bottom, 844);
// Every tab is on screen without scrolling the bar.
for (final tab in renderedRunDetailTabs) {
final rect = tester.getRect(runDetailTab(tab));
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
}
// At rest after scrolling to the end, the last content clears the bar.
final scrollable = find.descendant(
of: body,
matching: find.byType(Scrollable),
);
final position = tester.state<ScrollableState>(scrollable.first).position;
position.jumpTo(position.maxScrollExtent);
await tester.pumpAndSettle();
expect(
MediaQuery.paddingOf(tester.element(body)).bottom,
greaterThanOrEqualTo(844 - pill.top),
);
await pumpRunDetail(tester, platform, size: const Size(1000, 844));
final widePill = tester.getRect(
find.descendant(of: strip, matching: find.byType(GlassPill)),
);
expect(widePill.right, 1000 - 16);
expect(widePill.bottom, 844 - 16);
expect(widePill.width, lessThan(1000 * 0.6));
// Beside the bar the content takes taps: the body spans the width.
expect(tester.getRect(body).width, 1000);
});
testWidgets('${platform.name} missing graph states the exact wording', (
tester,
) async {
await pumpRunDetail(tester, platform, run: graphRunFixture(graph: false));
await openRunDetailTab(tester, RunDetailTab.graph);
expect(find.text(runGraphMissing), findsOneWidget);
expect(find.byType(InteractiveViewer), findsNothing);
});
testWidgets('${platform.name} Graph stays bounded at 320 with 2x text', (
tester,
) async {
await pumpRunDetail(
tester,
platform,
size: const Size(320, 568),
scale: 2,
);
await openRunDetailTab(tester, RunDetailTab.graph);
expect(tester.takeException(), isNull);
final slot = tester.getSize(find.byType(RunGraphView));
expect(slot.height, greaterThan(0));
expect(slot.width, lessThanOrEqualTo(320));
expect(find.byType(InteractiveViewer), findsOneWidget);
expect(find.text(runGraphExecuted), findsOneWidget);
expect(find.text(runGraphNotExecuted), findsOneWidget);
});
}
}