From a92feecb1dceb2bd4e4f6180a0240211c416bdc5 Mon Sep 17 00:00:00 2001 From: "Guan-Ming (Wesley) Chiu" <105915352+guan404ming@users.noreply.github.com> Date: Fri, 3 Jul 2026 14:05:22 +0800 Subject: [PATCH] Add TypeScript SDK coordinator schema-mapping tests --- ts-sdk/tests/coordinator/client.test.ts | 40 ++++++++++++++++++++ ts-sdk/tests/coordinator/integration.test.ts | 2 + 2 files changed, 42 insertions(+) diff --git a/ts-sdk/tests/coordinator/client.test.ts b/ts-sdk/tests/coordinator/client.test.ts index 0511ffd4179f0..b2583e80e0a03 100644 --- a/ts-sdk/tests/coordinator/client.test.ts +++ b/ts-sdk/tests/coordinator/client.test.ts @@ -125,6 +125,29 @@ describe("client is bound to TaskContext", () => { }); }); + it("defaults getXCom locator fields from ctx with snake_case wire names", async () => { + const sent: Record[] = []; + const recordingComm = { + request: async (b: Record) => { + sent.push(b); + return { body: { type: "XComResult", key: b.key, value: null } }; + }, + } as unknown as CommChannel; + const c = createCoordinatorClient(recordingComm, FAKE_CTX); + + await c.getXCom({ key: "k" }); + + expect(sent[0]).toEqual({ + type: "GetXCom", + key: "k", + dag_id: "d", + task_id: "t", + run_id: "r", + map_index: null, + include_prior_dates: false, + }); + }); + it("maps camelCase public XCom options to snake_case supervisor fields", async () => { const sent: Record[] = []; const recordingComm = { @@ -197,6 +220,23 @@ describe("getConnection", () => { }); }); + it("coerces absent optional wire fields to null public fields", async () => { + const c = client([ + { body: { type: "ConnectionResult", conn_id: "bare", conn_type: "generic" } }, + ]); + + await expect(c.getConnection("bare")).resolves.toEqual({ + id: "bare", + type: "generic", + host: null, + schema: null, + login: null, + password: null, + port: null, + extra: null, + }); + }); + it("returns null for missing connections", async () => { const c = client([{ body: { type: "ErrorResponse", error: "CONNECTION_NOT_FOUND" } }]); expect(await c.getConnection("missing")).toBeNull(); diff --git a/ts-sdk/tests/coordinator/integration.test.ts b/ts-sdk/tests/coordinator/integration.test.ts index 42dc3650a4e57..a580159073ec2 100644 --- a/ts-sdk/tests/coordinator/integration.test.ts +++ b/ts-sdk/tests/coordinator/integration.test.ts @@ -248,6 +248,8 @@ describe("coordinator runtime integration", () => { taskId: "say_hello", dagId: "test_dag", runId: "r1", + tryNumber: 1, + mapIndex: -1, }); expect(result.logRecords.some((r) => r["event"] === "[ts-sdk.runtime] Task succeeded")).toBe( true,