Skip to content

Commit cce8436

Browse files
test: fix type errors; un-skip implemented tests; delete tests for dropped Protocol surface
1 parent be67283 commit cce8436

2 files changed

Lines changed: 13 additions & 45 deletions

File tree

src/app-bridge.test.ts

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ describe("App <-> AppBridge integration", () => {
235235
expect(receivedContexts).toEqual([{ theme: "dark" }]);
236236
});
237237

238-
it.skip("setHostContext only sends changed values" /* TODO: v2 setHostContext does not diff (send full patch) */, async () => {
238+
it("setHostContext only sends changed values", async () => {
239239
const receivedContexts: unknown[] = [];
240240
app.onhostcontextchanged = (params) => {
241241
receivedContexts.push(params);
@@ -336,7 +336,7 @@ describe("App <-> AppBridge integration", () => {
336336
await newBridgeTransport.close();
337337
});
338338

339-
it.skip("getHostContext accumulates multiple partial updates" /* TODO: investigate accumulate behavior */, async () => {
339+
it("getHostContext accumulates multiple partial updates", async () => {
340340
// Need fresh transports for new bridge
341341
const [newAppTransport, newBridgeTransport] =
342342
InMemoryTransport.createLinkedPair();
@@ -358,11 +358,11 @@ describe("App <-> AppBridge integration", () => {
358358
await newApp.connect(newAppTransport);
359359

360360
// Send partial update: only theme changes
361-
newBridge.sendHostContextChange({ theme: "dark" });
361+
newBridge.sendHostContextChanged({ theme: "dark" });
362362
await flush();
363363

364364
// Send another partial update: only containerDimensions change
365-
newBridge.sendHostContextChange({
365+
newBridge.sendHostContextChanged({
366366
containerDimensions: { width: 1024, maxHeight: 768 },
367367
});
368368
await flush();
@@ -774,7 +774,7 @@ describe("App <-> AppBridge integration", () => {
774774
);
775775
});
776776

777-
it.skip("onlistresources setter registers handler for resources/list requests" /* covered by listServerResources test below */, async () => {
777+
it("onlistresources setter registers handler for resources/list requests", async () => {
778778
const requestParams = {};
779779
const resources = [{ uri: "test://resource", name: "Test" }];
780780
const receivedRequests: unknown[] = [];
@@ -791,7 +791,7 @@ describe("App <-> AppBridge integration", () => {
791791
const result = await app.listServerResources();
792792

793793
expect(receivedRequests).toHaveLength(1);
794-
expect(receivedRequests[0]).toMatchObject(requestParams);
794+
// v2: list* methods send undefined params when called with no args
795795
expect(result.resources).toEqual(resources);
796796
});
797797

@@ -862,7 +862,7 @@ describe("App <-> AppBridge integration", () => {
862862
expect(result.contents).toEqual(contents);
863863
});
864864

865-
it.skip("onlistresourcetemplates setter registers handler /* TODO: v2 client.listResourceTemplates result shape */ for resources/templates/list requests", async () => {
865+
it("onlistresourcetemplates setter registers handler", async () => {
866866
const requestParams = {};
867867
const resourceTemplates = [
868868
{ uriTemplate: "test://{id}", name: "Test Template" },
@@ -880,11 +880,11 @@ describe("App <-> AppBridge integration", () => {
880880
const result = await app.client.listResourceTemplates();
881881

882882
expect(receivedRequests).toHaveLength(1);
883-
expect(receivedRequests[0]).toMatchObject(requestParams);
883+
// v2: list* methods send undefined params when called with no args
884884
expect(result.resourceTemplates).toEqual(resourceTemplates);
885885
});
886886

887-
it.skip("onlistprompts setter registers handler /* TODO: v2 client.listPrompts result shape */ for prompts/list requests", async () => {
887+
it("onlistprompts setter registers handler", async () => {
888888
const requestParams = {};
889889
const prompts = [{ name: "test-prompt" }];
890890
const receivedRequests: unknown[] = [];
@@ -900,7 +900,7 @@ describe("App <-> AppBridge integration", () => {
900900
const result = await app.client.listPrompts();
901901

902902
expect(receivedRequests).toHaveLength(1);
903-
expect(receivedRequests[0]).toMatchObject(requestParams);
903+
// v2: list* methods send undefined params when called with no args
904904
expect(result.prompts).toEqual(prompts);
905905
});
906906

@@ -1345,38 +1345,6 @@ describe("isToolVisibilityAppOnly", () => {
13451345
expect(app.onteardown).toBe(handler);
13461346
});
13471347

1348-
it.skip("direct setRequestHandler throws when called twice" /* v2: double-set protection removed (BREAKING.md) */, () => {
1349-
const bridge2 = new AppBridge(
1350-
createMockClient() as Client,
1351-
testHostInfo,
1352-
testHostCapabilities,
1353-
);
1354-
bridge2.setRequestHandler(
1355-
// @ts-expect-error — exercising throw path with raw schema
1356-
{ shape: { method: { value: "test/method" } } },
1357-
() => ({}),
1358-
);
1359-
expect(() => {
1360-
bridge2.setRequestHandler(
1361-
// @ts-expect-error — exercising throw path with raw schema
1362-
{ shape: { method: { value: "test/method" } } },
1363-
() => ({}),
1364-
);
1365-
}).toThrow(/already registered/);
1366-
});
13671348

1368-
it.skip("direct setNotificationHandler throws for event-mapped methods" /* v2: double-set protection removed */, () => {
1369-
const app2 = new App(testAppInfo, {}, { autoResize: false });
1370-
app2.addEventListener("toolinput", () => {});
1371-
expect(() => {
1372-
app2.setNotificationHandler(
1373-
// @ts-expect-error — exercising throw path with raw schema
1374-
{
1375-
shape: { method: { value: "ui/notifications/tool-input" } },
1376-
},
1377-
() => {},
1378-
);
1379-
}).toThrow(/already registered/);
1380-
});
13811349
});
13821350
});

src/server/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe("registerAppResource", () => {
225225
});
226226

227227
registerAppResource(
228-
mockServer as unknown as Pick<McpServer, "registerResource">,
228+
mockServer as unknown as McpServer,
229229
"My Resource",
230230
"ui://test/view.html",
231231
{
@@ -255,7 +255,7 @@ describe("registerAppResource", () => {
255255
};
256256

257257
registerAppResource(
258-
mockServer as unknown as Pick<McpServer, "registerResource">,
258+
mockServer as unknown as McpServer,
259259
"My Resource",
260260
"ui://test/view.html",
261261
{
@@ -306,7 +306,7 @@ describe("registerAppResource", () => {
306306
const callback = mock(async () => expectedResult);
307307

308308
registerAppResource(
309-
mockServer as unknown as Pick<McpServer, "registerResource">,
309+
mockServer as unknown as McpServer,
310310
"My Resource",
311311
"ui://test/view.html",
312312
{ _meta: { ui: {} } },

0 commit comments

Comments
 (0)