MCPcopy
hub / github.com/dosco/graphjin / TestGraphQLHelpTopicsUseCatalogGraphQL

Function TestGraphQLHelpTopicsUseCatalogGraphQL

serv/mcp_catalog_workflow_test.go:83–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestGraphQLHelpTopicsUseCatalogGraphQL(t *testing.T) {
84 ms := workflowCatalogTestServer(t, MCPConfig{}, nil)
85
86 for _, topic := range graphQLHelpTopics() {
87 t.Run(topic, func(t *testing.T) {
88 res, err := ms.handleGraphQLHelp(sourceModeUserTestContext(), newToolRequest(map[string]any{"for": topic}))
89 if err != nil {
90 t.Fatalf("graphql_help: %v", err)
91 }
92 text := assertToolSuccess(t, res)
93 var out GraphQLHelpResult
94 if err := json.Unmarshal([]byte(text), &out); err != nil {
95 t.Fatalf("decode graphql_help: %v\n%s", err, text)
96 }
97 if out.For != topic || out.GraphQLQuery == "" || !strings.Contains(out.GraphQLQuery, "gj_catalog") {
98 t.Fatalf("expected graphql query guidance for %s, got %+v", topic, out)
99 }
100 if out.RecommendedFirstQuery == "" {
101 t.Fatalf("expected recommended first query for %s", topic)
102 }
103 if len(out.Bootstrap) == 0 {
104 t.Fatalf("expected bootstrap guidance for %s", topic)
105 }
106 if out.GraphQLVariables == nil {
107 t.Fatalf("expected stable graphql_variables map")
108 }
109 if len(out.CatalogRows) == 0 {
110 t.Fatalf("expected catalog rows for %s", topic)
111 }
112 if out.Next == nil || out.Next.RecommendedTool == "" {
113 t.Fatalf("expected next guidance for %s: %+v", topic, out.Next)
114 }
115 if out.CapabilityProfile == nil {
116 t.Fatalf("expected caller capability_profile for %s", topic)
117 }
118 if !stringSliceContains(out.CapabilityProfile.AvailableTools, "query_catalog") {
119 t.Fatalf("expected query_catalog in capability_profile for %s: %+v", topic, out.CapabilityProfile)
120 }
121 if strings.Contains(text, "app-user") || strings.Contains(text, "app-account") {
122 t.Fatalf("graphql_help leaked plaintext identity values for %s: %s", topic, text)
123 }
124 wantID := "help:" + topic
125 foundHelp := false
126 for _, row := range out.CatalogRows {
127 if row.ID == wantID {
128 foundHelp = true
129 break
130 }
131 }
132 if !foundHelp {
133 t.Fatalf("expected %s in graphql_help rows: %+v", wantID, out.CatalogRows)
134 }
135 if topic == "discovery" {
136 if len(out.TopicRoutes) == 0 || len(out.ReplacesTools) == 0 {
137 t.Fatalf("expected discovery help to include topic routes and replacement map: %+v", out)
138 }
139 foundMCPTools := false
140 foundOldTool := false

Callers

nothing calls this directly

Calls 7

graphQLHelpTopicsFunction · 0.85
newToolRequestFunction · 0.85
assertToolSuccessFunction · 0.85
stringSliceContainsFunction · 0.85
handleGraphQLHelpMethod · 0.80

Tested by

no test coverage detected