From ad2e5b50d5201c9b97329b02e2223d6e599545f1 Mon Sep 17 00:00:00 2001 From: flemming-it Date: Mon, 1 Jun 2026 02:01:46 +0200 Subject: [PATCH] test(editor): exercise the extract-with-approval flow shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- test/flow_graph_test.dart | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/test/flow_graph_test.dart b/test/flow_graph_test.dart index 1c8a638..16c84c3 100644 --- a/test/flow_graph_test.dart +++ b/test/flow_graph_test.dart @@ -183,5 +183,66 @@ steps: expect(graph.steps.first.use, 'debug.echo@^0'); 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); + }); }); }