Skip to content

Commit 779f657

Browse files
test(gateway): align tests with upstream type/shape changes after rebase
After rebasing onto upstream main, two test surfaces drifted: 1. GatewayRequestContextParams gained two required fields upstream (getRuntimeConfig, broadcastVoiceWakeRoutingChanged). The makeContextParams test helper was missing them, so every consumer tripped tsgo with a missing-field error. Add both as vi.fn() stubs. 2. revokeDeviceToken's return shape changed upstream from a bare entry record to a discriminated union {ok: true, entry: ...} | {ok: false, reason}. The new device.token.revoke synchronous-invalidate test still mocked the old shape, so the production handler took the !revoked.ok branch and never reached the invalidateClientsForDevice call the test asserted. Update the mock to the new union shape. Also fix three new Set([...] as never) sites in server-request- context.test.ts that produced Set<unknown> rather than Set<never>. Move the cast outside the Set constructor so the literal stays inferred while the wrapper is type-erased to never, which is assignable to the Partial<GatewayRequestContextParams> clients field.
1 parent a9bf5cc commit 779f657

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/gateway/server-methods/devices.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ describe("deviceHandlers", () => {
352352
});
353353

354354
it("invalidates affected clients synchronously before responding to device.token.revoke", async () => {
355-
revokeDeviceTokenMock.mockResolvedValue({ role: "operator", revokedAtMs: 456 });
355+
revokeDeviceTokenMock.mockResolvedValue({
356+
ok: true,
357+
entry: { role: "operator", revokedAtMs: 456 },
358+
});
356359
const opts = createOptions(
357360
"device.token.revoke",
358361
{ deviceId: "device-1", role: "operator" },

src/gateway/server-request-context.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function makeContextParams(
1818
return {
1919
deps: {} as never,
2020
runtimeState,
21+
getRuntimeConfig: vi.fn(() => ({}) as never),
2122
execApprovalManager: undefined,
2223
pluginApprovalManager: undefined,
2324
loadGatewayModelCatalog: vi.fn(async () => []),
@@ -63,6 +64,7 @@ function makeContextParams(
6364
markChannelLoggedOut: vi.fn(),
6465
wizardRunner: vi.fn(async () => undefined),
6566
broadcastVoiceWakeChanged: vi.fn(),
67+
broadcastVoiceWakeRoutingChanged: vi.fn(),
6668
unavailableGatewayMethods: new Set(),
6769
...overrides,
6870
};
@@ -157,7 +159,7 @@ describe("createGatewayRequestContext", () => {
157159
connect: { device: { id: "device-2" }, role: "primary" },
158160
socket: { close: vi.fn() },
159161
};
160-
const clients = new Set([target, unrelated] as never);
162+
const clients = new Set([target, unrelated]) as never;
161163

162164
const context = createGatewayRequestContext(makeContextParams({ clients }));
163165
context.invalidateClientsForDevice?.("device-1", { reason: "device-token-rotated" });
@@ -178,7 +180,7 @@ describe("createGatewayRequestContext", () => {
178180
connect: { device: { id: "device-1" }, role: "primary" },
179181
socket: { close: vi.fn() },
180182
};
181-
const clients = new Set([target] as never);
183+
const clients = new Set([target]) as never;
182184

183185
const context = createGatewayRequestContext(makeContextParams({ clients }));
184186
context.disconnectClientsForDevice?.("device-1");
@@ -199,7 +201,7 @@ describe("createGatewayRequestContext", () => {
199201
connect: { device: { id: "device-1" }, role: "secondary" },
200202
socket: { close: vi.fn() },
201203
};
202-
const clients = new Set([primary, secondary] as never);
204+
const clients = new Set([primary, secondary]) as never;
203205

204206
const context = createGatewayRequestContext(makeContextParams({ clients }));
205207
context.invalidateClientsForDevice?.("device-1", { role: "primary" });

0 commit comments

Comments
 (0)