Merge branch 'worktree-agent-a099cbf073f6e9e51' into integrate/shell-wide

# Conflicts:
#	app/lib/features/runs/ui/run_detail_tabs.dart
This commit is contained in:
2026-10-31 12:51:39 +00:00
30 changed files with 1197 additions and 197 deletions
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
@@ -52,7 +53,10 @@ void main() {
testWidgets('a wide window keeps the tab bar and list beside the open chat '
'at $size', (tester) async {
await _pumpShell(tester, size);
expect(find.text('Select a chat to open it here.'), findsOneWidget);
expect(
find.widgetWithText(EmptyDetailPane, 'Select a chat to open it here.'),
findsOneWidget,
);
expect(
tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
isFalse,
@@ -112,9 +112,9 @@ void main() {
await _pumpPipelines(tester, gateway: gateway, pipelineId: 1, version: 2);
// The detail is open (not the "Select a pipeline." placeholder), and the
// The detail is open (not the "Select a pipeline to open it here." placeholder), and the
// detail request names the route's pinned version.
expect(find.text('Select a pipeline.'), findsNothing);
expect(find.text('Select a pipeline to open it here.'), findsNothing);
expect(find.text('Alpha review'), findsWidgets);
expect(
gateway
@@ -116,7 +116,7 @@ void main() {
expect(find.text('pipeline 2 was not found'), findsOneWidget);
expect(find.text('Retry'), findsOneWidget);
expect(find.text('Select a pipeline.'), findsNothing);
expect(find.text('Select a pipeline to open it here.'), findsNothing);
});
testWidgets('the list switches between all and scheduled pipelines', (
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -25,7 +26,13 @@ void main() {
expect(find.textContaining('run 42'), findsNothing);
// A pipeline that never ran shows its summary alone, with no status dot.
expect(find.text('no runs recorded'), findsNothing);
expect(find.text('Select a pipeline.'), findsOneWidget);
expect(
find.widgetWithText(
EmptyDetailPane,
'Select a pipeline to open it here.',
),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
@@ -218,7 +218,8 @@ void main() {
);
// The grid spans the Summary, and its one fact is at the start of the
// line rather than a half-width block centred on the page.
expect(grid.width, moreOrLessEquals(900));
// Full Summary width, up to the shared reading cap (840) on wide panes.
expect(grid.width, moreOrLessEquals(840));
expect(stage.left, moreOrLessEquals(16));
expect(stage.center.dx, lessThan(450));
expect(find.byType(CupertinoListSection), findsNothing);
@@ -1,5 +1,6 @@
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';
@@ -113,8 +114,10 @@ void main() {
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);
// 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', (
@@ -8,6 +8,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
class _Gateway implements ApiGateway {
@@ -154,6 +155,11 @@ void main() {
) async {
await tester.pumpWidget(_materialScreen(gateway));
await _mountList(tester, gateway);
// Beside the list, nothing open yet: the shared empty-pane placeholder.
expect(
find.widgetWithText(EmptyDetailPane, 'Select a run to open it here.'),
findsOneWidget,
);
await tester.tap(find.text('Beta run'));
await tester.pump();
@@ -13,8 +13,9 @@ Future<void> pumpSchedules(
ValueChanged<SavedSchedule>? onOpen,
double textScale = 1,
bool settle = true,
Size size = const Size(390, 844),
}) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
@@ -29,7 +29,9 @@ void main() {
);
expect(find.text('2 schedules'), findsOneWidget);
expect(find.textContaining('not pipeline definitions'), findsOneWidget);
// The strip carries the count only; the helper line lives in the
// empty state.
expect(find.textContaining('not pipeline definitions'), findsNothing);
// Two lines per row: the name with its next run, then the timer
// and pinned pipeline version. The editor holds the rest.
expect(find.text('Research batteries'), findsOneWidget);
@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart';
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_view.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'schedule_list_test_support.dart';
import 'schedule_screen_harness.dart';
/// On a wide window the rows share the toolbar strip's width, and the strip
/// is one row: the field, the filter and the count as a muted label.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host 1200: rows end under the strip and the strip is one '
'row', (tester) async {
await pumpSchedules(
tester,
cupertino: cupertino,
size: const Size(1200, 800),
gateway: FakeSchedulesGateway(
(type, fields) async => schedulesReply([
scheduleRecord(nextDue: '2026-10-22T09:00:00'),
pausedRecord(),
]),
),
);
final strip = tester.getRect(find.byKey(scheduleToolbarKey));
final row = tester.getRect(find.byKey(appListRowSurfaceKey).first);
expect(row.left, 0);
expect(row.width, kScheduleListMaxWidth);
// The row's trailing time ends inside the strip's trailing edge.
// The trailing time is the row's rightmost text, whatever its wording.
final time = find
.descendant(
of: find.byKey(appListRowSurfaceKey).first,
matching: find.byType(Text),
)
.evaluate()
.map((element) => tester.getRect(find.byWidget(element.widget)))
.reduce((a, b) => a.right >= b.right ? a : b);
expect(time.right, lessThanOrEqualTo(strip.right - 12 + 0.5));
// Field, filter and count on one line.
final field = tester.getRect(find.byKey(scheduleSearchFieldKey));
final filter = tester.getRect(find.byKey(scheduleFilterKey));
final count = tester.getRect(find.text('2 schedules'));
expect((field.center.dy - filter.center.dy).abs(), lessThan(4));
expect((count.center.dy - filter.center.dy).abs(), lessThan(4));
expect(find.textContaining('not pipeline definitions'), findsNothing);
});
}
}
@@ -0,0 +1,52 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
/// One placeholder for an empty detail pane: the destination's icon above a
/// short muted line, centred, on both hosts.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final destination in [
AppDestination.runs,
AppDestination.chat,
AppDestination.pipelines,
]) {
testWidgets('$host ${destination.name}: icon over a muted line', (
tester,
) async {
final content = EmptyDetailPane(
destination: destination,
message: 'Select one to open it here.',
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: content))
: MaterialApp(home: Scaffold(body: content)),
);
final details = destinationDetails(destination);
final icon = find.byIcon(
cupertino ? details.cupertinoIcon : details.icon,
);
expect(icon, findsOneWidget);
final text = find.text('Select one to open it here.');
expect(
tester.getTopLeft(text).dy,
greaterThan(tester.getRect(icon).bottom),
);
// Centred in the pane.
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1));
// Muted: the same secondary colour on the icon and the line.
final context = tester.element(text);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
expect(tester.widget<Icon>(icon).color, muted);
expect(tester.widget<Text>(text).style?.color, muted);
});
}
}
}
+25 -12
View File
@@ -12,7 +12,8 @@ import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
/// Beside a list each pane owns its bar on one shared top row, and an open
/// item's tabs never stack on the shell's tab bar at the bottom.
/// item's tabs float at the bottom of its own pane, beside (never on) the
/// shell's tab bar over the list.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
@@ -149,18 +150,20 @@ void main() {
expect(find.text('Its context'), findsOneWidget);
});
testWidgets('$host 1200: the item\'s tabs float under its bar, not on '
'the shell\'s tab bar', (tester) async {
testWidgets('$host 1200: the item\'s tabs float at the bottom of its '
'pane, beside the shell\'s tab bar', (tester) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
await tester.pump();
final shellTabs = tester.getRect(
find.descendant(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(Icon),
),
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(GlassPill),
)
.first,
);
final itemTabs = tester.getRect(
find.descendant(
@@ -168,16 +171,26 @@ void main() {
matching: find.byType(GlassPill),
),
);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
// Near the bottom of the detail pane, never on the shell's tabs.
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(itemTabs.left, greaterThanOrEqualTo(body.left));
expect(itemTabs.overlaps(shellTabs), isFalse);
// The item's list starts below its bar and clears its tabs at rest.
final paneBarPill = tester.getRect(
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
);
expect(itemTabs.top, greaterThanOrEqualTo(paneBarPill.bottom));
expect(itemTabs.top, lessThan(200));
expect(itemTabs.bottom, lessThan(shellTabs.top - 100));
// The item's list starts below its tabs at rest.
expect(
tester.getTopLeft(find.text('item row 0')).dy,
greaterThanOrEqualTo(itemTabs.bottom),
greaterThanOrEqualTo(paneBarPill.bottom),
);
expect(
MediaQuery.paddingOf(
tester.element(find.byKey(const Key('item-list'))),
).bottom,
greaterThanOrEqualTo(800 - itemTabs.top),
);
});
}
@@ -0,0 +1,151 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
/// While a tab shows its list beside an open item, the shell's destination
/// bar floats over the list pane only: it never covers the item, and the
/// item's own bottom control (a composer) owns the pane's bottom edge.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
/// A detail whose composer sits at the bottom, padded by the media inset
/// the way the chat composer is.
Widget composerDetail() => Builder(
builder: (context) => Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
child: const SizedBox(
key: Key('composer'),
height: 56,
width: double.infinity,
),
),
),
);
Widget listBody() => Builder(
builder: (context) => ListView(
key: const Key('list'),
children: [
for (var index = 0; index < 40; index++)
SizedBox(height: 40, child: Text('row $index')),
],
),
);
Widget shell({
required bool cupertino,
bool split = true,
double textScale = 1,
}) {
final app = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) => split
? ListDetailPanes(list: listBody(), detail: composerDetail())
: listBody(),
},
);
return MediaQuery(
data: MediaQueryData.fromView(
WidgetsBinding.instance.platformDispatcher.views.first,
).copyWith(textScaler: TextScaler.linear(textScale)),
child: cupertino ? CupertinoApp(home: app) : MaterialApp(home: app),
);
}
Rect destinationPill(WidgetTester tester) => tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.chat')).first,
matching: find.byType(GlassPill),
)
.first,
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final width in [1200.0, 1600.0]) {
testWidgets('$host $width split: the destination bar stays over the '
'list pane and the composer owns the detail bottom', (tester) async {
await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
await tester.pump();
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final pill = destinationPill(tester);
expect(pill.right, lessThanOrEqualTo(list.right));
expect(pill.left, greaterThanOrEqualTo(list.left));
expect(pill.overlaps(body), isFalse, reason: 'no overlap with detail');
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
// The detail keeps only the system inset (none here): its composer
// reaches the bottom edge, below the level of the shell's pill.
final composer = tester.getRect(find.byKey(const Key('composer')));
expect(composer.bottom, 800);
expect(composer.left, body.left);
expect(composer.top, greaterThan(pill.top));
// The list still clears the bar.
final listContext = tester.element(find.byKey(const Key('list')));
expect(
MediaQuery.paddingOf(listContext).bottom,
greaterThanOrEqualTo(pill.height),
);
});
}
testWidgets('$host 1200 unsplit: the bar is compact at the right edge', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
await tester.pump();
final pill = destinationPill(tester);
expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(pill.width, lessThan(1200 * 0.6));
});
testWidgets('$host 390: the bar spans the phone', (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.right, closeTo(390 - kFloatingBarMargin, 0.5));
});
for (final width in [600.0, 840.0]) {
testWidgets('$host $width split at 2x: the narrow list pane bar lays '
'out without overflow', (tester) async {
await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino, textScale: 2));
await tester.pump();
await tester.pump();
expect(tester.takeException(), isNull);
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
expect(destinationPill(tester).right, lessThanOrEqualTo(list.right));
});
}
}
}
+191
View File
@@ -0,0 +1,191 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/detail_page.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
/// On a wide split window (an unfolded foldable) under a system status bar,
/// every pane's bar sits below the status-bar inset while content still
/// reaches the top edge; and the open item's tabs float at the bottom of the
/// detail pane, beside (never on) the shell's tab bar over the list.
void main() {
const statusBar = 40.0;
Future<void> setUp(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
tester.view.padding = const FakeViewPadding(top: statusBar);
tester.view.viewPadding = const FakeViewPadding(top: statusBar);
addTearDown(tester.view.reset);
}
List<Widget> rows(String label) => [
for (var index = 0; index < 40; index++)
SizedBox(height: 40, child: Text('$label $index')),
];
/// An item publishing its bar to the pane, with its own floating tabs
/// placed where the pane says (like run and pipeline detail).
Widget tabbedItem(bool cupertino) => ShellBar(
title: 'Open item',
child: Builder(
builder: (context) {
final edge = PageTabsEdge.of(context);
return FloatingBarOverlay(
edge: edge,
bar: KeyedSubtree(
key: const Key('item-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
edge: edge,
currentIndex: 0,
onTap: (_) {},
items: const [
FloatingDestinationItem(icon: Icon(Icons.notes), label: 'One'),
FloatingDestinationItem(icon: Icon(Icons.share), label: 'Two'),
],
),
),
child: Builder(
builder: (context) => ListView(
key: const Key('item-list'),
padding: withBarClearance(context, EdgeInsets.zero),
children: rows('item'),
),
),
);
},
),
);
/// An item drawing its own header over itself (like the chat thread).
Widget overlayItem(bool cupertino) => ShellBar(
barless: true,
child: SegmentedBarOverlay(
bar: SegmentedBar(
key: const Key('own-header'),
cupertino: cupertino,
automaticallyImplyLeading: false,
title: 'Own header',
),
child: ListView(key: const Key('item-list'), children: rows('item')),
),
);
Widget shell(bool cupertino, Widget Function(bool) item) {
final app = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => ListDetailPanes(
list: ShellBar(
child: ListView(key: const Key('list'), children: rows('list')),
),
detail: DetailPane(
destination: AppDestination.runs,
implyBack: false,
builder: (_) => item(cupertino),
),
),
},
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
}
Iterable<Rect> pillsOf(WidgetTester tester, Finder bar) => find
.descendant(of: bar, matching: find.byType(GlassPill))
.evaluate()
.map((element) {
final box = element.renderObject! as RenderBox;
return box.localToGlobal(Offset.zero) & box.size;
});
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host split under a status bar: list and pane bars sit '
'below it, content reaches the top edge', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, tabbedItem));
await tester.pump();
await tester.pump();
final listBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Runs',
);
final paneBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Open item',
);
for (final bar in [listBar, paneBar]) {
final pills = pillsOf(tester, bar);
expect(pills, isNotEmpty);
for (final pill in pills) {
expect(pill.top, greaterThanOrEqualTo(statusBar));
}
}
// Content may still extend under the bars and the status bar.
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
// At rest the first rows start below the bars.
final paneBottom = pillsOf(tester, paneBar).first.bottom;
expect(
tester.getTopLeft(find.text('item 0')).dy,
greaterThanOrEqualTo(paneBottom),
);
});
testWidgets('$host split under a status bar: a self-drawn header (chat) '
'sits below it', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, overlayItem));
await tester.pump();
await tester.pump();
final pills = pillsOf(tester, find.byKey(const Key('own-header')));
expect(pills, isNotEmpty);
for (final pill in pills) {
expect(pill.top, greaterThanOrEqualTo(statusBar));
}
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
});
testWidgets('$host split: the item tabs float at the bottom of the '
'detail pane, beside the shell tab bar over the list', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, tabbedItem));
await tester.pump();
await tester.pump();
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final tabs = pillsOf(tester, find.byKey(const Key('item-tabs'))).single;
expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(tabs.left, greaterThanOrEqualTo(body.left));
expect(tabs.right, lessThanOrEqualTo(body.right));
final shellTabs = tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(GlassPill),
)
.first,
);
expect(shellTabs.overlaps(tabs), isFalse);
expect(shellTabs.right, lessThanOrEqualTo(body.left));
// The item's list clears its tabs at rest.
final list = tester.element(find.byKey(const Key('item-list')));
expect(
MediaQuery.paddingOf(list).bottom,
greaterThanOrEqualTo(800 - tabs.top),
);
});
}
}
+115
View File
@@ -0,0 +1,115 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_summary_view.dart';
import 'package:pipelines_app/ui/layout/reading_width.dart';
import '../../features/pipelines/fixtures.dart';
import '../../features/pipelines/test_helpers.dart';
import '../../features/runs/ui/run_detail_graph_support.dart';
import '../../features/runs/ui/run_detail_visit_support.dart';
/// Reading bodies (run Summary, stage page sections, pipeline Summary) keep
/// [kReadingMaxWidth] from the leading edge on a wide window and the full
/// width on a phone.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
testWidgets('ReadingWidth caps from the leading edge and keeps its child '
'across the cap', (tester) async {
await setSize(tester, const Size(1200, 600));
final scroll = ScrollController();
addTearDown(scroll.dispose);
await tester.pumpWidget(
MaterialApp(
home: ReadingWidth(
child: ListView(
key: const Key('body'),
controller: scroll,
children: [
for (var index = 0; index < 50; index++)
SizedBox(height: 40, child: Text('row $index')),
],
),
),
),
);
final wide = tester.getRect(find.byKey(const Key('body')));
expect(wide.left, 0);
expect(wide.width, kReadingMaxWidth);
expect(wide.height, 600);
scroll.jumpTo(300);
await tester.pump();
await setSize(tester, const Size(500, 600));
await tester.pump();
expect(tester.getRect(find.byKey(const Key('body'))).width, 500);
expect(scroll.offset, 300, reason: 'the body was not remounted');
});
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} 1200: run Summary is capped', (tester) async {
await pumpRunDetail(tester, platform, size: const Size(1200, 800));
final body = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
);
expect(body.left, 0);
expect(body.width, kReadingMaxWidth);
});
testWidgets('${platform.name} 390: run Summary keeps the full width', (
tester,
) async {
await pumpRunDetail(tester, platform, size: const Size(390, 844));
final body = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
);
expect(body.width, 390);
});
testWidgets('${platform.name} 1200: stage page Summary is capped', (
tester,
) async {
await openVisit(tester, platform, size: const Size(1200, 900));
final body = tester.getRect(
find.byKey(const Key('run-visit-body-summary')),
);
expect(body.left, 0);
expect(body.width, kReadingMaxWidth);
// The section's trailing copy button sits within the cap.
final copy = find.byKey(const ValueKey('run-visit-copy-Input'));
expect(tester.getRect(copy).right, lessThanOrEqualTo(kReadingMaxWidth));
});
}
testWidgets('1200: pipeline Summary is capped, the pane still scrolls', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
final gateway = gatewayFor(PipelineFixture());
final controller = PipelinesController(PipelinesRepository(gateway));
addTearDown(controller.dispose);
await controller.openPipeline(1);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: PipelineDetailPanel(
controller: controller,
gateway: gateway,
showBack: false,
),
),
),
);
await tester.pumpAndSettle();
final summary = tester.getRect(find.byType(PipelineSummaryView));
expect(summary.left, 0);
expect(summary.width, kReadingMaxWidth);
});
}