Files
openclaw/src/gateway/server-plugins.lifecycle.test.ts
Peter Steinberger c757675f34 improve: keep isolated tests under one second (#100019)
* test: speed up isolated test suite

* test: finish isolated latency cleanup

* test: eliminate remaining isolated latency spikes

* test: remove final isolated timing outliers

* test: bound full-suite tooling processes

* test: bound native test process lifetime

* test: warm isolated runtime suites

* test: eliminate final isolated timing outliers

* test: fix isolated timing fixture types

* test: make timeout cleanup timing deterministic

* test: pin media manifests to source checkout

* test: isolate provider manifest contracts

* test: eliminate residual isolated timing spikes

* test: restore final isolated timing fixes

* test: eliminate remaining isolated timing spikes

* test: warm Zalo lifecycle imports

* test: keep isolated suites below one second

* test: use readable browser response fixtures
2026-07-05 10:57:19 -07:00

47 lines
1.5 KiB
TypeScript

/**
* Tests gateway plugin lifecycle loading, startup, and shutdown behavior.
*/
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
import { clearFallbackGatewayContext, createGatewaySubagentRuntime } from "./server-plugins.js";
import { installGatewayTestHooks, startServer } from "./test-helpers.server.js";
installGatewayTestHooks({ scope: "suite" });
afterEach(() => {
clearFallbackGatewayContext();
});
describe("gateway plugin fallback context lifecycle", () => {
let started: Awaited<ReturnType<typeof startServer>> | undefined;
beforeAll(async () => {
const warm = await startServer();
await warm.server.close({ reason: "warm fallback context lifecycle" });
started = await startServer();
});
afterAll(async () => {
await started?.server.close({ reason: "fallback context lifecycle cleanup" });
});
it("clears the fallback gateway context after server close", async () => {
const runtime = createGatewaySubagentRuntime();
if (!started) {
throw new Error("expected gateway server to start");
}
try {
await expect(
runtime.getSessionMessages({ sessionKey: "agent:main:main", limit: 1 }),
).resolves.toEqual({ messages: [] });
} finally {
await started.server.close({ reason: "fallback context lifecycle test done" });
started = undefined;
}
await expect(
runtime.getSessionMessages({ sessionKey: "agent:main:main", limit: 1 }),
).rejects.toThrow("No scope set and no fallback context available");
});
});