Files
pipelines/app/test/features/runs/ui/run_detail_tabs_test.dart
T
alan 6987a8992e Merge branch 'worktree-agent-a099cbf073f6e9e51' into integrate/shell-wide
# Conflicts:
#	app/lib/features/runs/ui/run_detail_tabs.dart
2026-10-31 12:51:39 +00:00

167 lines
6.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/reading_width.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 reading
// width from the leading edge (Summary is capped on a wide pane).
expect(tester.getRect(body).left, 0);
expect(tester.getRect(body).width, kReadingMaxWidth);
});
testWidgets('${platform.name} missing graph states the exact wording', (
tester,
) async {
await pumpRunDetail(tester, platform, run: graphRunFixture(graph: false));
await openRunDetailTab(tester, RunDetailTab.summary);
// One muted line on the Summary: no framed, tappable empty preview.
expect(find.text(runGraphMissing), findsOneWidget);
expect(find.byKey(runGraphPreviewMissingKey), findsOneWidget);
expect(find.byKey(runGraphPreviewKey), findsNothing);
expect(find.byType(RunGraphView), findsNothing);
expect(find.byType(InteractiveViewer), findsNothing);
final line = tester.getSize(find.byKey(runGraphPreviewMissingKey));
expect(line.height, lessThan(60));
expect(
find.descendant(
of: find.byKey(runGraphPreviewMissingKey),
matching: find.byType(DecoratedBox),
),
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);
});
}
}