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 '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 strip lines up with the header's 16px inset on both hosts: the // first label sits within its segment's own padding of that inset, not // behind a second 16px control inset (which put it at 48 on Cupertino). expect( tester .getTopLeft( find.descendant(of: strip, matching: find.text('Summary')), ) .dx, // Segments share the widest label's width, so a short first label // sits a little in from its edge; a doubled inset would be 48+. lessThan(46), ); 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} phone tabs sit at the bottom, wide ones ' 'under the header', (tester) async { await pumpRunDetail(tester, platform, size: const Size(390, 844)); final strip = tester.getRect(find.byKey(const Key('run-detail-tabs'))); final body = tester.getRect( find.byKey(const Key('run-detail-tab-body-summary')), ); expect(strip.top, greaterThanOrEqualTo(body.bottom)); expect(strip.bottom, greaterThan(844 - 80)); // Every tab is on screen without scrolling the bar. for (final tab in renderedRunDetailTabs) { final rect = tester.getRect(runDetailTab(tab)); expect(rect.left, greaterThanOrEqualTo(0), reason: tab.name); expect(rect.right, lessThanOrEqualTo(390), reason: tab.name); } await pumpRunDetail(tester, platform, size: const Size(1000, 844)); final wideStrip = tester.getRect( find.byKey(const Key('run-detail-tabs')), ); final wideBody = tester.getRect( find.byKey(const Key('run-detail-tab-body-summary')), ); expect(wideStrip.bottom, lessThanOrEqualTo(wideBody.top)); }); 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); }); } }