Merge branch 'main' into worktree-agent-a3cb3553b5c91a345

This commit is contained in:
2026-12-03 14:21:22 +00:00
135 changed files with 7973 additions and 443 deletions
@@ -0,0 +1,80 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/graph/domain/check_stage.dart';
import 'package:pipelines_app/features/graph/domain/graph_definition.dart';
import 'package:pipelines_app/features/graph/domain/stage_definition.dart';
Map<String, dynamic> _verify({Map<String, dynamic>? configs}) => {
'key': 'verify',
'type': 'check',
'configs':
configs ??
{
'command_timeout': '15m',
'timeout': '1h',
'keep_going': 'true',
'delivery': 'true',
},
'edges': {'pass': 'review', 'fail': 'implement', 'error': '#failure'},
'blocks': {'commands': 'go vet ./...\n\ngo test ./...\n'},
'prompt': '',
'output': '',
};
void main() {
test('a check stage reads its commands, one per non-blank line', () {
expect(isCheckStage(_verify()), isTrue);
expect(checkCommands(_verify()), ['go vet ./...', 'go test ./...']);
expect(isCheckStage({'type': 'model'}), isFalse);
expect(isCheckStage({'key': 'x'}), isFalse);
});
test('the delivery config marks the gate, and only on a check stage', () {
expect(isDeliveryGate(_verify()), isTrue);
expect(isDeliveryGate(_verify(configs: {'delivery': 'false'})), isFalse);
expect(isDeliveryGate(_verify(configs: {})), isFalse);
expect(
isDeliveryGate({
'type': 'model',
'configs': {'delivery': 'true'},
}),
isFalse,
);
});
test('graph nodes carry the stage type and the gate caption', () {
final nodes = graphNodes({
'stages': [
_verify(),
{
..._verify(configs: {}),
'key': 'lint',
},
{
'key': 'review',
'edges': {'success': '#'},
},
],
});
final byKey = {for (final node in nodes) node.key: node};
expect(byKey['verify']!.kindCaption, 'Delivery gate');
expect(byKey['lint']!.kindCaption, 'Check');
expect(byKey['review']!.kindCaption, isNull);
expect(byKey['#success']!.kindCaption, isNull);
});
test('a check definition lists its commands in place of a prompt', () {
final fields = stageDefinitionFields(_verify());
final byLabel = {for (final field in fields) field.label: field};
expect(byLabel['Type']!.value, 'check (delivery gate)');
final commands = byLabel['Commands']!;
expect(commands.value, 'go vet ./...\ngo test ./...');
expect(commands.monospace, isTrue);
expect(byLabel.containsKey('Prompt'), isFalse);
expect(byLabel['Command timeout']!.value, '15m');
expect(byLabel['Keep going']!.value, 'true');
expect(byLabel['Delivery gate']!.value, 'true');
expect(byLabel['Outcomes']!.value, contains('pass → review'));
expect(byLabel['Outcomes']!.value, contains('fail → implement'));
});
}
@@ -0,0 +1,81 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/graph/domain/graph_definition.dart';
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart';
import 'package:pipelines_app/ui/text/monospace.dart';
Map<String, dynamic> _graph() => {
'stages': [
{
'key': 'verify',
'type': 'check',
'configs': {'delivery': 'true'},
'edges': {'pass': '#', 'fail': 'fix'},
'blocks': {'commands': 'go vet ./...\ngo test ./...'},
},
{
'key': 'fix',
'type': 'model',
'prompt': 'Fix it.',
'edges': {'success': 'verify'},
},
],
};
Widget _host(Widget child) => MaterialApp(
home: Scaffold(body: Center(child: child)),
);
void main() {
testWidgets('a check node shows its kind under its name', (tester) async {
final nodes = {for (final node in graphNodes(_graph())) node.key: node};
await tester.pumpWidget(
_host(
Column(
mainAxisSize: MainAxisSize.min,
children: [
GraphStageNode(node: nodes['verify']!, onSelected: (_) {}),
GraphStageNode(node: nodes['fix']!, onSelected: (_) {}),
],
),
),
);
expect(find.byKey(const ValueKey('graph-node-kind-verify')), findsOne);
expect(find.byKey(const ValueKey('graph-node-kind-fix')), findsNothing);
expect(find.text('Delivery gate'), findsOne);
expect(find.byIcon(Icons.verified_outlined), findsOne);
expect(find.bySemanticsLabel('verify\nDelivery gate'), findsOne);
expect(find.bySemanticsLabel('fix'), findsOne);
expect(tester.takeException(), isNull);
});
testWidgets('a check definition lists its commands in monospace', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: StageDefinitionView(
graph: _graph(),
stageKey: 'verify',
pipelineId: 1,
pipelineName: 'Demo',
version: 3,
),
),
),
);
final commands = tester.widget<SelectableText>(
find.descendant(
of: find.byKey(const ValueKey('stage-definition-Commands')),
matching: find.byType(SelectableText),
),
);
expect(commands.data, 'go vet ./...\ngo test ./...');
expect(commands.style?.fontFamily, appMonospaceFamily);
expect(find.text('check (delivery gate)'), findsOne);
expect(find.text('Prompt'), findsNothing);
});
}