feat(app): on a phone an open pipeline, run or chat is its own page over the tabs

This commit is contained in:
2026-10-23 22:58:49 +01:00
parent 700ba6f820
commit 7cbfbbbb61
8 changed files with 418 additions and 76 deletions
@@ -243,7 +243,7 @@ void main() {
await tester.pageBack();
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Back to pipelines'));
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('pipeline-list')), findsOneWidget);
@@ -282,7 +282,7 @@ void main() {
await tester.pageBack();
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Back to pipelines'));
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
@@ -33,9 +33,12 @@ void main() {
expect(find.byKey(const Key('pipeline-list')), findsNothing);
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
await tester.tap(find.byTooltip('Back to pipelines'));
// The open pipeline is its own page: its bar names it and Back closes it.
expect(find.text('Alpha review'), findsWidgets);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('pipeline-list')), findsOneWidget);
expect(find.byKey(const Key('pipeline-detail')), findsNothing);
});
testWidgets(
@@ -298,4 +298,36 @@ void main() {
},
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
);
testWidgets('on a phone an open run is its own page and Back returns', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
int? selected;
var backs = 0;
await tester.pumpWidget(
_materialScreen(
gateway,
onRunSelected: (id) => selected = id,
onBack: (_) => backs++,
),
);
await _mountList(tester, gateway);
await tester.tap(find.text('Beta run'));
await tester.pump();
expect(selected, 2);
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
await tester.pumpAndSettle();
// The run covers the list as a page with its own Back.
expect(find.text('Alpha run'), findsNothing);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pumpAndSettle();
expect(backs, 1);
expect(find.text('Alpha run'), findsOneWidget);
});
}
+98
View File
@@ -0,0 +1,98 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/detail_page.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
class _Owner extends StatefulWidget {
const _Owner({required this.selection});
final ValueNotifier<String?> selection;
@override
State<_Owner> createState() => _OwnerState();
}
class _OwnerState extends State<_Owner> {
final DetailPageHost page = DetailPageHost();
int closed = 0;
@override
void dispose() {
page.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => ValueListenableBuilder<String?>(
valueListenable: widget.selection,
builder: (context, selected, _) {
page.sync(
context,
selected: selected != null,
destination: AppDestination.runs,
onClosed: () {
closed++;
widget.selection.value = null;
},
builder: (context) =>
ShellBar(title: 'Run $selected', child: Text('detail $selected')),
);
return const Text('the list');
},
);
}
void main() {
testWidgets('a selection opens its page; Back closes it and clears it', (
tester,
) async {
final selection = ValueNotifier<String?>(null);
await tester.pumpWidget(MaterialApp(home: _Owner(selection: selection)));
expect(find.text('the list'), findsOneWidget);
selection.value = '7';
await tester.pumpAndSettle();
// A page of its own over the list, titled by its content.
expect(find.text('detail 7'), findsOneWidget);
expect(find.text('Run 7'), findsOneWidget);
expect(find.text('the list'), findsNothing);
// The open page follows the owner's later state.
selection.value = '8';
await tester.pumpAndSettle();
expect(find.text('detail 8'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pumpAndSettle();
expect(find.text('the list'), findsOneWidget);
expect(selection.value, isNull);
final state = tester.state<_OwnerState>(find.byType(_Owner));
expect(state.closed, 1);
});
testWidgets('a selection cleared elsewhere removes the page', (tester) async {
final selection = ValueNotifier<String?>('3');
await tester.pumpWidget(MaterialApp(home: _Owner(selection: selection)));
await tester.pumpAndSettle();
expect(find.text('detail 3'), findsOneWidget);
selection.value = null;
await tester.pumpAndSettle();
expect(find.text('detail 3'), findsNothing);
expect(find.text('the list'), findsOneWidget);
// Removed by the owner, so nothing is reported back.
expect(tester.state<_OwnerState>(find.byType(_Owner)).closed, 0);
});
testWidgets('the system Back closes the page first', (tester) async {
final selection = ValueNotifier<String?>('5');
await tester.pumpWidget(MaterialApp(home: _Owner(selection: selection)));
await tester.pumpAndSettle();
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
expect(await navigator.maybePop(), isTrue);
await tester.pumpAndSettle();
expect(find.text('the list'), findsOneWidget);
expect(selection.value, isNull);
});
}