test: tighten infra sdk empty array assertions

This commit is contained in:
Shakker
2026-05-09 05:36:04 +01:00
parent d4b20e8904
commit 7d5cfd157a
25 changed files with 59 additions and 57 deletions

View File

@@ -272,7 +272,7 @@ describe("diagnostic-events", () => {
});
await new Promise<void>((resolve) => setImmediate(resolve));
expect(publicEvents).toEqual([]);
expect(publicEvents).toStrictEqual([]);
expect(internalEvents).toEqual([{ trusted: true, type: "model.call.started" }]);
});
@@ -395,7 +395,7 @@ describe("diagnostic-events", () => {
model: "gpt-5.4",
});
expect(events).toEqual([]);
expect(events).toStrictEqual([]);
await new Promise<void>((resolve) => setImmediate(resolve));
expect(events).toEqual(["tool.execution.started", "model.call.started"]);
});
@@ -417,7 +417,7 @@ describe("diagnostic-events", () => {
});
await new Promise<void>((resolve) => setImmediate(resolve));
expect(publicEvents).toEqual([]);
expect(publicEvents).toStrictEqual([]);
expect(internalEvents).toEqual(["log.record"]);
});
@@ -434,7 +434,7 @@ describe("diagnostic-events", () => {
channel: "telegram",
});
expect(seen).toEqual([]);
expect(seen).toStrictEqual([]);
expect(nowSpy).not.toHaveBeenCalled();
});

View File

@@ -40,7 +40,7 @@ describe("resolveDiagnosticFlags", () => {
resolveDiagnosticFlags(cfg, {
OPENCLAW_DIAGNOSTICS: raw,
} as NodeJS.ProcessEnv),
).toEqual([]);
).toStrictEqual([]);
}
});
});

View File

