Files
pipelines/app/test/features/runs/run_decisions_test.dart
T

88 lines
2.5 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/domain/run_decisions.dart';
import 'package:pipelines_app/features/runs/domain/run_events.dart';
import 'package:pipelines_app/features/runs/domain/run_models.dart';
void main() {
test(
'scheduled origin is immutable and export pending blocks attention/decision',
() {
final rows = <JsonMap>[
{
'id': 5,
'status': 'waiting',
'scheduled': true,
'schedule_id': 12,
'schedule_name': 'Nightly',
},
];
final changed = foldRunEvent(rows, {
'run_id': 5,
'status': 'waiting',
'scheduled': false,
'schedule_id': 99,
'schedule_name': 'Other',
'export_pending_sequence': 4,
});
expect(changed.runs.single['schedule_id'], 12);
expect(changed.runs.single['schedule_name'], 'Nightly');
expect(changed.runs.single['scheduled'], true);
expect(orderAttention(changed.runs), isEmpty);
expect(
pendingDecision({
...changed.runs.single,
'current_stage': 'human',
'steps': [],
}),
isNull,
);
},
);
test(
'pending decision uses recorded options then graph fallback and target labels',
() {
final run = <String, dynamic>{
'id': 7,
'status': 'waiting',
'current_stage': 'human',
'name': 'Build',
'graph': {
'stages': [
{
'key': 'human',
'type': 'human',
'prompt': 'Graph prompt',
'edges': {'go': '#', 'error': '#', 'skip': 'finish'},
},
],
},
'steps': [
{
'sequence': 1,
'status': 'waiting',
'stage': 'human',
'output': {
'prompt': 'Recorded prompt',
'options': ['go'],
},
},
],
};
final decision = pendingDecision(run)!;
expect(decision.instructions, 'Recorded prompt');
expect(decision.options.map((option) => option.key), ['go']);
expect(decision.options.single.target, 'SUCCESS');
final fallback = pendingDecision({
...run,
'steps': [
{'status': 'waiting', 'stage': 'human', 'output': {}},
],
})!;
expect(fallback.instructions, 'Graph prompt');
expect(fallback.options.map((option) => option.key), ['go', 'skip']);
},
);
}