TestShouldStripMCPAppsMetadata verifies the spec-conformant strip decision: strip when the feature flag is off, OR when the client explicitly does not advertise the io.modelcontextprotocol/ui extension.
(t *testing.T)
| 2221 | // strip when the feature flag is off, OR when the client explicitly does not |
| 2222 | // advertise the io.modelcontextprotocol/ui extension. |
| 2223 | func TestShouldStripMCPAppsMetadata(t *testing.T) { |
| 2224 | t.Parallel() |
| 2225 | |
| 2226 | tests := []struct { |
| 2227 | name string |
| 2228 | setupCtx func() context.Context |
| 2229 | ffOn bool |
| 2230 | want bool |
| 2231 | }{ |
| 2232 | { |
| 2233 | name: "FF off, capability unknown -> strip", |
| 2234 | setupCtx: context.Background, |
| 2235 | ffOn: false, |
| 2236 | want: true, |
| 2237 | }, |
| 2238 | { |
| 2239 | name: "FF off, capability present -> strip (FF wins)", |
| 2240 | setupCtx: func() context.Context { return ghcontext.WithUISupport(context.Background(), true) }, |
| 2241 | ffOn: false, |
| 2242 | want: true, |
| 2243 | }, |
| 2244 | { |
| 2245 | name: "FF on, capability unknown -> keep", |
| 2246 | setupCtx: context.Background, |
| 2247 | ffOn: true, |
| 2248 | want: false, |
| 2249 | }, |
| 2250 | { |
| 2251 | name: "FF on, capability present -> keep", |
| 2252 | setupCtx: func() context.Context { return ghcontext.WithUISupport(context.Background(), true) }, |
| 2253 | ffOn: true, |
| 2254 | want: false, |
| 2255 | }, |
| 2256 | { |
| 2257 | name: "FF on, capability explicitly absent -> strip", |
| 2258 | setupCtx: func() context.Context { return ghcontext.WithUISupport(context.Background(), false) }, |
| 2259 | ffOn: true, |
| 2260 | want: true, |
| 2261 | }, |
| 2262 | } |
| 2263 | |
| 2264 | for _, tc := range tests { |
| 2265 | t.Run(tc.name, func(t *testing.T) { |
| 2266 | got := shouldStripMCPAppsMetadata(tc.setupCtx(), tc.ffOn) |
| 2267 | require.Equal(t, tc.want, got) |
| 2268 | }) |
| 2269 | } |
| 2270 | } |
nothing calls this directly
no test coverage detected