fix: React to upstream RC schema changes for form mode elicitation requests (#1164)
Co-authored-by: Nate Barbettini <nate@arcade.dev>
This commit is contained in:
parent
2a55dfd5f2
commit
b59a2bde7d
1 changed files with 91 additions and 42 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
CallToolRequestSchema,
|
||||
CreateMessageRequestSchema,
|
||||
ElicitRequestSchema,
|
||||
ElicitResultSchema,
|
||||
ListRootsRequestSchema,
|
||||
ErrorCode
|
||||
} from '../types.js';
|
||||
|
|
@ -917,6 +918,64 @@ test('should reject form-mode elicitation when client only supports URL mode', a
|
|||
await client.close();
|
||||
});
|
||||
|
||||
test('should reject missing-mode elicitation when client only supports URL mode', async () => {
|
||||
const server = new Server(
|
||||
{
|
||||
name: 'test server',
|
||||
version: '1.0'
|
||||
},
|
||||
{
|
||||
capabilities: {}
|
||||
}
|
||||
);
|
||||
|
||||
const client = new Client(
|
||||
{
|
||||
name: 'test client',
|
||||
version: '1.0'
|
||||
},
|
||||
{
|
||||
capabilities: {
|
||||
elicitation: {
|
||||
url: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const handler = vi.fn().mockResolvedValue({
|
||||
action: 'cancel'
|
||||
});
|
||||
client.setRequestHandler(ElicitRequestSchema, handler);
|
||||
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
await Promise.all([client.connect(clientTransport), server.connect(serverTransport)]);
|
||||
|
||||
await expect(
|
||||
server.request(
|
||||
{
|
||||
method: 'elicitation/create',
|
||||
params: {
|
||||
message: 'Please provide data',
|
||||
requestedSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
username: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ElicitResultSchema
|
||||
)
|
||||
).rejects.toThrow('Client does not support form-mode elicitation requests');
|
||||
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
|
||||
await Promise.all([client.close(), server.close()]);
|
||||
});
|
||||
|
||||
test('should reject URL-mode elicitation when client only supports form mode', async () => {
|
||||
const client = new Client(
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue