test(editor): exercise the extract-with-approval flow shape
New test mirrors the most complex shipped example — three-step chain with a system.approval gate in the middle, multi-line prompts containing embedded \$step.field refs, outputs that reference multiple steps. Verifies: - step count + approval flagging - edge detection (8 edges across inputs, steps, outputs) - structural round-trip stability through toYaml() / fromYaml() If this test stays green, the editor is safe on every flow currently shipped under flows/. 12/12 pass. Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
parent
f8138f3516
commit
ad2e5b50d5
1 changed files with 61 additions and 0 deletions
|
|
@ -183,5 +183,66 @@ steps:
|
||||||
expect(graph.steps.first.use, 'debug.echo@^0');
|
expect(graph.steps.first.use, 'debug.echo@^0');
|
||||||
expect(updated.steps.first.use, 'debug.echo@^1');
|
expect(updated.steps.first.use, 'debug.echo@^1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('handles the extract-with-approval shape (multi-step + approval)', () {
|
||||||
|
// Same shape as the shipped example flow — three
|
||||||
|
// steps, one of which is the system.approval gate,
|
||||||
|
// multi-line prompt with embedded \$step.field refs,
|
||||||
|
// outputs that reference multiple steps. If this
|
||||||
|
// round-trips structurally the editor is safe on the
|
||||||
|
// most complex shipped flow.
|
||||||
|
const yaml = '''
|
||||||
|
name: extract-with-approval
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
document: bytes
|
||||||
|
llm_endpoint: text
|
||||||
|
llm_model: text
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- id: extract
|
||||||
|
use: text.extract@^0
|
||||||
|
with:
|
||||||
|
document: \$inputs.document
|
||||||
|
|
||||||
|
- id: review
|
||||||
|
use: system.approval@^0
|
||||||
|
with:
|
||||||
|
prompt: "Approve before sending to the LLM."
|
||||||
|
show: \$extract.extracted
|
||||||
|
|
||||||
|
- id: summarize
|
||||||
|
use: llm.chat@^0
|
||||||
|
with:
|
||||||
|
prompt: "Summarise: \$extract.extracted"
|
||||||
|
endpoint: \$inputs.llm_endpoint
|
||||||
|
model: \$inputs.llm_model
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
extracted: \$extract.extracted
|
||||||
|
approved_by: \$review.decided_by
|
||||||
|
summary: \$summarize.response
|
||||||
|
''';
|
||||||
|
final graph = FlowGraph.fromYaml(yaml);
|
||||||
|
expect(graph.steps, hasLength(3));
|
||||||
|
expect(graph.steps[1].isApproval, isTrue);
|
||||||
|
// Edges: 4 input wires + 3 output wires = 7
|
||||||
|
// - inputs.document -> extract.document
|
||||||
|
// - extract.extracted -> review.show
|
||||||
|
// - extract.extracted -> summarize.prompt
|
||||||
|
// - inputs.llm_endpoint -> summarize.endpoint
|
||||||
|
// - inputs.llm_model -> summarize.model
|
||||||
|
// - extract.extracted -> outputs.extracted
|
||||||
|
// - review.decided_by -> outputs.approved_by
|
||||||
|
// - summarize.response -> outputs.summary
|
||||||
|
// (8 edges total)
|
||||||
|
expect(graph.edges.length, greaterThanOrEqualTo(8));
|
||||||
|
// Round-trip stability: parse, emit, re-parse — same
|
||||||
|
// structural shape.
|
||||||
|
final round = FlowGraph.fromYaml(graph.toYaml());
|
||||||
|
expect(round.steps.map((s) => s.id), graph.steps.map((s) => s.id));
|
||||||
|
expect(round.outputs.keys, graph.outputs.keys);
|
||||||
|
expect(round.edges.length, graph.edges.length);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue