test: add App → AppBridge integration test for downloadFile

This commit is contained in:
Anton Pidkuiko MacBook 2026-02-24 16:57:18 +00:00
commit 9340bd800e
No known key found for this signature in database

View file

@ -712,6 +712,36 @@ describe("App <-> AppBridge integration", () => {
expect(result.content).toEqual(resultContent);
});
it("ondownloadfile setter registers handler for ui/download-file requests", async () => {
const downloadParams = {
contents: [
{
type: "resource" as const,
resource: {
uri: "file:///export.json",
mimeType: "application/json",
text: '{"key":"value"}',
},
},
],
};
const receivedRequests: unknown[] = [];
bridge.ondownloadfile = async (params) => {
receivedRequests.push(params);
return {};
};
await bridge.connect(bridgeTransport);
await app.connect(appTransport);
const result = await app.downloadFile(downloadParams);
expect(receivedRequests).toHaveLength(1);
expect(receivedRequests[0]).toMatchObject(downloadParams);
expect(result).toEqual({});
});
it("callServerTool throws a helpful error when called with a string instead of params object", async () => {
await bridge.connect(bridgeTransport);
await app.connect(appTransport);