Files
pipelines/app/test/shell/pane_bar_row_test.dart
T
alan c6c6dcfe18 fix(app): float content behind top bars and give each wide pane its own bar row
- Top-bar clearance helpers (withTopBarClearance, withBarClearance,
  SliverTopBarClearance, BelowTopBar, TopBarNotices); shell, DetailPane and
  the runs/pipelines/templates/artifacts/stage definition/filter/usage pages
  drop their top SafeArea and pad their own lists, pinned headers pin at the
  inset.
- Wide windows: the shell bar narrows to the list pane (ShellPaneSplit) and
  the open item's bar shares its row; item tabs float at the pane's top
  (PageTabsEdge) instead of stacking on the shell's tab bar; the floating
  tab pill no longer swells over leftover media padding.
- Pipeline detail is a DetailPane on wide too; Run/Runs move from FABs into
  the bar's actions; name and identity live in the title pill.
- Run detail title pill shows the real title with Run N, pipeline and
  version (the pill links to the pipeline); the body keeps only status,
  actions and notices; standalone detail draws the same segmented bar.
- One Runs tab badge: attention outranks running.
- Tests for content-behind-bar padding and the no-stacking wide layout;
  notes/app-chrome-fixes.md.
2026-10-31 03:36:22 +00:00

232 lines
7.8 KiB
Dart

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';
/// 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.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
Rect rectOf(Element element) {
final box = element.renderObject! as RenderBox;
return box.localToGlobal(Offset.zero) & box.size;
}
/// An open item: its title published to the pane's bar, its own tabs
/// floating where the pane says, and a list padded clear of both bars.
Widget item({bool cupertino = false}) => ShellBar(
title: 'Open item',
subtitle: 'Its context',
actions: const [Icon(Icons.more_vert, semanticLabel: 'More')],
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.timeline),
label: 'Two',
),
],
),
),
child: Builder(
builder: (context) => ListView(
key: const Key('item-list'),
padding: withBarClearance(context, EdgeInsets.zero),
children: [
for (var index = 0; index < 30; index++)
SizedBox(height: 40, child: Text('item row $index')),
],
),
),
);
},
),
);
Widget shell({bool cupertino = false, int attention = 0}) {
final app = AdaptiveShell(
cupertino: cupertino,
attentionCount: attention,
destinationBodies: {
AppDestination.runs: (_) => ShellBadge(
kind: ShellBadgeKind.running,
count: 4,
child: ListDetailPanes(
list: ShellBar(
actions: [const Icon(Icons.sort, semanticLabel: 'Sort')],
child: ListView(
children: [
for (var index = 0; index < 30; index++)
SizedBox(height: 40, child: Text('list row $index')),
],
),
),
detail: DetailPane(
destination: AppDestination.runs,
implyBack: false,
builder: (_) => item(cupertino: cupertino),
),
),
),
},
destination: AppDestination.runs,
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
}
Finder shellBar() => find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Runs',
);
Finder paneBar() => find.descendant(
of: find.byType(DetailPane),
matching: find.byType(SegmentedBar),
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host 1200: the shell bar covers the list pane and the '
'item\'s bar shares its row', (tester) async {
await setSize(tester, const Size(1200, 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 shellPills = find.descendant(
of: shellBar(),
matching: find.byType(GlassPill),
);
for (final element in shellPills.evaluate()) {
expect(
rectOf(element).right,
lessThanOrEqualTo(list.right),
reason: 'no shell piece sits over the open item',
);
}
// Both titles on the same top row.
final shellTitle = tester.getRect(
find.descendant(of: shellBar(), matching: find.text('Runs')),
);
final paneTitle = tester.getRect(find.text('Open item'));
expect(paneTitle.left, greaterThanOrEqualTo(body.left));
final paneTop = tester.getRect(
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
);
final shellTop = tester.getRect(shellPills.first);
expect(paneTop.top, shellTop.top);
expect(paneTitle.top, lessThan(shellTitle.bottom));
// The title pill carries the item's context too.
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 {
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),
),
);
final itemTabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('item-tabs')),
matching: find.byType(GlassPill),
),
);
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),
);
});
}
testWidgets('390: an open item is its own page with its tabs at the bottom', (
tester,
) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(
MaterialApp(
home: DetailPane(
destination: AppDestination.runs,
builder: (_) => item(),
),
),
);
await tester.pump();
final tabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('item-tabs')),
matching: find.byType(GlassPill),
),
);
expect(tabs.bottom, greaterThan(844 - 40));
// Content reaches the top edge and starts below the page's bar.
final bar = tester.getRect(
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
);
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
expect(
tester.getTopLeft(find.text('item row 0')).dy,
greaterThanOrEqualTo(bar.bottom),
);
});
testWidgets('the Runs tab shows one indicator: attention outranks running', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(attention: 2));
await tester.pump();
await tester.pump();
expect(find.text('2'), findsOneWidget);
expect(find.text('4'), findsNothing);
await tester.pumpWidget(shell());
await tester.pump();
await tester.pump();
expect(find.text('4'), findsOneWidget);
});
}