perf(test): trim duplicate e2e suites and harden signal hooks

This commit is contained in:
Peter Steinberger
2026-02-13 16:46:31 +00:00
parent 45b9aad0f4
commit 1eccfa8934
8 changed files with 79 additions and 319 deletions

View File

@@ -221,8 +221,9 @@ describe("gateway server health/presence", () => {
test("presence includes client fingerprint", async () => {
const identityPath = path.join(os.tmpdir(), `openclaw-device-${randomUUID()}.json`);
const identity = loadOrCreateDeviceIdentity(identityPath);
const token = process.env.OPENCLAW_GATEWAY_TOKEN?.trim() || undefined;
const role = "operator";
const scopes: string[] = [];
const scopes: string[] = ["operator.admin"];
const signedAtMs = Date.now();
const payload = buildDeviceAuthPayload({
deviceId: identity.deviceId,
@@ -231,11 +232,12 @@ describe("gateway server health/presence", () => {
role,
scopes,
signedAtMs,
token: null,
token: token ?? null,
});
const ws = await openClient({
role,
scopes,
token,
client: {
id: GATEWAY_CLIENT_NAMES.FINGERPRINT,
version: "9.9.9",
@@ -262,8 +264,14 @@ describe("gateway server health/presence", () => {
}),
);
const presenceRes = await presenceP;
const entries = presenceRes.payload as Array<Record<string, unknown>>;
const presenceRes = (await presenceP) as { ok?: boolean; payload?: unknown };
expect(presenceRes.ok).toBe(true);
const presencePayload = presenceRes.payload;
const entries = Array.isArray(presencePayload)
? presencePayload
: Array.isArray((presencePayload as { presence?: unknown } | undefined)?.presence)
? ((presencePayload as { presence: Array<Record<string, unknown>> }).presence ?? [])
: [];
const clientEntry = entries.find(
(e) => e.host === GATEWAY_CLIENT_NAMES.FINGERPRINT && e.version === "9.9.9",
);