fix: stabilize gateway test env cleanup (#1148) (thanks @TSavo)
This commit is contained in:
parent
282dbe3167
commit
2f6842fdf4
@ -16,6 +16,7 @@ Docs: https://docs.clawd.bot
|
||||
### Fixes
|
||||
- Tools: return a companion-app-required message when node exec is requested with no paired node.
|
||||
- Streaming: emit assistant deltas for OpenAI-compatible SSE chunks. (#1147) — thanks @alauppe.
|
||||
- Tests: clean up gateway env stubs and assert config.apply sentinel writes. (#1148) — thanks @TSavo.
|
||||
|
||||
## 2026.1.18-2
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ describe("gateway server channels", () => {
|
||||
vi.stubEnv("TELEGRAM_BOT_TOKEN", undefined);
|
||||
const result = await startServerWithClient();
|
||||
servers.push(result);
|
||||
const { server, ws } = result;
|
||||
const { ws } = result;
|
||||
await connectOk(ws);
|
||||
|
||||
const res = await rpcReq<{
|
||||
@ -61,7 +61,7 @@ describe("gateway server channels", () => {
|
||||
test("channels.logout reports no session when missing", async () => {
|
||||
const result = await startServerWithClient();
|
||||
servers.push(result);
|
||||
const { server, ws } = result;
|
||||
const { ws } = result;
|
||||
await connectOk(ws);
|
||||
|
||||
const res = await rpcReq<{ cleared?: boolean; channel?: string }>(ws, "channels.logout", {
|
||||
@ -86,7 +86,7 @@ describe("gateway server channels", () => {
|
||||
|
||||
const result = await startServerWithClient();
|
||||
servers.push(result);
|
||||
const { server, ws } = result;
|
||||
const { ws } = result;
|
||||
await connectOk(ws);
|
||||
|
||||
const res = await rpcReq<{
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { readRestartSentinel } from "../infra/restart-sentinel.js";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
connectOk,
|
||||
@ -31,7 +29,7 @@ describe("gateway config.apply", () => {
|
||||
it("writes config, stores sentinel, and schedules restart", async () => {
|
||||
const result = await startServerWithClient();
|
||||
servers.push(result);
|
||||
const { server, ws } = result;
|
||||
const { ws } = result;
|
||||
await connectOk(ws);
|
||||
|
||||
const id = "req-1";
|
||||
@ -53,26 +51,14 @@ describe("gateway config.apply", () => {
|
||||
);
|
||||
expect(res.ok).toBe(true);
|
||||
|
||||
// Verify sentinel file was created (restart was scheduled)
|
||||
const sentinelPath = path.join(os.homedir(), ".clawdbot", "restart-sentinel.json");
|
||||
|
||||
// Wait for file to be written
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
|
||||
try {
|
||||
const raw = await fs.readFile(sentinelPath, "utf-8");
|
||||
const parsed = JSON.parse(raw) as { payload?: { kind?: string } };
|
||||
expect(parsed.payload?.kind).toBe("config-apply");
|
||||
} catch (err) {
|
||||
// File may not exist if signal delivery is mocked, verify response was ok instead
|
||||
expect(res.ok).toBe(true);
|
||||
}
|
||||
const sentinel = await readRestartSentinel();
|
||||
expect(sentinel?.payload.kind).toBe("config-apply");
|
||||
});
|
||||
|
||||
it("rejects invalid raw config", async () => {
|
||||
const result = await startServerWithClient();
|
||||
servers.push(result);
|
||||
const { server, ws } = result;
|
||||
const { ws } = result;
|
||||
await connectOk(ws);
|
||||
|
||||
const id = "req-2";
|
||||
|
||||
@ -7,4 +7,5 @@ process.on("exit", cleanup);
|
||||
afterEach(() => {
|
||||
// Guard against leaked fake timers across test files/workers.
|
||||
vi.useRealTimers();
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user