Add labelled run entry points

Make starting runs discoverable from pipeline details and the Runs tab. Share the existing launch flow, add an active-pipeline picker, and update walkthrough guidance with focused widget coverage.
This commit is contained in:
2026-11-12 10:53:09 +00:00
parent 24618964ce
commit fc86a8257c
14 changed files with 820 additions and 153 deletions
@@ -604,4 +604,28 @@ void main() {
expect(find.text('Nightly review'), findsWidgets);
expect(launches, 0);
});
testWidgets('the labelled Run button on the detail starts the flow', (
tester,
) async {
final fixture = PipelineFixture();
final navigated = <int>[];
final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(79));
await pumpScreen(tester, gateway, navigated);
await openDetail(tester);
final run = find.byKey(runPipelineActionKey);
expect(
find.descendant(of: run, matching: find.text(runPipelineActionLabel)),
findsOneWidget,
);
await tester.tap(run);
await tester.pumpAndSettle();
await fillFields(tester);
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
expect(gateway.callsOf('run_pipeline'), hasLength(1));
expect(navigated, [79]);
});
}
+206
View File
@@ -0,0 +1,206 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import '../../pipelines/fixtures.dart';
JsonMap _acceptedRun(int id) => {
'type': 'run',
'run_detail': {'id': id, 'status': 'running', 'title': 'Run $id'},
};
/// Pipelines for the picker: the fixture's three active ones plus one archived
/// pipeline, which must never be offered for a new run.
List<Map<String, dynamic>> _pipelines(PipelineFixture fixture) => [
...fixture.summaries,
{
...pipelineSummary(id: 4, name: 'Retired build'),
'archived_at': '2026-10-01T10:00:00',
},
];
FakeGateway _gateway(PipelineFixture fixture, {required int launchedRunId}) =>
FakeGateway(
(type, fields) => switch (type) {
'list_runs' => runListReply(fixture.runs),
'list_pipelines' => pipelineListReply(_pipelines(fixture)),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'chat_directories' => {
'type': 'chat_directories',
'chat_directories': ['/work/recent'],
},
'run_pipeline' => _acceptedRun(launchedRunId),
_ => errorReply('unexpected $type'),
},
);
/// Pumps the Runs screen. With [withNavigationBar] the screen sits in a
/// scaffold with `extendBody` and a bottom NavigationBar, as the shell does on
/// a phone, so the body scrolls under the bar.
Future<void> _pumpRuns(
WidgetTester tester,
FakeGateway gateway, {
required Size size,
required List<int> selected,
bool withNavigationBar = false,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = RunsScreen(gateway: gateway, onRunSelected: selected.add);
await tester.pumpWidget(
MaterialApp(
home: withNavigationBar
? Scaffold(
extendBody: true,
body: screen,
bottomNavigationBar: NavigationBar(
selectedIndex: 0,
onDestinationSelected: (_) {},
destinations: const [
NavigationDestination(
icon: Icon(Icons.play_arrow),
label: 'Runs',
),
NavigationDestination(
icon: Icon(Icons.settings),
label: 'Settings',
),
],
),
)
: Scaffold(body: screen),
),
);
await tester.pumpAndSettle();
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({});
for (final size in const [Size(430, 900), Size(1100, 900)]) {
testWidgets('New run is labelled on the Runs list at ${size.width} wide', (
tester,
) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
await _pumpRuns(tester, gateway, size: size, selected: []);
final button = find.byKey(const Key('runs-new-run'));
expect(button, findsOneWidget);
expect(
find.descendant(of: button, matching: find.text('New run')),
findsOneWidget,
);
});
}
testWidgets('New run clears the bottom bar and opens the picker on a phone', (
tester,
) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
await _pumpRuns(
tester,
gateway,
size: const Size(430, 900),
selected: [],
withNavigationBar: true,
);
final button = find.byKey(const Key('runs-new-run'));
final bar = find.byType(NavigationBar);
expect(button, findsOneWidget);
// The button sits wholly above the bar, not beneath it.
expect(
tester.getRect(button).bottom,
lessThanOrEqualTo(tester.getRect(bar).top),
);
// A tap at the button reaches the button, not the bar behind it.
await tester.tap(button);
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-run-search')), findsOneWidget);
});
testWidgets(
'New run picks an active pipeline, starts it and opens the new run',
(tester) async {
final fixture = PipelineFixture();
final gateway = _gateway(fixture, launchedRunId: 91);
final selected = <int>[];
await _pumpRuns(
tester,
gateway,
size: const Size(1100, 900),
selected: selected,
);
await tester.tap(find.byKey(const Key('runs-new-run')));
await tester.pumpAndSettle();
// The picker lists active pipelines only; the archived one is withheld.
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsOneWidget);
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
expect(find.byKey(const ValueKey('new-run-pipeline-4')), findsNothing);
// Search narrows the list by name.
await tester.enterText(find.byKey(const Key('new-run-search')), 'beta');
await tester.pump();
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsNothing);
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('new-run-pipeline-2')));
await tester.pumpAndSettle();
// The chosen pipeline's latest version is read, then the start dialog
// opens for it: the same flow as the pipeline's own Run action.
expect(gateway.callsOf('get_pipeline').single.fields, {
'pipeline_id': 2,
'version': 0,
});
await tester.enterText(
find.byKey(runPipelinePromptKey),
'Ship the beta.',
);
await tester.enterText(find.byKey(runPipelineWorkspaceKey), '/work/beta');
await tester.pump();
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
final launch = gateway.callsOf('run_pipeline').single.fields;
expect(launch['pipeline_id'], 2);
expect(launch['version'], 1);
expect(selected, [91]);
},
);
testWidgets('dismissing the picker starts nothing', (tester) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
final selected = <int>[];
await _pumpRuns(
tester,
gateway,
size: const Size(430, 900),
selected: selected,
);
await tester.tap(find.byKey(const Key('runs-new-run')));
await tester.pumpAndSettle();
await tester.tapAt(const Offset(4, 4));
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-run-search')), findsNothing);
expect(gateway.callsOf('get_pipeline'), isEmpty);
expect(gateway.callsOf('run_pipeline'), isEmpty);
expect(selected, isEmpty);
});
}
@@ -4,6 +4,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
/// The list's row titles only: the New run button carries the same words.
Finder _rowTitled(String title) =>
find.descendant(of: find.byType(RunsList), matching: find.text(title));
class _Gateway implements ApiGateway {
final listRequests = <Completer<JsonMap>>[];
@@ -53,7 +58,7 @@ void main() {
await tester.pump();
expect(gateway.listRequests, hasLength(2));
// No row is invented while the fresh read is outstanding.
expect(find.text('New run'), findsNothing);
expect(_rowTitled('New run'), findsNothing);
gateway.listRequests[1].complete({
'runs': [
{'id': 2, 'title': 'New run', 'status': 'running'},
@@ -63,7 +68,7 @@ void main() {
await tester.pump();
await tester.pump();
expect(find.text('New run'), findsOneWidget);
expect(_rowTitled('New run'), findsOneWidget);
expect(gateway.listRequests, hasLength(2));
expect(gateway.detailRequests, isEmpty);
});