@@ -135,7 +135,7 @@ describe("resolveAllowAlwaysPatterns", () => {
env,
safeBins,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
const second = evaluateShellAllowlist({
command,
@@ -168,7 +168,7 @@ describe("resolveAllowAlwaysPatterns", () => {
if (params.expectPersisted) {
expect(persisted).toEqual([touch]);
} else {
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
}
const second = evaluateShellAllowlist({
@@ -219,7 +219,7 @@ describe("resolveAllowAlwaysPatterns", () => {
},
],
});
expect(patterns).toEqual([]);
expect(patterns).toStrictEqual([]);
});
it("persists benign awk interpreters when strict inline-eval is enabled", () => {
@@ -312,7 +312,7 @@ describe("resolveAllowAlwaysPatterns", () => {
safeBins,
strictInlineEval: true,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
});
it("unwraps shell wrappers and persists the inner executable instead", () => {
@@ -460,7 +460,7 @@ describe("resolveAllowAlwaysPatterns", () => {
env,
safeBins,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
const second = evaluateShellAllowlist({
command,
@@ -589,7 +589,7 @@ $0 \\"$1\\"" touch {marker}`,
],
platform: process.platform,
});
expect(patterns).toEqual([]);
expect(patterns).toStrictEqual([]);
});
it("detects shell wrappers even when unresolved executableName is a full path", () => {
@@ -730,7 +730,7 @@ $0 \\"$1\\"" touch {marker}`,
env: makePathEnv(dir),
platform: process.platform,
});
expect(patterns).toEqual([]);
expect(patterns).toStrictEqual([]);
});
it("fails closed for unresolved dispatch wrappers", () => {
@@ -750,7 +750,7 @@ $0 \\"$1\\"" touch {marker}`,
],
platform: process.platform,
});
expect(patterns).toEqual([]);
expect(patterns).toStrictEqual([]);
});
it("prevents allow-always bypass for busybox shell applets", () => {
@@ -879,7 +879,7 @@ $0 \\"$1\\"" touch {marker}`,
env,
safeBins,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
const second = evaluateShellAllowlist({
command: `awk 'BEGIN{system("id > ${path.join(dir, "marker")}")}'`,
@@ -915,7 +915,7 @@ $0 \\"$1\\"" touch {marker}`,
env,
safeBins,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
const second = evaluateShellAllowlist({
command: `sh -c '$0 "$@"' awk 'BEGIN{system("id > /tmp/pwned")}'`,
@@ -977,7 +977,7 @@ $0 \\"$1\\"" touch {marker}`,
env,
safeBins,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
const second = evaluateShellAllowlist({
command: `sh -c '$0 "$@"' env BASH_ENV=/tmp/payload.sh bash -c 'id > /tmp/pwned'`,
@@ -1005,7 +1005,7 @@ $0 \\"$1\\"" touch {marker}`,
env,
safeBins,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
const second = evaluateShellAllowlist({
command: `sh -c '$0 "$@"' bash -c 'id > /tmp/pwned'`,
@@ -1033,7 +1033,7 @@ $0 \\"$1\\"" touch {marker}`,
env,
safeBins,
});
expect(persisted).toEqual([]);
expect(persisted).toStrictEqual([]);
const second = evaluateShellAllowlist({
command: `sh -c '$0 "$@"' xargs sh -c 'id > /tmp/pwned'`,

View File

@@ -234,7 +234,7 @@ describe("exec approvals store helpers", () => {
expect(rename).toHaveBeenCalled();
expect(fs.readFileSync(approvalsPath, "utf8")).toContain('"security": "full"');
expect(fs.statSync(approvalsPath).mode & 0o777).toBe(0o600);
expect(listExecApprovalTempFiles(dir)).toEqual([]);
expect(listExecApprovalTempFiles(dir)).toStrictEqual([]);
});
it("normalizes fallback temp files before copying", () => {
@@ -268,7 +268,7 @@ describe("exec approvals store helpers", () => {
expect(fs.readFileSync(approvalsPath, "utf8")).toContain('"security": "full"');
expect(fs.statSync(approvalsPath).mode & 0o777).toBe(0o600);
expect(listExecApprovalTempFiles(dir)).toEqual([]);
expect(listExecApprovalTempFiles(dir)).toStrictEqual([]);
});
it("restores the previous approvals file when fallback copy fails", () => {
@@ -304,7 +304,7 @@ describe("exec approvals store helpers", () => {
).toThrow(/copy failed after opening destination/);
expect(fs.readFileSync(approvalsPath, "utf8")).toBe(previousRaw);
expect(fs.statSync(approvalsPath).mode & 0o777).toBe(0o600);
expect(listExecApprovalTempFiles(dir)).toEqual([]);
expect(listExecApprovalTempFiles(dir)).toStrictEqual([]);
});
it("does not follow a symlink swapped in before fallback copy", () => {
@@ -338,7 +338,7 @@ describe("exec approvals store helpers", () => {
saveExecApprovals({ version: 1, defaults: { security: "full" }, agents: {} }),
).toThrow(/symlink|ELOOP/);
expect(fs.readFileSync(targetPath, "utf8")).toBe('{"sentinel":true}\n');
expect(listExecApprovalTempFiles(dir)).toEqual([]);
expect(listExecApprovalTempFiles(dir)).toStrictEqual([]);
});
it("does not use the copy fallback for hard-linked approvals files", () => {
@@ -361,7 +361,7 @@ describe("exec approvals store helpers", () => {
saveExecApprovals({ version: 1, defaults: { security: "full" }, agents: {} }),
).toThrow(/hard-linked exec approvals file/);
expect(fs.readFileSync(linkedPath, "utf8")).toBe('{"sentinel":true}\n');
expect(listExecApprovalTempFiles(dir)).toEqual([]);
expect(listExecApprovalTempFiles(dir)).toStrictEqual([]);
});
it("refuses to write approvals through a symlink destination", () => {

View File

@@ -90,7 +90,7 @@ describe("exec approvals allowlist evaluation", () => {
return;
}
expect(result.allowlistSatisfied).toBe(true);
expect(result.allowlistMatches).toEqual([]);
expect(result.allowlistMatches).toStrictEqual([]);
});
it("satisfies allowlist via auto-allow skills", () => {
@@ -188,8 +188,8 @@ describe("exec approvals allowlist evaluation", () => {
cwd: "/tmp",
});
expect(result.allowlistSatisfied).toBe(false);
expect(result.allowlistMatches).toEqual([]);
expect(result.segmentSatisfiedBy).toEqual([]);
expect(result.allowlistMatches).toStrictEqual([]);
expect(result.segmentSatisfiedBy).toStrictEqual([]);
});
it("aggregates segment satisfaction across chains", () => {

View File

@@ -146,7 +146,7 @@ describe("wrapFetchWithAbortSignal", () => {
await Promise.resolve();
await waitForMicrotaskTurn();
expect(unhandled).toEqual([]);
expect(unhandled).toStrictEqual([]);
expect(removeEventListener).toHaveBeenCalledOnce();
} finally {
process.off("unhandledRejection", onUnhandled);
@@ -303,7 +303,7 @@ describe("wrapFetchWithAbortSignal", () => {
const seenHeaders = getSeenInit()?.headers;
expect(seenHeaders).not.toBe(init.headers);
expect(Object.getOwnPropertySymbols(seenHeaders as object)).toEqual([]);
expect(Object.getOwnPropertySymbols(seenHeaders as object)).toStrictEqual([]);
expect(new Headers(seenHeaders).get("content-type")).toBe("application/json");
expect(Object.getOwnPropertySymbols(init.headers as object)).toHaveLength(1);
},

View File

@@ -115,7 +115,7 @@ describe("NodeSqliteKyselyDialect", () => {
throw new Error("rollback outer");
}),
).rejects.toThrow("rollback outer");
await expect(db.selectFrom("person").selectAll().execute()).resolves.toEqual([]);
await expect(db.selectFrom("person").selectAll().execute()).resolves.toStrictEqual([]);
const trx = await db.startTransaction().execute();
await trx.insertInto("person").values({ name: "Ada" }).execute();

View File

@@ -84,7 +84,7 @@ describe("fetchWithRuntimeDispatcher", () => {
expect(response.status).toBe(200);
const sentHeaders = requireFetchInit(runtimeFetch).headers;
expect(sentHeaders).not.toBe(headers);
expect(Object.getOwnPropertySymbols(sentHeaders as object)).toEqual([]);
expect(Object.getOwnPropertySymbols(sentHeaders as object)).toStrictEqual([]);
expect(Object.getOwnPropertySymbols(headers)).toHaveLength(1);
});

View File

@@ -33,7 +33,7 @@ describe("session-delivery queue recovery", () => {
expect(deliver).toHaveBeenCalledTimes(1);
expect(summary.recovered).toBe(1);
expect(await loadPendingSessionDeliveries(tempDir)).toEqual([]);
expect(await loadPendingSessionDeliveries(tempDir)).toStrictEqual([]);
});
});

View File

@@ -80,7 +80,7 @@ describe("ssh-config", () => {
expect(parsed.user).toBe("bob");
expect(parsed.host).toBe("example.com");
expect(parsed.port).toBeUndefined();
expect(parsed.identityFiles).toEqual([]);
expect(parsed.identityFiles).toStrictEqual([]);
});
it("resolves ssh config via ssh -G", async () => {

View File

@@ -16,7 +16,7 @@ describe("state migration fs helpers", () => {
await withTempDir({ prefix: "openclaw-state-migrations-fs-" }, async (base) => {
const nested = path.join(base, "nested");
expect(safeReadDir(nested)).toEqual([]);
expect(safeReadDir(nested)).toStrictEqual([]);
ensureDir(nested);
fs.writeFileSync(path.join(nested, "file.txt"), "ok", "utf8");

View File

@@ -258,7 +258,7 @@ describe("system run command helpers", () => {
test("resolveSystemRunCommand returns an empty success payload when no command is provided", () => {
const res = expectValidResult(resolveSystemRunCommand({}));
expect(res.argv).toEqual([]);
expect(res.argv).toStrictEqual([]);
expect(res.commandText).toBe("");
expect(res.shellPayload).toBeNull();
expect(res.previewText).toBeNull();

View File

@@ -345,7 +345,7 @@ describe("runGatewayUpdate", () => {
expect(result.status).toBe("error");
expect(result.reason).toBe("fetch-failed");
expect(calls).toContain(fetchCommand);
expect(calls.slice(calls.indexOf(fetchCommand) + 1)).toEqual([]);
expect(calls.slice(calls.indexOf(fetchCommand) + 1)).toStrictEqual([]);
});
it("aborts rebase on failure", async () => {
@@ -1431,7 +1431,7 @@ describe("runGatewayUpdate", () => {
expect(calls).not.toContain("npm run build");
expect(calls).not.toContain("npm run lint");
const preflightCalls = calls.filter((call) => preflightPrefixPattern.test(call));
expect(preflightCalls).toEqual([]);
expect(preflightCalls).toStrictEqual([]);
});
it("skips update when no git root", async () => {
@@ -1453,8 +1453,8 @@ describe("runGatewayUpdate", () => {
expect(result.reason).toBe("not-git-install");
const pnpmGlobalInstallCalls = calls.filter((call) => call.startsWith("pnpm add -g"));
const npmGlobalInstallCalls = calls.filter((call) => call.startsWith("npm i -g"));
expect(pnpmGlobalInstallCalls).toEqual([]);
expect(npmGlobalInstallCalls).toEqual([]);
expect(pnpmGlobalInstallCalls).toStrictEqual([]);
expect(npmGlobalInstallCalls).toStrictEqual([]);
});
async function runNpmGlobalUpdateCase(params: {
@@ -1908,7 +1908,7 @@ describe("runGatewayUpdate", () => {
);
const pnpmAddGlobalCalls = calls.filter((call) => call.startsWith("pnpm add -g"));
expect(npmPrefixedGlobalInstallCalls.length).toBeGreaterThan(0);
expect(pnpmAddGlobalCalls).toEqual([]);
expect(pnpmAddGlobalCalls).toStrictEqual([]);
expect(result.steps.map((step) => step.name)).toEqual(["global update", "global install swap"]);
await expect(fs.access(staleInstallChunk)).rejects.toMatchObject({ code: "ENOENT" });
});

View File

@@ -268,6 +268,6 @@ describe("createChannelApproverDmTargetResolver", () => {
expiresAtMs: 1000,
},
}),
).toEqual([]);
).toStrictEqual([]);
});
});

View File

@@ -105,7 +105,7 @@ describe("createDangerousNameMatchingMutableAllowlistWarningCollector", () => {
},
} as never,
}),
).toEqual([]);
).toStrictEqual([]);
});
});
@@ -115,8 +115,8 @@ describe("normalizeAllowFromList", () => {
});
it("returns an empty list for non-arrays", () => {
expect(normalizeAllowFromList(undefined)).toEqual([]);
expect(normalizeAllowFromList(null)).toEqual([]);
expect(normalizeAllowFromList(undefined)).toStrictEqual([]);
expect(normalizeAllowFromList(null)).toStrictEqual([]);
});
});

View File

@@ -167,7 +167,7 @@ describe("channel-streaming", () => {
it("uses auto progress labels when no explicit label is configured", () => {
const invalidLabels = DEFAULT_PROGRESS_DRAFT_LABELS.filter((label) => !label.endsWith("..."));
expect(invalidLabels).toEqual([]);
expect(invalidLabels).toStrictEqual([]);
expect(resolveChannelProgressDraftLabel({ random: () => 0 })).toBe(
DEFAULT_PROGRESS_DRAFT_LABELS[0],
);

View File

@@ -135,7 +135,7 @@ describe("plugin-sdk/command-auth", () => {
useAccessGroups && authorizers.some((entry) => entry.configured && entry.allowed),
});
expect(result.effectiveAllowFrom).toEqual([]);
expect(result.effectiveAllowFrom).toStrictEqual([]);
expect(result.senderAllowedForCommands).toBe(false);
expect(result.commandAuthorized).toBeUndefined();
});

View File

@@ -89,7 +89,7 @@ describe("plugin-sdk/direct-dm", () => {
expect(result.access.decision).toBe("block");
expect(result.access.reason).toBe("dmPolicy=open (not allowlisted)");
expect(result.access.effectiveAllowFrom).toEqual([]);
expect(result.access.effectiveAllowFrom).toStrictEqual([]);
expect(result.commandAuthorized).toBeUndefined();
});

View File

@@ -320,7 +320,7 @@ describe("plugin-sdk facade loader", () => {
}),
).toThrow("plugin load failure");
expect(listImportedBundledPluginFacadeIds()).toEqual([]);
expect(listImportedBundledPluginFacadeIds()).toStrictEqual([]);
expect(() =>
loadBundledPluginPublicSurfaceModuleSync<{ marker: string }>({

View File

@@ -243,7 +243,7 @@ describe("plugin-sdk facade runtime", () => {
expect(loaded.marker).toBe("post-load-ok");
expect(reentryMarkers.length).toBeGreaterThan(0);
const unexpectedReentryMarkers = reentryMarkers.filter((marker) => marker !== "post-load-ok");
expect(unexpectedReentryMarkers).toEqual([]);
expect(unexpectedReentryMarkers).toStrictEqual([]);
expect(listImportedBundledPluginFacadeIds()).toEqual(["demo"]);
expect(loader).toHaveBeenCalledTimes(1);
});
@@ -258,7 +258,7 @@ describe("plugin-sdk facade runtime", () => {
}),
).toThrow("plugin load failure");
expect(listImportedBundledPluginFacadeIds()).toEqual([]);
expect(listImportedBundledPluginFacadeIds()).toStrictEqual([]);
// A second call must also throw (not return a stale empty sentinel).
expect(() =>

View File

@@ -143,7 +143,9 @@ describe("fetchWithBearerAuthScopeFallback", () => {
expect(response.status).toBe(200);
expect(fetchFn).toHaveBeenCalledTimes(2);
expect(Object.getOwnPropertySymbols(fetchFn.mock.calls[0]?.[1]?.headers as object)).toEqual([]);
expect(
Object.getOwnPropertySymbols(fetchFn.mock.calls[0]?.[1]?.headers as object),
).toStrictEqual([]);
expect(new Headers(fetchFn.mock.calls[1]?.[1]?.headers).get("authorization")).toBe(
"Bearer token-1",
);

View File

@@ -273,6 +273,6 @@ describe("resolveClaudeThinkingProfile", () => {
const fixedBudgetLevels = profile.levels.filter(
(level) => level.id === "xhigh" || level.id === "max",
);
expect(fixedBudgetLevels).toEqual([]);
expect(fixedBudgetLevels).toStrictEqual([]);
});
});

View File

@@ -88,7 +88,7 @@ describe("buildProviderToolCompatFamilyHooks", () => {
} as never,
tools,
}),
).toEqual([]);
).toStrictEqual([]);
});
it("preserves explicit empty properties maps when normalizing strict openai schemas", () => {
@@ -217,7 +217,7 @@ describe("buildProviderToolCompatFamilyHooks", () => {
} as never,
tools: [permissiveTool],
}),
).toEqual([]);
).toStrictEqual([]);
});
it("skips openai strict-tool normalization on non-native routes", () => {
@@ -251,7 +251,7 @@ describe("buildProviderToolCompatFamilyHooks", () => {
} as never,
tools,
}),
).toEqual([]);
).toStrictEqual([]);
});
it("suppresses openai strict-schema diagnostics because transport falls back to strict false", () => {
@@ -286,7 +286,7 @@ describe("buildProviderToolCompatFamilyHooks", () => {
],
});
expect(diagnostics).toEqual([]);
expect(diagnostics).toStrictEqual([]);
});
it("covers the shared xAI tool compat patch", () => {

View File

@@ -65,7 +65,7 @@ describe("createWebSearchProviderContractFields", () => {
selectionPluginId: "ollama",
});
expect(fields.inactiveSecretPaths).toEqual([]);
expect(fields.inactiveSecretPaths).toStrictEqual([]);
expect(fields.getCredentialValue({ apiKey: "ignored" })).toBeUndefined();
const searchConfig = { apiKey: "ignored" };

View File

@@ -68,6 +68,6 @@ describe("OpenAI-family schema normalization runtime contract", () => {
model: createNativeOpenAICodexResponsesModel() as never,
tools: [tool] as never,
}),
).toEqual([]);
).toStrictEqual([]);
});
});