2c105074aa
Pure-Dart graph foundation mirroring the current web client: terminal targets and labels, definition edges and nodes with web outcome ordering, recorded run evidence (visited stages, taken routes, current stage and live start), and sequence-ordered stage visit selection with clamping. No layout, widgets, screens or coordinates; fixtures cover linear, diamond, self-loop, repeated visits, mixed outcomes, terminals and missing/malformed evidence.
97 lines
2.4 KiB
Dart
97 lines
2.4 KiB
Dart
import 'package:pipelines_app/core/api_gateway.dart';
|
|
|
|
/// Small, server-shaped fixtures shared by the graph domain tests.
|
|
|
|
JsonMap step({
|
|
int sequence = 0,
|
|
String stage = '',
|
|
String status = 'completed',
|
|
String outcome = '',
|
|
String target = '',
|
|
String startedAt = '',
|
|
Map<String, dynamic>? control,
|
|
}) {
|
|
return <String, dynamic>{
|
|
'sequence': sequence,
|
|
'stage': stage,
|
|
'status': status,
|
|
'outcome': outcome,
|
|
'target': target,
|
|
if (startedAt.isNotEmpty) 'started_at': startedAt,
|
|
'control': ?control,
|
|
};
|
|
}
|
|
|
|
JsonMap stage(
|
|
String key, {
|
|
Map<String, String?> edges = const {},
|
|
bool fallbackError = false,
|
|
String type = 'model',
|
|
}) {
|
|
return <String, dynamic>{
|
|
'key': key,
|
|
'type': type,
|
|
'edges': edges,
|
|
if (fallbackError) 'fallback_error': true,
|
|
};
|
|
}
|
|
|
|
/// plan -> build -> ship, with an implicit failure fallback on plan and an
|
|
/// explicit terminal pair on ship.
|
|
JsonMap linearGraph() => <String, dynamic>{
|
|
'stages': <dynamic>[
|
|
stage(
|
|
'plan',
|
|
edges: <String, String?>{'success': 'build', 'error': '#'},
|
|
fallbackError: true,
|
|
),
|
|
stage('build', edges: <String, String?>{'success': 'ship'}),
|
|
stage(
|
|
'ship',
|
|
edges: <String, String?>{'success': '#success', 'error': '#failure'},
|
|
),
|
|
],
|
|
};
|
|
|
|
/// a fans out to b/c and both converge on d.
|
|
JsonMap diamondGraph() => <String, dynamic>{
|
|
'stages': <dynamic>[
|
|
stage(
|
|
'a',
|
|
edges: <String, String?>{'success': 'b', 'approved': 'c', 'error': '#'},
|
|
fallbackError: true,
|
|
),
|
|
stage('b', edges: <String, String?>{'success': 'd'}),
|
|
stage('c', edges: <String, String?>{'success': 'd'}),
|
|
stage('d', edges: <String, String?>{'success': '#success'}),
|
|
],
|
|
};
|
|
|
|
/// a retries itself and can still succeed into b; terminal pair on b.
|
|
JsonMap selfLoopGraph() => <String, dynamic>{
|
|
'stages': <dynamic>[
|
|
stage('a', edges: <String, String?>{'success': 'b', 'retry': 'a'}),
|
|
stage(
|
|
'b',
|
|
edges: <String, String?>{'success': '#success', 'error': '#failure'},
|
|
),
|
|
],
|
|
};
|
|
|
|
/// A definition with an absent edge, an empty target and an unknown target.
|
|
JsonMap incompleteGraph() => <String, dynamic>{
|
|
'stages': <dynamic>[
|
|
stage(
|
|
'a',
|
|
edges: <String, String?>{
|
|
'success': null,
|
|
'blocked': '',
|
|
'retry': 'ghost',
|
|
'error': '#',
|
|
},
|
|
fallbackError: true,
|
|
),
|
|
stage('b', edges: <String, String?>{'success': '#success'}),
|
|
],
|
|
};
|