Skip to content

Commit a4ff3e1

Browse files
committed
test: repair gateway client boundary snapshots
1 parent 9ca7912 commit a4ff3e1

7 files changed

Lines changed: 116 additions & 64 deletions

src/tui/gateway-chat.test.ts

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -515,30 +515,46 @@ describe("GatewayChatClient", () => {
515515
vi.useRealTimers();
516516
});
517517

518-
it("identifies the TUI as a tui client and skips device identity on insecure local ui paths", () => {
519-
const client = new GatewayChatClient({
520-
url: "ws://127.0.0.1:18789",
521-
token: "test-token",
522-
preauthHandshakeTimeoutMs: 30_000,
523-
allowInsecureLocalOperatorUi: true,
518+
it("identifies the TUI as a tui client and skips device identity on insecure local ui paths", async () => {
519+
const constructedOptions: Array<Record<string, unknown>> = [];
520+
521+
vi.resetModules();
522+
vi.doMock("../gateway/client.js", async (importOriginal) => {
523+
const actual = await importOriginal<typeof import("../gateway/client.js")>();
524+
class CapturingGatewayClient {
525+
constructor(opts: Record<string, unknown>) {
526+
constructedOptions.push(opts);
527+
}
528+
start() {}
529+
stop() {}
530+
request() {
531+
throw new Error("unexpected request");
532+
}
533+
}
534+
return { ...actual, GatewayClient: CapturingGatewayClient };
524535
});
525536

526-
expect(
527-
(client as unknown as { client: { opts: { clientName?: string; mode?: string } } }).client
528-
.opts.clientName,
529-
).toBe("openclaw-tui");
530-
expect(
531-
(client as unknown as { client: { opts: { clientName?: string; mode?: string } } }).client
532-
.opts.mode,
533-
).toBe("ui");
534-
expect(
535-
(client as unknown as { client: { opts: { deviceIdentity?: unknown } } }).client.opts
536-
.deviceIdentity,
537-
).toBeUndefined();
538-
expect(
539-
(client as unknown as { client: { opts: { preauthHandshakeTimeoutMs?: number } } }).client
540-
.opts.preauthHandshakeTimeoutMs,
541-
).toBe(30_000);
537+
try {
538+
const { GatewayChatClient: CapturingGatewayChatClient } = await import("./gateway-chat.js");
539+
const client = new CapturingGatewayChatClient({
540+
url: "ws://127.0.0.1:18789",
541+
token: "test-token",
542+
preauthHandshakeTimeoutMs: 30_000,
543+
allowInsecureLocalOperatorUi: true,
544+
});
545+
546+
expect(client.connection.allowInsecureLocalOperatorUi).toBe(true);
547+
expect(constructedOptions).toHaveLength(1);
548+
expect(constructedOptions[0]).toMatchObject({
549+
clientName: "openclaw-tui",
550+
mode: "ui",
551+
preauthHandshakeTimeoutMs: 30_000,
552+
deviceIdentity: null,
553+
});
554+
} finally {
555+
vi.doUnmock("../gateway/client.js");
556+
vi.resetModules();
557+
}
542558
});
543559

544560
it("surfaces loopback block-mode start failures through disconnect handler", async () => {

test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/codex-dynamic-tools.discord-group.json

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,17 @@
262262
},
263263
"after": {
264264
"description": "Failures before alert",
265-
"type": "number"
265+
"minimum": 1,
266+
"type": "integer"
266267
},
267268
"channel": {
268269
"description": "Alert channel",
269270
"type": "string"
270271
},
271272
"cooldownMs": {
272273
"description": "Alert cooldown ms",
273-
"type": "number"
274+
"minimum": 0,
275+
"type": "integer"
274276
},
275277
"includeSkipped": {
276278
"description": "Skipped runs count toward alert",
@@ -329,6 +331,7 @@
329331
"type": "string"
330332
},
331333
"timeoutSeconds": {
334+
"minimum": 0,
332335
"type": "number"
333336
},
334337
"toolsAllow": {
@@ -346,15 +349,17 @@
346349
"properties": {
347350
"anchorMs": {
348351
"description": "Start anchor ms (kind=every)",
349-
"type": "number"
352+
"minimum": 0,
353+
"type": "integer"
350354
},
351355
"at": {
352356
"description": "ISO-8601 time (kind=at)",
353357
"type": "string"
354358
},
355359
"everyMs": {
356360
"description": "Interval ms (kind=every)",
357-
"type": "number"
361+
"minimum": 1,
362+
"type": "integer"
358363
},
359364
"expr": {
360365
"description": "Cron expr in tz wall-clock time; do not convert to UTC. Omitted tz => Gateway host local timezone. Example 6pm Shanghai daily: expr \"0 18 * * *\", tz \"Asia/Shanghai\".",
@@ -367,7 +372,8 @@
367372
},
368373
"staggerMs": {
369374
"description": "Jitter ms (kind=cron)",
370-
"type": "number"
375+
"minimum": 0,
376+
"type": "integer"
371377
},
372378
"tz": {
373379
"description": "IANA timezone for cron wall-clock fields, e.g. \"Asia/Shanghai\"; omitted => Gateway host local timezone.",
@@ -480,15 +486,17 @@
480486
},
481487
"after": {
482488
"description": "Failures before alert",
483-
"type": "number"
489+
"minimum": 1,
490+
"type": "integer"
484491
},
485492
"channel": {
486493
"description": "Alert channel",
487494
"type": "string"
488495
},
489496
"cooldownMs": {
490497
"description": "Alert cooldown ms",
491-
"type": "number"
498+
"minimum": 0,
499+
"type": "integer"
492500
},
493501
"includeSkipped": {
494502
"description": "Skipped runs count toward alert",
@@ -547,6 +555,7 @@
547555
"type": "string"
548556
},
549557
"timeoutSeconds": {
558+
"minimum": 0,
550559
"type": "number"
551560
},
552561
"toolsAllow": {
@@ -564,15 +573,17 @@
564573
"properties": {
565574
"anchorMs": {
566575
"description": "Start anchor ms (kind=every)",
567-
"type": "number"
576+
"minimum": 0,
577+
"type": "integer"
568578
},
569579
"at": {
570580
"description": "ISO-8601 time (kind=at)",
571581
"type": "string"
572582
},
573583
"everyMs": {
574584
"description": "Interval ms (kind=every)",
575-
"type": "number"
585+
"minimum": 1,
586+
"type": "integer"
576587
},
577588
"expr": {
578589
"description": "Cron expr in tz wall-clock time; do not convert to UTC. Omitted tz => Gateway host local timezone. Example 6pm Shanghai daily: expr \"0 18 * * *\", tz \"Asia/Shanghai\".",
@@ -585,7 +596,8 @@
585596
},
586597
"staggerMs": {
587598
"description": "Jitter ms (kind=cron)",
588-
"type": "number"
599+
"minimum": 0,
600+
"type": "integer"
589601
},
590602
"tz": {
591603
"description": "IANA timezone for cron wall-clock fields, e.g. \"Asia/Shanghai\"; omitted => Gateway host local timezone.",

test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/codex-dynamic-tools.heartbeat-turn.json

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,17 @@
262262
},
263263
"after": {
264264
"description": "Failures before alert",
265-
"type": "number"
265+
"minimum": 1,
266+
"type": "integer"
266267
},
267268
"channel": {
268269
"description": "Alert channel",
269270
"type": "string"
270271
},
271272
"cooldownMs": {
272273
"description": "Alert cooldown ms",
273-
"type": "number"
274+
"minimum": 0,
275+
"type": "integer"
274276
},
275277
"includeSkipped": {
276278
"description": "Skipped runs count toward alert",
@@ -329,6 +331,7 @@
329331
"type": "string"
330332
},
331333
"timeoutSeconds": {
334+
"minimum": 0,
332335
"type": "number"
333336
},
334337
"toolsAllow": {
@@ -346,15 +349,17 @@
346349
"properties": {
347350
"anchorMs": {
348351
"description": "Start anchor ms (kind=every)",
349-
"type": "number"
352+
"minimum": 0,
353+
"type": "integer"
350354
},
351355
"at": {
352356
"description": "ISO-8601 time (kind=at)",
353357
"type": "string"
354358
},
355359
"everyMs": {
356360
"description": "Interval ms (kind=every)",
357-
"type": "number"
361+
"minimum": 1,
362+
"type": "integer"
358363
},
359364
"expr": {
360365
"description": "Cron expr in tz wall-clock time; do not convert to UTC. Omitted tz => Gateway host local timezone. Example 6pm Shanghai daily: expr \"0 18 * * *\", tz \"Asia/Shanghai\".",
@@ -367,7 +372,8 @@
367372
},
368373
"staggerMs": {
369374
"description": "Jitter ms (kind=cron)",
370-
"type": "number"
375+
"minimum": 0,
376+
"type": "integer"
371377
},
372378
"tz": {
373379
"description": "IANA timezone for cron wall-clock fields, e.g. \"Asia/Shanghai\"; omitted => Gateway host local timezone.",
@@ -480,15 +486,17 @@
480486
},
481487
"after": {
482488
"description": "Failures before alert",
483-
"type": "number"
489+
"minimum": 1,
490+
"type": "integer"
484491
},
485492
"channel": {
486493
"description": "Alert channel",
487494
"type": "string"
488495
},
489496
"cooldownMs": {
490497
"description": "Alert cooldown ms",
491-
"type": "number"
498+
"minimum": 0,
499+
"type": "integer"
492500
},
493501
"includeSkipped": {
494502
"description": "Skipped runs count toward alert",
@@ -547,6 +555,7 @@
547555
"type": "string"
548556
},
549557
"timeoutSeconds": {
558+
"minimum": 0,
550559
"type": "number"
551560
},
552561
"toolsAllow": {
@@ -564,15 +573,17 @@
564573
"properties": {
565574
"anchorMs": {
566575
"description": "Start anchor ms (kind=every)",
567-
"type": "number"
576+
"minimum": 0,
577+
"type": "integer"
568578
},
569579
"at": {
570580
"description": "ISO-8601 time (kind=at)",
571581
"type": "string"
572582
},
573583
"everyMs": {
574584
"description": "Interval ms (kind=every)",
575-
"type": "number"
585+
"minimum": 1,
586+
"type": "integer"
576587
},
577588
"expr": {
578589
"description": "Cron expr in tz wall-clock time; do not convert to UTC. Omitted tz => Gateway host local timezone. Example 6pm Shanghai daily: expr \"0 18 * * *\", tz \"Asia/Shanghai\".",
@@ -585,7 +596,8 @@
585596
},
586597
"staggerMs": {
587598
"description": "Jitter ms (kind=cron)",
588-
"type": "number"
599+
"minimum": 0,
600+
"type": "integer"
589601
},
590602
"tz": {
591603
"description": "IANA timezone for cron wall-clock fields, e.g. \"Asia/Shanghai\"; omitted => Gateway host local timezone.",

0 commit comments

Comments
 (0)