364fd5b538
Keep the Material-only run action behavior while preserving public Cupertino parameters for callers that will be cleaned up separately. Narrow the related tests to the supported Material path.
122 lines
3.7 KiB
Dart
122 lines
3.7 KiB
Dart
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/actions/decision_wording.dart';
|
|
import 'package:pipelines_app/features/runs/screen.dart';
|
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
|
|
|
class _DecisionGateway implements ApiGateway {
|
|
final events = StreamController<JsonMap>.broadcast();
|
|
final decisions = <JsonMap>[];
|
|
final reply = Completer<JsonMap>();
|
|
final JsonMap run = {
|
|
'id': 9,
|
|
'title': 'Human checkpoint',
|
|
'name': 'fixture',
|
|
'status': 'waiting',
|
|
'executing': false,
|
|
'current_stage': 'gate',
|
|
'graph': {
|
|
'stages': [
|
|
{
|
|
'key': 'gate',
|
|
'type': 'human',
|
|
'edges': {'approve': '#success'},
|
|
},
|
|
],
|
|
},
|
|
'steps': [
|
|
{
|
|
'sequence': 1,
|
|
'stage': 'gate',
|
|
'status': 'waiting',
|
|
'output': {
|
|
'prompt': 'Please review this recorded checkpoint.',
|
|
'options': ['approve'],
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
@override
|
|
Stream<JsonMap> get frames => events.stream;
|
|
@override
|
|
Future<JsonMap> call(String type, [JsonMap fields = const {}]) =>
|
|
switch (type) {
|
|
'list_runs' => Future.value({
|
|
'runs': [run],
|
|
}),
|
|
'get_run' => Future.value({'run_detail': run}),
|
|
'decide_run' => _decide(fields),
|
|
_ => Future.error(UnsupportedError(type)),
|
|
};
|
|
Future<JsonMap> _decide(JsonMap fields) {
|
|
decisions.add(fields);
|
|
return reply.future;
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('actual detail exposes and confirms recorded decision', (
|
|
tester,
|
|
) async {
|
|
final gateway = _DecisionGateway();
|
|
addTearDown(gateway.events.close);
|
|
final screen = RunsScreen(gateway: gateway, initialRunId: 9);
|
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
|
// The web's decision banner spans the header's glass strip (under
|
|
// the top bar, 12 in from the pane) at the strip's 12px inset, with
|
|
// Decide trailing.
|
|
final banner = tester.getRect(find.byKey(const Key('run-decision-banner')));
|
|
final strip = tester.getRect(
|
|
find.descendant(
|
|
of: find.byKey(const Key('run-detail-header')),
|
|
matching: find.byType(GlassPill),
|
|
),
|
|
);
|
|
final pane = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
|
|
expect(strip.left, pane.left + 12);
|
|
expect(strip.right, pane.right - 12);
|
|
expect(banner.left, strip.left + 12);
|
|
expect(banner.right, strip.right - 12);
|
|
expect(
|
|
tester.getCenter(find.byKey(decisionActionKey)).dx,
|
|
greaterThan(banner.center.dx),
|
|
);
|
|
await tester.tap(find.byKey(decisionActionKey));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.text('Please review this recorded checkpoint.'),
|
|
findsOneWidget,
|
|
);
|
|
await tester.tap(find.text('approve'));
|
|
await tester.enterText(find.byKey(decisionFeedbackKey), ' checked ');
|
|
await tester.pump();
|
|
expect(gateway.decisions, isEmpty);
|
|
await tester.tap(find.text(decisionConfirmLabel));
|
|
await tester.pump();
|
|
expect(gateway.decisions.single, {
|
|
'run_id': 9,
|
|
'stage': 'gate',
|
|
'option': 'approve',
|
|
'feedback': 'checked',
|
|
});
|
|
gateway.reply.complete({
|
|
'run_detail': {
|
|
...gateway.run,
|
|
'status': 'succeeded',
|
|
'executing': false,
|
|
},
|
|
});
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(decisionActionKey), findsNothing);
|
|
expect(find.text(decisionWaitingTitle), findsNothing);
|
|
expect(find.text('succeeded'), findsOneWidget);
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
});
|
|
}
|