Merge branch 'main' into flutter/chat-thread

This commit is contained in:
2026-10-21 20:04:40 +01:00
25 changed files with 1906 additions and 218 deletions
@@ -128,6 +128,32 @@ void main() {
expect(find.text('Alpha review'), findsOneWidget);
});
testWidgets('embedded framing adds no bar and keeps a content refresh', (
tester,
) async {
final fixture = PipelineFixture();
final gateway = gatewayFor(fixture);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Host bar')),
body: PipelinesScreen(gateway: gateway, embedded: true),
),
),
);
await tester.pumpAndSettle();
expect(find.byType(AppBar), findsOneWidget);
expect(find.text('Host bar'), findsOneWidget);
expect(find.text('Pipelines'), findsNothing);
expect(find.text('Alpha review'), findsOneWidget);
final lists = gateway.callsOf('list_pipelines').length;
await tester.tap(find.byTooltip('Refresh'));
await tester.pumpAndSettle();
expect(gateway.callsOf('list_pipelines').length, lists + 1);
});
testWidgets('graph tab states it is pending without a hook', (tester) async {
final fixture = PipelineFixture();
await pumpWide(tester, gatewayFor(fixture));
@@ -0,0 +1,93 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
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/actions/cancel_wording.dart';
import 'package:pipelines_app/features/runs/screen.dart';
class _Gateway implements ApiGateway {
final events = StreamController<JsonMap>.broadcast();
final requests = <({String type, JsonMap fields})>[];
final canceled = Completer<JsonMap>();
final JsonMap run = {
'id': 7,
'title': 'Controlled run',
'name': 'fixture',
'status': 'running',
'executing': true,
'steps': <JsonMap>[],
};
@override
Stream<JsonMap> get frames => events.stream;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
requests.add((type: type, fields: fields));
return switch (type) {
'list_runs' => Future.value({
'runs': [Map.of(run)],
}),
'get_run' => Future.value({'run_detail': Map.of(run)}),
'cancel_run' => canceled.future,
_ => Future.error(UnsupportedError(type)),
};
}
}
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'actual detail confirms cancel and folds accepted state ($cupertino)',
(tester) async {
final gateway = _Gateway();
addTearDown(gateway.events.close);
final screen = RunsScreen(gateway: gateway, initialRunId: 7);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
: MaterialApp(home: Scaffold(body: screen)),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(cancelActionKey));
await tester.pumpAndSettle();
expect(find.text('Cancel run 7?'), findsOneWidget);
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
await tester.tap(find.byKey(cancelKeepKey));
await tester.pumpAndSettle();
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
await tester.tap(find.byKey(cancelActionKey));
await tester.pumpAndSettle();
await tester.tap(find.byKey(cancelConfirmKey));
await tester.pump();
expect(
gateway.requests.where((r) => r.type == 'cancel_run').single.fields,
{'run_id': 7},
);
expect(find.text('canceled'), findsNothing);
gateway.canceled.complete({
'run_detail': {
...gateway.run,
'status': 'canceled',
'executing': false,
},
});
await tester.pumpAndSettle();
expect(find.byKey(cancelActionKey), findsNothing);
expect(find.text('canceled'), findsOneWidget);
await tester.tap(find.text(cupertino ? 'Back' : 'Back to list'));
await tester.pumpAndSettle();
expect(
find.textContaining('canceled'),
findsWidgets,
reason:
'The accepted server state must also update the held list row',
);
await tester.pumpWidget(const SizedBox.shrink());
},
);
}
}