Files
pipelines/app/test/shell/split_detail_pages_test.dart
T
alan 9bdabb32d9 Remove Cupertino shell branches
Keep the Material-only shell path while preserving public cupertino parameters for callers. Narrow matching tests to Material hosts and behavior because the app always runs under MaterialApp.
2026-11-11 03:48:41 +00:00

131 lines
5.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.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/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import '../features/runs/ui/run_detail_graph_support.dart';
import '../features/runs/ui/run_detail_visit_support.dart';
/// On a wide split window (unfolded foldable, desktop) the real run detail
/// and the stage page it opens keep the shell's tab bar at the bottom left
/// and float their own tabs above it with a gap; the stage page opens inside
/// the detail pane instead of covering the shell.
void main() {
Rect pillOf(WidgetTester tester, Finder owner) => tester.getRect(
find.descendant(
of: owner,
matching: find.byKey(FloatingDestinationBar.rowKey),
),
);
Rect shellPill(WidgetTester tester) => tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byKey(FloatingDestinationBar.rowKey),
)
.first,
);
Future<void> pumpSplitRun(WidgetTester tester) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = RunDetailFakeGateway(visitRunFixture());
final controller = RunsController(RunsRepository(gateway));
addTearDown(controller.dispose);
await controller.select(77);
final shell = AdaptiveShell(
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => ListDetailPanes(
list: ListView(
children: [for (var i = 0; i < 30; i++) Text('run row $i')],
),
detail: DetailPane(
destination: AppDestination.runs,
implyBack: false,
builder: (_) => RunDetailView(
controller: controller,
gateway: gateway,
onBack: () {},
),
),
),
},
);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: shell,
),
);
await tester.pumpAndSettle();
}
testWidgets('1200: run tabs float at the pane\'s bottom beside the '
'shell bar under the list, and the stage page opens in the pane', (
tester,
) async {
await pumpSplitRun(tester);
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
final list = tester.getRect(find.byKey(const ValueKey('list-detail-list')));
var main = shellPill(tester);
expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5));
expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs')));
expect(runTabs.left, greaterThanOrEqualTo(body.left));
expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(runTabs.overlaps(main), isFalse);
expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
// Open the stage page from the timeline.
await openRunDetailTab(tester, RunDetailTab.timeline);
final row = find.byKey(const ValueKey('run-timeline-visit-1'));
await tester.ensureVisible(row);
await tester.pumpAndSettle();
await tester.tap(row);
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
// The page covers only the detail pane: the root navigator has nothing
// pushed, and the list and the shell's tab bar stay in place.
expect(
tester.state<NavigatorState>(find.byType(Navigator).first).canPop(),
isFalse,
);
expect(find.text('run row 0'), findsOneWidget);
final back = tester.getRect(find.byKey(const Key('run-visit-back')));
expect(back.left, greaterThanOrEqualTo(body.left));
main = shellPill(tester);
expect(main.left, closeTo(list.left + kFloatingBarMargin, 0.5));
final visitTabs = pillOf(
tester,
find.byKey(const Key('run-visit-tabs')).last,
);
expect(visitTabs.left, greaterThanOrEqualTo(body.left));
expect(visitTabs.overlaps(main), isFalse);
expect(visitTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(tester.takeException(), isNull);
// The shell's tabs still work over the open stage page.
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
// Back closes the page inside the pane, back to the run.
await tester.tap(find.byKey(const Key('run-visit-back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsNothing);
expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget);
});
}