|
5 | 5 | * `{resourceId}` variable. |
6 | 6 | */ |
7 | 7 | import { afterEach, beforeEach, describe, expect, it } from "vitest"; |
8 | | -import { connect, textOf, type Session } from "./harness.js"; |
| 8 | +import { connect, connectModern, textOf, type Session } from "./harness.js"; |
| 9 | +import { |
| 10 | + RESOURCE_TYPE_BLOB, |
| 11 | + RESOURCE_TYPE_TEXT, |
| 12 | +} from "../resources/templates.js"; |
9 | 13 |
|
10 | 14 | let session: Session; |
11 | 15 |
|
@@ -235,3 +239,48 @@ describe("completion/complete for resource templates", () => { |
235 | 239 | expect(completion.values).toEqual(expected); |
236 | 240 | }); |
237 | 241 | }); |
| 242 | + |
| 243 | +/** |
| 244 | + * Prompt arguments carry no JSON Schema over the wire, only a name, a |
| 245 | + * description and `required`, so the description is the one place a client |
| 246 | + * can learn what an argument accepts (#3985). Checked in both eras, since each |
| 247 | + * is served by its own code path. |
| 248 | + */ |
| 249 | +describe.each([ |
| 250 | + ["2025-era", connect], |
| 251 | + ["2026-07-28", connectModern], |
| 252 | +])("prompts/list argument descriptions (%s)", (_era, open) => { |
| 253 | + let listed: Session; |
| 254 | + |
| 255 | + beforeEach(async () => { |
| 256 | + listed = await open(); |
| 257 | + }); |
| 258 | + |
| 259 | + afterEach(async () => { |
| 260 | + await listed.close(); |
| 261 | + }); |
| 262 | + |
| 263 | + it("describes every argument of every prompt", async () => { |
| 264 | + const { prompts } = await listed.client.listPrompts(); |
| 265 | + const undescribed = prompts.flatMap((prompt) => |
| 266 | + (prompt.arguments ?? []) |
| 267 | + .filter((argument) => !argument.description?.trim()) |
| 268 | + .map((argument) => `${prompt.name}.${argument.name}`), |
| 269 | + ); |
| 270 | + expect(undescribed).toEqual([]); |
| 271 | + }); |
| 272 | + |
| 273 | + it("names resource-prompt's allowed values in its argument descriptions", async () => { |
| 274 | + const { prompts } = await listed.client.listPrompts(); |
| 275 | + const prompt = prompts.find((p) => p.name === "resource-prompt"); |
| 276 | + const descriptionOf = (name: string) => |
| 277 | + prompt?.arguments?.find((argument) => argument.name === name) |
| 278 | + ?.description; |
| 279 | + expect(descriptionOf("resourceType")).toBe( |
| 280 | + `Type of resource to fetch. Must be "${RESOURCE_TYPE_TEXT}" or "${RESOURCE_TYPE_BLOB}".`, |
| 281 | + ); |
| 282 | + expect(descriptionOf("resourceId")).toBe( |
| 283 | + "ID of the resource to fetch. Must be a positive integer (1 or greater).", |
| 284 | + ); |
| 285 | + }); |
| 286 | +}); |
0 commit comments