Merge branch 'worktree-agent-aa9ed772f90c7c7b3'

This commit is contained in:
2026-12-02 20:20:08 +00:00
68 changed files with 1719 additions and 156 deletions
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_fullscreen.dart';
@@ -76,7 +77,13 @@ Future<void> _enter(WidgetTester tester) async {
}
/// A bar control by its Material tooltip.
Finder _named(String name) => find.byTooltip(name);
/// A control named [name]: by its tooltip on desktop, or by its accessible
/// name where touch shows the name as a caption instead.
Finder _named(String name) => find.byWidgetPredicate(
(widget) =>
(widget is Tooltip && widget.message == name) ||
(widget is LabelledIconButton && widget.label == name),
);
void main() {
testWidgets('the bottom actions offer Full screen', (tester) async {
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_body.dart';
import 'package:pipelines_app/features/changes/widgets/diff_form_control.dart';
@@ -56,7 +57,14 @@ void main() {
),
),
);
await tester.tap(find.byTooltip('Details'));
// A tooltip on desktop; a caption under the icon on touch.
await tester.tap(
find.byWidgetPredicate(
(widget) =>
(widget is Tooltip && widget.message == 'Details') ||
(widget is LabelledIconButton && widget.label == 'Details'),
),
);
await tester.pumpAndSettle();
expect(find.text('Recorded artifact facts'), findsOneWidget);
expect(find.byType(Dialog), width >= 600 ? findsOneWidget : findsNothing);
@@ -0,0 +1,116 @@
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/pipelines/pending_run_store.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/run_pipeline_intent.dart';
import 'package:pipelines_app/features/pipelines/run_pipeline_seed.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_version_field.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/features/runs/actions/retry_eligibility.dart';
import 'package:pipelines_app/features/runs/ui/run_again_flow.dart';
import '../../pipelines/fixtures.dart';
import '../../pipelines/ui/run_pipeline_launch_test.dart'
show acceptedRun, launchGateway;
/// Run again: a finished run that did not fail opens the New run form for its
/// pipeline, pre-filled with its prompt, workspace and report requirement,
/// at the latest version with the original offered.
void main() {
JsonMap finished({String status = 'succeeded', bool withInput = true}) => {
'id': 9,
'status': status,
'executing': false,
'pipeline_id': 1,
'version': 1,
'workspace': '/work/alpha',
'output_format': 'markdown',
if (withInput) 'input': {'prompt': 'Ship the release notes.'},
};
test('only finished runs that did not fail can run again', () {
expect(canRunAgain(finished()), isTrue);
expect(canRunAgain(finished(status: 'canceled')), isTrue);
expect(canRunAgain(finished(status: 'interrupted')), isTrue);
expect(canRunAgain(finished(status: 'failed')), isFalse);
expect(canRunAgain(finished()..['executing'] = true), isFalse);
expect(canRunAgain(finished()..remove('pipeline_id')), isFalse);
});
test('the seed carries the run inputs and its version', () {
final seed = runAgainSeed(finished());
expect(seed.prompt, 'Ship the release notes.');
expect(seed.workspace, '/work/alpha');
expect(seed.originalVersion, 1);
expect(seed.outputFormat, RunOutputFormat.markdown);
expect(runPipelineVersionChoices(2, 1), [2, 1]);
expect(runPipelineVersionChoices(2, 2), [2]);
});
testWidgets('the form opens pre-filled at the latest version and can '
'start the original one', (tester) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final launched = <JsonMap>[];
final fixture = PipelineFixture();
final gateway = launchGateway(
fixture,
onLaunch: (fields) {
launched.add(fields);
return acceptedRun(30);
},
onLookup: (_) => {'type': 'run', 'run_detail': finished()},
);
final controller = PipelinesController(
PipelinesRepository(gateway),
pendingRunStore: MemoryPendingRunStore(),
);
addTearDown(controller.dispose);
final started = <int>[];
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) => TextButton(
onPressed: () => startRunAgainFlow(
context: context,
// A list row carries no input: the run is read first.
run: finished(withInput: false),
controller: controller,
gateway: gateway,
onRunStarted: started.add,
),
child: const Text('again'),
),
),
),
);
await tester.tap(find.text('again'));
await tester.pumpAndSettle();
final prompt = tester.widget<TextField>(find.byKey(runPipelinePromptKey));
expect(prompt.controller!.text, 'Ship the release notes.');
final workspace = tester.widget<TextField>(
find.byKey(runPipelineWorkspaceKey),
);
expect(workspace.controller!.text, '/work/alpha');
expect(find.text('Latest (v2)'), findsOneWidget);
await tester.tap(find.byKey(runPipelineVersionKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Original run (v1)').last);
await tester.pumpAndSettle();
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
expect(launched, hasLength(1));
expect(launched.single['pipeline_id'], 1);
expect(launched.single['version'], 1);
expect(launched.single['workspace'], '/work/alpha');
expect(launched.single['input'], {'prompt': 'Ship the release notes.'});
expect(launched.single['output_format'], 'markdown');
expect(started, [30]);
});
}
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'run_detail_graph_support.dart';
@@ -81,7 +82,13 @@ void main() {
final rest = tester.getTopLeft(facts).dy;
expect(rest, greaterThanOrEqualTo(barBottom));
// The tabs float at the bottom over the section.
final tabs = pieceOf(tester, find.byKey(const Key('run-visit-tabs')));
// The labelled row (buttons over their captions) ends above the margin.
final tabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('run-visit-tabs')),
matching: find.byKey(FloatingDestinationBar.rowKey),
),
);
expect(tabs.bottom, 844 - 16);
expect(tester.getRect(summary).bottom, 844);
@@ -97,11 +97,8 @@ void main() {
),
);
final body = find.byKey(const Key('run-detail-tab-body-summary'));
// Sized to its tabs at the right, floating above the bottom.
expect(
pill.width,
FloatingDestinationBar.rowWidth(tabs: renderedRunDetailTabs.length),
);
// Sized to its labelled tabs at the right, floating above the bottom.
expect(pill.width, lessThan(390 * 0.85));
expect(pill.right, 390 - 16);
expect(pill.bottom, 844 - 16);
// The tab's content reaches the bottom edge, behind the bar.
@@ -294,8 +294,8 @@ void main() {
);
expect(pill.right, size.width - 16);
expect(pill.bottom, size.height - 16);
// Sized to its tabs at the right on every width.
expect(pill.width, lessThan(size.width * 0.7));
// Sized to its labelled tabs at the right on every width.
expect(pill.width, lessThan(size.width * 0.8));
},
);
}
@@ -0,0 +1,149 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show SemanticsNode;
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/domain/run_outcome_line.dart';
import 'package:pipelines_app/features/runs/ui/run_again_flow.dart';
import 'package:pipelines_app/features/runs/ui/run_failure_banner.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
JsonMap _run(String status, [JsonMap extra = const {}]) => {
'id': 7,
'title': 'Nightly release',
'name': 'release',
'status': status,
'executing': false,
'pipeline_id': 3,
'created_at': '2026-10-21T12:00:00Z',
'finished_at': '2026-10-21T12:02:05Z',
...extra,
};
class _FakeGateway implements ApiGateway {
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async => {};
@override
Stream<JsonMap> get frames => const Stream.empty();
}
/// A run row says why a run failed (its failure reason, else its
/// diagnostic's first line) in one line with the full text in a tooltip, and
/// a succeeded run's short result; its status is read once.
void main() {
test('the outcome line prefers the failure reason, then the diagnostic', () {
final reason = runOutcomeLine(
_run('failed', {
'failure_reason': 'Stage review timed out',
'diagnostic': 'trace\nmore',
}),
);
expect(reason?.line, 'Stage review timed out');
expect(reason?.failed, isTrue);
final diagnostic = runOutcomeLine(
_run('failed', {'diagnostic': '\n exit status 2\nstack trace'}),
);
expect(diagnostic?.line, 'exit status 2');
expect(diagnostic?.full, 'exit status 2\nstack trace');
expect(runOutcomeLine(_run('failed')), isNull);
expect(
runOutcomeLine(
_run('succeeded', {'result_preview': 'Released 1.2'}),
)?.line,
'Released 1.2',
);
// A long or multi-line preview is left to the detail.
expect(
runOutcomeLine(_run('succeeded', {'result_preview': 'x' * 200})),
isNull,
);
expect(
runOutcomeLine(_run('succeeded', {'result_preview': 'a\nb'})),
isNull,
);
expect(runOutcomeLine(_run('running', {'failure_reason': 'x'})), isNull);
});
Future<void> pumpRow(WidgetTester tester, JsonMap run) async {
tester.view.physicalSize = const Size(800, 400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunListRow(
run: run,
now: DateTime.utc(2026, 10, 22),
gateway: _FakeGateway(),
onRunChanged: (_) {},
onRunAgain: (_) {},
),
),
),
);
await tester.pumpAndSettle();
}
testWidgets('a failed row shows its reason with the full text in a '
'tooltip', (tester) async {
const reason = 'Stage review timed out after 30 minutes';
await pumpRow(tester, _run('failed', {'failure_reason': reason}));
expect(find.text(reason), findsOneWidget);
final tooltip = tester.widget<Tooltip>(
find.byKey(const ValueKey('run-row-outcome-7')),
);
expect(tooltip.message, reason);
});
testWidgets('the row reads its status once', (tester) async {
final semantics = tester.ensureSemantics();
await pumpRow(tester, _run('failed', {'failure_reason': 'Boom'}));
final labels = <String>[];
void collect(SemanticsNode node) {
final data = node.getSemanticsData();
labels.add('${data.label} ${data.tooltip}');
node.visitChildren((child) {
collect(child);
return true;
});
}
collect(tester.getSemantics(find.byType(RunListRow)));
final all = labels.join(' ');
expect(RegExp(r'\bfailed\b').allMatches(all), hasLength(1), reason: all);
semantics.dispose();
});
testWidgets('a succeeded run offers Run again; a failed one does not', (
tester,
) async {
await pumpRow(tester, _run('succeeded'));
await tester.tap(find.byKey(const ValueKey('run-list-more-menu-7')));
await tester.pumpAndSettle();
expect(find.byKey(runAgainActionKey), findsOneWidget);
await tester.tapAt(Offset.zero);
await tester.pumpAndSettle();
await pumpRow(tester, _run('failed', {'failure_reason': 'Boom'}));
await tester.tap(find.byKey(const ValueKey('run-list-more-menu-7')));
await tester.pumpAndSettle();
expect(find.byKey(runAgainActionKey), findsNothing);
});
testWidgets('the Summary leads with why a failed run failed', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunFailureBanner(
run: _run('failed', {'diagnostic': 'exit status 2'}),
),
),
),
);
expect(find.text('Why it failed'), findsOneWidget);
expect(find.text('exit status 2'), findsOneWidget);
await tester.pumpWidget(
MaterialApp(home: RunFailureBanner(run: _run('succeeded'))),
);
expect(find.text('Why it failed'), findsNothing);
});
}
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/settings/settings_phone_order.dart';
import 'package:pipelines_app/features/settings/settings_search_page.dart';
import 'package:pipelines_app/features/settings/settings_section.dart';
SettingsSection _section(String id, String title) => SettingsSection(
id: id,
title: title,
keywords: '',
builder: (_) => SizedBox(height: 400, child: Text('$title body')),
);
/// A phone's Settings lead with Connection and Notifications and offer a
/// "Jump to topic" menu; a wide window keeps its order and index column.
void main() {
final sections = [
_section('interface-size', 'Interface size'),
_section('font', 'Font'),
_section('notifications', 'Notifications'),
_section('connection', 'Connection'),
_section('help', 'Help and about'),
];
test('Connection, then Notifications, lead on a phone', () {
expect(settingsPhoneOrder(sections).map((section) => section.id), [
'connection',
'notifications',
'interface-size',
'font',
'help',
]);
});
Future<void> pumpAt(WidgetTester tester, double width) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(body: SettingsSearchPage(sections: sections)),
),
);
await tester.pumpAndSettle();
}
testWidgets('a phone jumps to a topic from its menu', (tester) async {
await pumpAt(tester, 390);
final connection = tester.getTopLeft(find.text('Connection body')).dy;
final size = tester.getTopLeft(find.text('Interface size body')).dy;
expect(connection, lessThan(size));
await tester.tap(find.byKey(settingsTopicMenuKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Help and about').last);
await tester.pumpAndSettle();
expect(
tester.getTopLeft(find.text('Help and about body')).dy,
lessThan(400),
);
});
testWidgets('a wide window keeps its order and has no topic menu', (
tester,
) async {
await pumpAt(tester, 1300);
expect(find.byKey(settingsTopicMenuKey), findsNothing);
final connection = tester.getTopLeft(find.text('Connection body')).dy;
final size = tester.getTopLeft(find.text('Interface size body')).dy;
expect(size, lessThan(connection));
});
}
@@ -232,6 +232,10 @@ void main() {
await tester.enterText(workspace, ' /srv/pipelines ');
await tester.pump();
// A phone leads with Connection and Notifications, so Save may sit
// below the fold.
await tester.ensureVisible(find.byKey(SettingsKeys.saveWorkspace));
await tester.pump();
await tester.tap(find.byKey(SettingsKeys.saveWorkspace));
await tester.pump();
await tester.pump();
@@ -359,7 +363,9 @@ void main() {
expect(row, findsOneWidget);
expect(
tester
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
.widget<ListTile>(
find.descendant(of: row, matching: find.byType(ListTile)),
)
.enabled,
isTrue,
);
@@ -391,7 +397,9 @@ void main() {
expect(row, findsOneWidget);
expect(
tester
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
.widget<ListTile>(
find.descendant(of: row, matching: find.byType(ListTile)),
)
.enabled,
isFalse,
);
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/walkthrough/first_run_walkthrough.dart';
import 'package:pipelines_app/features/walkthrough/walkthrough_steps.dart';
const _openConnectionKey = ValueKey<String>('walkthrough.open-connection');
/// The walkthrough acts as well as directs: Open Connection on the connect
/// page (skipped once connected) and a labelled Copy command.
void main() {
Future<void> launch(
WidgetTester tester, {
required bool connected,
required VoidCallback onOpenConnection,
}) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) => TextButton(
onPressed: () => showFirstRunWalkthrough(
context,
connected: connected,
onOpenConnection: onOpenConnection,
),
child: const Text('Open'),
),
),
),
),
);
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
}
testWidgets('Open Connection closes the walkthrough and opens it', (
tester,
) async {
var opened = 0;
await launch(tester, connected: false, onOpenConnection: () => opened++);
expect(find.textContaining('enter the Server URL'), findsOneWidget);
await tester.tap(find.byKey(_openConnectionKey));
await tester.pumpAndSettle();
expect(opened, 1);
expect(find.text('Step 1 of 4'), findsNothing);
});
testWidgets('a connected app skips the connect directions', (tester) async {
await launch(tester, connected: true, onOpenConnection: () {});
expect(find.text('Step 1 of 4'), findsOneWidget);
expect(find.textContaining('this app is connected'), findsOneWidget);
expect(find.textContaining('enter the Server URL'), findsNothing);
expect(find.byKey(_openConnectionKey), findsNothing);
expect(walkthroughStepsFor(connected: true), hasLength(4));
});
testWidgets('the harness page labels its copy action', (tester) async {
await launch(tester, connected: true, onOpenConnection: () {});
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.next')));
await tester.pumpAndSettle();
expect(
find.descendant(
of: find.byKey(const ValueKey<String>('walkthrough.copy')),
matching: find.text('Copy command'),
),
findsOneWidget,
);
});
}
@@ -62,8 +62,7 @@ class _HeldStore implements WalkthroughStore {
Future<void> markSeen() => inner.markSeen();
@override
Future<bool> wasOffered(String serverScope) =>
inner.wasOffered(serverScope);
Future<bool> wasOffered(String serverScope) => inner.wasOffered(serverScope);
@override
Future<void> markOffered(String serverScope) =>
@@ -98,7 +97,10 @@ Widget _host({
Future<void> _finishWalkthrough(WidgetTester tester) async {
for (var page = 0; page < 3; page++) {
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.next')));
final next = find.byKey(const ValueKey<String>('walkthrough.next'));
await tester.ensureVisible(next);
await tester.pumpAndSettle();
await tester.tap(next);
await tester.pumpAndSettle();
}
await tester.tap(find.text('Done'));