feat(app): start a pipeline from the detail view
Native Run action opens the web's prompt/workspace/notify dialog, sends the exact run_pipeline body against the pinned resolved version with one request key per confirmed attempt, keeps refusals in the dialog, reconciles a lost reply by key, and opens only the server-named run through the existing run route with one fresh Runs list read. Adds a shared failure-reason helper so operators never see Dart runtime prefixes, and records the slice boundary in notes/P3-run.md.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import 'dart:async';
|
||||
|
||||
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';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final listRequests = <Completer<JsonMap>>[];
|
||||
final detailRequests = <num>[];
|
||||
|
||||
@override
|
||||
Stream<JsonMap> get frames => const Stream.empty();
|
||||
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
||||
if (type == 'list_runs') {
|
||||
final request = Completer<JsonMap>();
|
||||
listRequests.add(request);
|
||||
return request.future;
|
||||
}
|
||||
if (type == 'get_run') {
|
||||
detailRequests.add(fields['run_id'] as num);
|
||||
return Completer<JsonMap>().future;
|
||||
}
|
||||
return Future.error(UnsupportedError(type));
|
||||
}
|
||||
}
|
||||
|
||||
Widget _screen(_Gateway gateway, int token) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunsScreen(gateway: gateway, listRefreshToken: token),
|
||||
),
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('an accepted launch invalidates a mounted list with one fresh '
|
||||
'read and no detail read', (tester) async {
|
||||
final gateway = _Gateway();
|
||||
await tester.pumpWidget(_screen(gateway, 0));
|
||||
await tester.pump();
|
||||
expect(gateway.listRequests, hasLength(1));
|
||||
gateway.listRequests[0].complete({
|
||||
'runs': [
|
||||
{'id': 1, 'title': 'Old run', 'status': 'succeeded'},
|
||||
],
|
||||
});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.text('Old run'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(_screen(gateway, 1));
|
||||
await tester.pump();
|
||||
expect(gateway.listRequests, hasLength(2));
|
||||
// No row is invented while the fresh read is outstanding.
|
||||
expect(find.text('New run'), findsNothing);
|
||||
gateway.listRequests[1].complete({
|
||||
'runs': [
|
||||
{'id': 2, 'title': 'New run', 'status': 'running'},
|
||||
{'id': 1, 'title': 'Old run', 'status': 'succeeded'},
|
||||
],
|
||||
});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('New run'), findsOneWidget);
|
||||
expect(gateway.listRequests, hasLength(2));
|
||||
expect(gateway.detailRequests, isEmpty);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user