test(agent-service): cover WorkflowState logical-plan, traversal, validation and content methods - #7159
test(agent-service): cover WorkflowState logical-plan, traversal, validation and content methods#7159mengw15 wants to merge 2 commits into
Conversation
…idation and content methods
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7159 +/- ##
============================================
+ Coverage 79.62% 79.96% +0.33%
Complexity 3836 3836
============================================
Files 1160 1160
Lines 46188 46166 -22
Branches 5145 5145
============================================
+ Hits 36777 36916 +139
+ Misses 7778 7617 -161
Partials 1633 1633
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR extends the agent-service unit test suite for WorkflowState’s pure in-memory behaviors (logical plan conversion, traversal helpers, validation state, port updates, and content round-tripping) without changing production code.
Changes:
- Added
toLogicalPlanassertions for operator/link shaping and port-index resolution. - Added traversal tests for
getFrontierOperators(depth)andgetSubDAG(target). - Added tests for validation state mutation/stream emission,
updateOperatorInputPorts, and workflow content round-trip/defaulting.
Suppressed comments (1)
agent-service/src/agent/workflow-state.spec.ts:358
- This test asserts that
updateOperatorInputPortsdoes not prune links that target removed ports. The linked issue #7158 explicitly lists link-pruning as the behavior to cover, and keeping this assertion will make a future correctness fix (pruning invalid links) break the test suite.
If pruning links is the desired behavior, please either update updateOperatorInputPorts to remove links targeting ports that were dropped and then update this test to expect pruning, or avoid closing #7158 and track the behavior gap separately.
test("reducing the count drops the extra ports (links are left untouched)", () => {
const state = new WorkflowState();
state.addOperator(makeOperator("src"));
state.addOperator(
makeOperator("op1", {
inputPorts: [
{ portID: "input-0", displayName: "Input 0" },
{ portID: "input-1", displayName: "Input 1" },
],
})
);
state.addLink({
linkID: "l1",
source: { operatorID: "src", portID: "output-0" },
target: { operatorID: "op1", portID: "input-1" },
});
state.updateOperatorInputPorts("op1", 1);
expect(state.getOperator("op1")!.inputPorts.map(p => p.portID)).toEqual(["input-0"]);
// Observed behavior: the link to the now-removed input-1 is NOT pruned by this method.
expect(state.getAllLinks().map(l => l.linkID)).toEqual(["l1"]);
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…-port link behavior
What changes were proposed in this PR?
Extends the existing
WorkflowStatespec to cover the remaining pure,in-memory methods (
agent-service/src/agent/workflow-state.ts). All aredeterministic; no external services are mocked. No production code was changed.
15 tests, grouped by area:
toLogicalPlan— the produced operators, port-indexed links (indicesresolved from each operator's port list), and the empty reuse list.
getFrontierOperators(depth)returning the leaf set andexpanding one hop upstream per depth (topologically ordered), and
getSubDAGcollecting a target's upstream operators and links.
setValidationError/clearValidationError/setAllValidationErrors/getValidationOutput, theworkflowEmptyflag(no operators, or all disabled), and
getValidationChangedStreamemitting oneach mutation.
updateOperatorInputPorts— rebuilding the input-port list to a requestedcount (extras flagged dynamic), reducing the count, and the missing-operator
guard.
setWorkflowContentreplacing the state andgetWorkflowContentreflecting it, plus the default-settings fallback.Any related issues, documentation, discussions?
Closes #7158
How was this PR tested?
Extended unit tests, run locally in
agent-service/(all green; the failure pathwas verified by breaking an assertion to confirm the suite goes red):
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])