From e938f1c6ae619d2849868f44580ce3f6df66408d Mon Sep 17 00:00:00 2001 From: c <37263590+Aphroq@users.noreply.github.com> Date: Fri, 1 May 2026 14:34:27 +0000 Subject: [PATCH] test(agent): expand graph query regression fixture --- .../agent/tools/query_knowledge_graph_test.go | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/internal/agent/tools/query_knowledge_graph_test.go b/internal/agent/tools/query_knowledge_graph_test.go index fa8239d1..4807b62c 100644 --- a/internal/agent/tools/query_knowledge_graph_test.go +++ b/internal/agent/tools/query_knowledge_graph_test.go @@ -99,28 +99,53 @@ func TestQueryKnowledgeGraph_ReportsConfiguredEntityAndRelationTypes(t *testing. Enabled: true, Nodes: []*types.GraphNode{ {Name: "合同"}, - {Name: "部门"}, + {Name: "法务部门"}, + {Name: "审批流程"}, + {Name: "合同"}, + nil, + {Name: ""}, }, Relations: []*types.GraphRelation{ {Type: "属于"}, {Type: "管理"}, + {Type: "审批"}, + {Type: "管理"}, + {Type: ""}, + nil, }, }, }, results: []*types.SearchResult{ { - ID: "chunk-1", - Content: "合同管理流程由法务部门负责。", - KnowledgeID: "doc-1", - KnowledgeTitle: "合同管理制度", - Score: 0.91, + ID: "chunk-approval-1", + Content: "合同审批流程由法务部门与采购部门共同维护,法务部门负责合规审查。", + KnowledgeID: "doc-approval", + KnowledgeTitle: "合同审批管理制度", + Score: 0.97, + MatchType: types.MatchTypeEmbedding, + }, + { + ID: "chunk-approval-2", + Content: "采购申请提交后进入合同审批流程,审批完成后归档到合同台账。", + KnowledgeID: "doc-procurement", + KnowledgeTitle: "采购与合同协作规范", + Score: 0.89, + MatchType: types.MatchTypeKeywords, + }, + { + ID: "chunk-approval-3", + Content: "法务部门管理标准合同模板,并维护合同风险审查清单。", + KnowledgeID: "doc-legal", + KnowledgeTitle: "法务部职责说明", + Score: 0.84, + MatchType: types.MatchTypeEmbedding, }, }, }) args, err := json.Marshal(QueryKnowledgeGraphInput{ KnowledgeBaseIDs: []string{"kb-1"}, - Query: "合同管理", + Query: "合同审批与法务协作", }) require.NoError(t, err) @@ -130,15 +155,23 @@ func TestQueryKnowledgeGraph_ReportsConfiguredEntityAndRelationTypes(t *testing. require.True(t, result.Success) t.Logf("tool output:\n%s", result.Output) - assert.Contains(t, result.Output, "Entity Types (2)") - assert.Contains(t, result.Output, "Relationship Types (2)") + assert.Contains(t, result.Output, "Entity Types (3)") + assert.Contains(t, result.Output, "Relationship Types (3)") assert.NotContains(t, result.Output, "No entity types configured") assert.NotContains(t, result.Output, "No relationship types configured") assert.Contains(t, result.Output, "合同") + assert.Contains(t, result.Output, "法务部门") + assert.Contains(t, result.Output, "审批流程") assert.Contains(t, result.Output, "管理") + assert.Contains(t, result.Output, "审批") + assert.Contains(t, result.Output, "✓ Found 3 relevant results (deduplicated)") + assert.Contains(t, result.Output, "Result #1:") + assert.Contains(t, result.Output, "Result #2:") + assert.Contains(t, result.Output, "Result #3:") + assert.Contains(t, result.Output, "合同审批管理制度") graphConfig, ok := result.Data["graph_config"].(map[string]interface{}) require.True(t, ok) - assert.ElementsMatch(t, []string{"合同", "部门"}, graphConfig["nodes"]) - assert.ElementsMatch(t, []string{"属于", "管理"}, graphConfig["relations"]) + assert.ElementsMatch(t, []string{"合同", "审批流程", "法务部门"}, graphConfig["nodes"]) + assert.ElementsMatch(t, []string{"属于", "审批", "管理"}, graphConfig["relations"]) }