Skip to content

Commit 1233293

Browse files
committed
fix: Modify test mock data
1 parent 8ad6253 commit 1233293

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

client/src/lib/hooks/__tests__/useConnection.test.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,13 @@ describe("useConnection", () => {
510510
requestedSchema: {
511511
type: "object",
512512
properties: {
513-
name: {
514-
$ref: "#/properties/nameDef",
515-
},
516-
nameDef: {
513+
source: {
517514
type: "string",
518-
title: "Name",
515+
minLength: 1,
516+
title: "A Connectable Node",
517+
},
518+
target: {
519+
$ref: "#/properties/source",
519520
},
520521
},
521522
},
@@ -529,9 +530,10 @@ describe("useConnection", () => {
529530
expect(mockProtocolOnMessage).toHaveBeenCalledTimes(1);
530531

531532
const message = mockProtocolOnMessage.mock.calls[0][0];
532-
expect(message.params.requestedSchema.properties.name).toEqual({
533+
expect(message.params.requestedSchema.properties.target).toEqual({
533534
type: "string",
534-
title: "Name",
535+
minLength: 1,
536+
title: "A Connectable Node",
535537
});
536538
});
537539
});

client/src/utils/schemaUtils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export function formatFieldLabel(key: string): string {
302302
}
303303

304304
/**
305-
* Resolves $ref references in a JSON-RPC message's requestedSchema
305+
* Resolves `$ref` references in a JSON-RPC "elicitation/create" message's `requestedSchema` field
306306
* @param message The JSON-RPC message that may contain $ref references
307307
* @returns A new message with resolved $ref references, or the original message if no resolution is needed
308308
*/
@@ -325,10 +325,11 @@ export function resolveRefsInMessage(message: JSONRPCMessage): JSONRPCMessage {
325325
...requestedSchema,
326326
properties: Object.fromEntries(
327327
Object.entries(requestedSchema.properties).map(
328-
([key, propSchema]) => [
329-
key,
330-
resolveRef(propSchema, requestedSchema),
331-
],
328+
([key, propSchema]) => {
329+
const resolved = resolveRef(propSchema, requestedSchema);
330+
const normalized = normalizeUnionType(resolved);
331+
return [key, normalized];
332+
},
332333
),
333334
),
334335
},

0 commit comments

Comments
 (0)