From 3ee3fd72bbe43ef4cee58e777117f4f6536d499c Mon Sep 17 00:00:00 2001 From: Shakker Date: Sat, 9 May 2026 05:40:00 +0100 Subject: [PATCH] test: tighten registry empty array assertions --- src/daemon/service-env.test.ts | 4 +-- src/gateway/control-ui-csp.test.ts | 6 ++-- src/gateway/session-utils.test.ts | 4 +-- src/hooks/internal-hooks.test.ts | 4 +-- src/link-understanding/detect.test.ts | 36 ++++++++++--------- ...erver.shutdown-unhandled-rejection.test.ts | 2 +- src/model-catalog/manifest-planner.test.ts | 4 +-- src/plugin-sdk/keyed-async-queue.test.ts | 2 +- src/plugins/bundled-channel-runtime.test.ts | 4 +-- src/plugins/compaction-provider.test.ts | 8 ++--- src/plugins/effective-plugin-ids.test.ts | 4 +-- .../loader.native-module-loader.test.ts | 4 +-- .../provider-discovery.runtime.test.ts | 8 +++-- src/plugins/runtime-registry-boundary.test.ts | 2 +- .../status.compatibility.integration.test.ts | 4 +-- src/plugins/synthetic-auth.runtime.test.ts | 2 +- src/shared/device-bootstrap-profile.test.ts | 4 +-- src/shared/entry-status.test.ts | 2 +- src/shared/node-match.test.ts | 4 +-- src/shared/string-normalization.test.ts | 2 +- src/shared/usage-aggregates.test.ts | 2 +- src/terminal/table.test.ts | 2 +- src/trajectory/cleanup.test.ts | 2 +- src/trajectory/export.test.ts | 2 +- 24 files changed, 62 insertions(+), 56 deletions(-) diff --git a/src/daemon/service-env.test.ts b/src/daemon/service-env.test.ts index c9691e57a89..c071201e1d3 100644 --- a/src/daemon/service-env.test.ts +++ b/src/daemon/service-env.test.ts @@ -123,7 +123,7 @@ describe("getMinimalServicePathParts - Linux user directories", () => { "/sbin", ]); const userPathEntries = result.filter((entry) => entry.startsWith("/Users/testuser/")); - expect(userPathEntries).toEqual([]); + expect(userPathEntries).toStrictEqual([]); }); it("can include env-configured version manager dirs on macOS when requested", () => { @@ -169,7 +169,7 @@ describe("getMinimalServicePathParts - Linux user directories", () => { }); // Windows returns empty array (uses existing PATH) - expect(result).toEqual([]); + expect(result).toStrictEqual([]); }); it("omits hard-coded version-manager fallbacks on Linux when missing", () => { diff --git a/src/gateway/control-ui-csp.test.ts b/src/gateway/control-ui-csp.test.ts index 5467a297306..09c6680ea08 100644 --- a/src/gateway/control-ui-csp.test.ts +++ b/src/gateway/control-ui-csp.test.ts @@ -58,7 +58,7 @@ describe("buildControlUiCspHeader", () => { describe("computeInlineScriptHashes", () => { it("returns empty for HTML without scripts", () => { - expect(computeInlineScriptHashes("hi")).toEqual([]); + expect(computeInlineScriptHashes("hi")).toStrictEqual([]); }); it("hashes inline script content", () => { @@ -70,7 +70,7 @@ describe("computeInlineScriptHashes", () => { it("skips scripts with src attribute", () => { const hashes = computeInlineScriptHashes(''); - expect(hashes).toEqual([]); + expect(hashes).toStrictEqual([]); }); it("does not treat data-src as an external script attribute", () => { @@ -103,6 +103,6 @@ describe("computeInlineScriptHashes", () => { }); it("skips empty inline scripts", () => { - expect(computeInlineScriptHashes("")).toEqual([]); + expect(computeInlineScriptHashes("")).toStrictEqual([]); }); }); diff --git a/src/gateway/session-utils.test.ts b/src/gateway/session-utils.test.ts index cfbf622cbc7..8d8e12af792 100644 --- a/src/gateway/session-utils.test.ts +++ b/src/gateway/session-utils.test.ts @@ -318,8 +318,8 @@ describe("gateway session utils", () => { .filter((session) => !session.thinkingOptions?.includes("medium")) .map((session) => session.sessionId); - expect(missingMediumLevelSessionIds).toEqual([]); - expect(missingMediumOptionSessionIds).toEqual([]); + expect(missingMediumLevelSessionIds).toStrictEqual([]); + expect(missingMediumOptionSessionIds).toStrictEqual([]); expect(result.sessions.map((session) => session.thinkingDefault)).toEqual( Array.from({ length: result.sessions.length }, () => "medium"), ); diff --git a/src/hooks/internal-hooks.test.ts b/src/hooks/internal-hooks.test.ts index 5007b90de20..9258602dbff 100644 --- a/src/hooks/internal-hooks.test.ts +++ b/src/hooks/internal-hooks.test.ts @@ -458,7 +458,7 @@ describe("hooks", () => { it("should return empty array when no handlers are registered", () => { const keys = getRegisteredEventKeys(); - expect(keys).toEqual([]); + expect(keys).toStrictEqual([]); }); }); @@ -470,7 +470,7 @@ describe("hooks", () => { clearInternalHooks(); const keys = getRegisteredEventKeys(); - expect(keys).toEqual([]); + expect(keys).toStrictEqual([]); }); }); }); diff --git a/src/link-understanding/detect.test.ts b/src/link-understanding/detect.test.ts index 25747c48dac..01e5ae65851 100644 --- a/src/link-understanding/detect.test.ts +++ b/src/link-understanding/detect.test.ts @@ -25,38 +25,40 @@ describe("extractLinksFromMessage", () => { }); it("blocks localhost and common loopback addresses", () => { - expect(extractLinksFromMessage("http://localhost/secret")).toEqual([]); - expect(extractLinksFromMessage("http://localhost.localdomain/secret")).toEqual([]); - expect(extractLinksFromMessage("http://foo.localhost/secret")).toEqual([]); - expect(extractLinksFromMessage("http://service.local/secret")).toEqual([]); - expect(extractLinksFromMessage("http://service.internal/secret")).toEqual([]); - expect(extractLinksFromMessage("http://0.0.0.0/secret")).toEqual([]); - expect(extractLinksFromMessage("http://[::1]/secret")).toEqual([]); + expect(extractLinksFromMessage("http://localhost/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://localhost.localdomain/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://foo.localhost/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://service.local/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://service.internal/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://0.0.0.0/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://[::1]/secret")).toStrictEqual([]); }); it("blocks private network ranges", () => { - expect(extractLinksFromMessage("http://10.0.0.1/internal")).toEqual([]); - expect(extractLinksFromMessage("http://172.16.0.1/internal")).toEqual([]); - expect(extractLinksFromMessage("http://192.168.1.1/internal")).toEqual([]); + expect(extractLinksFromMessage("http://10.0.0.1/internal")).toStrictEqual([]); + expect(extractLinksFromMessage("http://172.16.0.1/internal")).toStrictEqual([]); + expect(extractLinksFromMessage("http://192.168.1.1/internal")).toStrictEqual([]); }); it("blocks link-local and cloud metadata addresses", () => { - expect(extractLinksFromMessage("http://169.254.169.254/latest/meta-data/")).toEqual([]); - expect(extractLinksFromMessage("http://169.254.1.1/test")).toEqual([]); + expect(extractLinksFromMessage("http://169.254.169.254/latest/meta-data/")).toStrictEqual([]); + expect(extractLinksFromMessage("http://169.254.1.1/test")).toStrictEqual([]); expect(extractLinksFromMessage("http://metadata.google.internal/computeMetadata/v1/")).toEqual( [], ); }); it("blocks CGNAT range used by Tailscale", () => { - expect(extractLinksFromMessage("http://100.100.50.1/test")).toEqual([]); + expect(extractLinksFromMessage("http://100.100.50.1/test")).toStrictEqual([]); }); it("blocks private and mapped IPv6 addresses", () => { - expect(extractLinksFromMessage("http://[::ffff:127.0.0.1]/secret")).toEqual([]); - expect(extractLinksFromMessage("http://[2001:db8:1234::5efe:127.0.0.1]/secret")).toEqual([]); - expect(extractLinksFromMessage("http://[fe80::1]/secret")).toEqual([]); - expect(extractLinksFromMessage("http://[fc00::1]/secret")).toEqual([]); + expect(extractLinksFromMessage("http://[::ffff:127.0.0.1]/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://[2001:db8:1234::5efe:127.0.0.1]/secret")).toStrictEqual( + [], + ); + expect(extractLinksFromMessage("http://[fe80::1]/secret")).toStrictEqual([]); + expect(extractLinksFromMessage("http://[fc00::1]/secret")).toStrictEqual([]); }); it("allows legitimate public URLs", () => { diff --git a/src/mcp/channel-server.shutdown-unhandled-rejection.test.ts b/src/mcp/channel-server.shutdown-unhandled-rejection.test.ts index ca0fb4a58cf..49b1bab0bb1 100644 --- a/src/mcp/channel-server.shutdown-unhandled-rejection.test.ts +++ b/src/mcp/channel-server.shutdown-unhandled-rejection.test.ts @@ -118,7 +118,7 @@ describe("serveOpenClawChannelMcp shutdown", () => { await servePromise; await new Promise((resolve) => setTimeout(resolve, 0)); - expect(unhandledRejections).toEqual([]); + expect(unhandledRejections).toStrictEqual([]); expect(bridgeState.close).toHaveBeenCalledTimes(1); }); }); diff --git a/src/model-catalog/manifest-planner.test.ts b/src/model-catalog/manifest-planner.test.ts index 55f03aa3b90..4b73844c40a 100644 --- a/src/model-catalog/manifest-planner.test.ts +++ b/src/model-catalog/manifest-planner.test.ts @@ -55,7 +55,7 @@ describe("manifest model catalog planner", () => { }, ]); expect(plan.rows.map((row) => row.ref)).toEqual(["moonshot/kimi-k2.6"]); - expect(plan.conflicts).toEqual([]); + expect(plan.conflicts).toStrictEqual([]); }); it("filters providers before row planning", () => { @@ -89,7 +89,7 @@ describe("manifest model catalog planner", () => { expect(plan.entries.map((entry) => entry.pluginId)).toEqual(["openrouter"]); expect(plan.rows.map((row) => row.ref)).toEqual(["openrouter/anthropic/claude-sonnet-4.6"]); - expect(plan.conflicts).toEqual([]); + expect(plan.conflicts).toStrictEqual([]); }); it("plans alias-filtered rows from owned provider catalogs", () => { diff --git a/src/plugin-sdk/keyed-async-queue.test.ts b/src/plugin-sdk/keyed-async-queue.test.ts index 7047c8240f2..245a45e1461 100644 --- a/src/plugin-sdk/keyed-async-queue.test.ts +++ b/src/plugin-sdk/keyed-async-queue.test.ts @@ -101,7 +101,7 @@ describe("enqueueKeyedTask", () => { ).rejects.toThrow("boom"); await new Promise((resolve) => setTimeout(resolve, 0)); - expect(unhandled).toEqual([]); + expect(unhandled).toStrictEqual([]); } finally { process.off("unhandledRejection", onUnhandledRejection); } diff --git a/src/plugins/bundled-channel-runtime.test.ts b/src/plugins/bundled-channel-runtime.test.ts index 4526162a317..8bf1e820384 100644 --- a/src/plugins/bundled-channel-runtime.test.ts +++ b/src/plugins/bundled-channel-runtime.test.ts @@ -25,7 +25,7 @@ describe("bundled channel runtime metadata", () => { it("preserves explicit empty bundled roots", () => { const tempRoot = createTempRoot(); - expect(listBundledChannelPluginMetadata({ rootDir: tempRoot })).toEqual([]); + expect(listBundledChannelPluginMetadata({ rootDir: tempRoot })).toStrictEqual([]); expect(resolveBundledChannelWorkspacePath({ rootDir: tempRoot, pluginId: "telegram" })).toBe( null, ); @@ -37,6 +37,6 @@ describe("bundled channel runtime metadata", () => { expect( listBundledChannelPluginMetadata({ rootDir: tempRoot, scanDir: missingScanDir }), - ).toEqual([]); + ).toStrictEqual([]); }); }); diff --git a/src/plugins/compaction-provider.test.ts b/src/plugins/compaction-provider.test.ts index e9ac9175415..7d42ba2a1d5 100644 --- a/src/plugins/compaction-provider.test.ts +++ b/src/plugins/compaction-provider.test.ts @@ -38,8 +38,8 @@ function requireCompactionProvider(id: string): CompactionProvider { describe("compaction provider registry", () => { it("starts empty", () => { - expect(listCompactionProviderIds()).toEqual([]); - expect(listRegisteredCompactionProviders()).toEqual([]); + expect(listCompactionProviderIds()).toStrictEqual([]); + expect(listRegisteredCompactionProviders()).toStrictEqual([]); }); it("returns undefined for an unknown id", () => { @@ -121,7 +121,7 @@ describe("compaction provider registry", () => { expect(listCompactionProviderIds()).toHaveLength(2); clearCompactionProviders(); - expect(listCompactionProviderIds()).toEqual([]); + expect(listCompactionProviderIds()).toStrictEqual([]); expect(getCompactionProvider("a")).toBeUndefined(); }); @@ -147,7 +147,7 @@ describe("compaction provider registry", () => { it("restore with empty array clears everything", () => { registerCompactionProvider(makeProvider("x")); restoreRegisteredCompactionProviders([]); - expect(listCompactionProviderIds()).toEqual([]); + expect(listCompactionProviderIds()).toStrictEqual([]); }); }); }); diff --git a/src/plugins/effective-plugin-ids.test.ts b/src/plugins/effective-plugin-ids.test.ts index cd22a238a3f..e2076c49f95 100644 --- a/src/plugins/effective-plugin-ids.test.ts +++ b/src/plugins/effective-plugin-ids.test.ts @@ -112,7 +112,7 @@ describe("resolveEffectivePluginIds", () => { slots: { contextEngine: "legacy" }, }, }), - ).toEqual([]); + ).toStrictEqual([]); }); it.each([ @@ -142,7 +142,7 @@ describe("resolveEffectivePluginIds", () => { ] satisfies Array<{ name: string; plugins: NonNullable }>)( "does not preload a selected context-engine slot when $name", ({ plugins }) => { - expect(resolve({ plugins })).toEqual([]); + expect(resolve({ plugins })).toStrictEqual([]); }, ); }); diff --git a/src/plugins/loader.native-module-loader.test.ts b/src/plugins/loader.native-module-loader.test.ts index 02bdbab312b..ab6c241d423 100644 --- a/src/plugins/loader.native-module-loader.test.ts +++ b/src/plugins/loader.native-module-loader.test.ts @@ -138,7 +138,7 @@ describe("createPluginModuleLoader", () => { }, }); - expect(sourceLoaderCalls).toEqual([]); + expect(sourceLoaderCalls).toStrictEqual([]); }); it("loads packaged JavaScript without creating a module loader", async () => { @@ -171,6 +171,6 @@ describe("createPluginModuleLoader", () => { }); expect(registry.plugins.find((plugin) => plugin.id === "npm-demo")?.status).toBe("loaded"); - expect(sourceLoaderCalls).toEqual([]); + expect(sourceLoaderCalls).toStrictEqual([]); }); }); diff --git a/src/plugins/provider-discovery.runtime.test.ts b/src/plugins/provider-discovery.runtime.test.ts index 11bbb08a711..2c7a150b5c9 100644 --- a/src/plugins/provider-discovery.runtime.test.ts +++ b/src/plugins/provider-discovery.runtime.test.ts @@ -237,8 +237,12 @@ describe("resolvePluginDiscoveryProvidersRuntime", () => { }, }); - expect(resolvePluginDiscoveryProvidersRuntime({ discoveryEntriesOnly: true })).toEqual([]); - expect(resolvePluginDiscoveryProvidersRuntime({ discoveryEntriesOnly: true })).toEqual([]); + expect(resolvePluginDiscoveryProvidersRuntime({ discoveryEntriesOnly: true })).toStrictEqual( + [], + ); + expect(resolvePluginDiscoveryProvidersRuntime({ discoveryEntriesOnly: true })).toStrictEqual( + [], + ); expect(mocks.resolvePluginProviders).not.toHaveBeenCalled(); }); }); diff --git a/src/plugins/runtime-registry-boundary.test.ts b/src/plugins/runtime-registry-boundary.test.ts index e13a53b9746..82a513f9fcb 100644 --- a/src/plugins/runtime-registry-boundary.test.ts +++ b/src/plugins/runtime-registry-boundary.test.ts @@ -46,6 +46,6 @@ describe("runtime plugin registry boundary", () => { ) .map((file) => file.relativePath); - expect(offenders).toEqual([]); + expect(offenders).toStrictEqual([]); }); }); diff --git a/src/plugins/status.compatibility.integration.test.ts b/src/plugins/status.compatibility.integration.test.ts index addbdb0617e..d29ce43488c 100644 --- a/src/plugins/status.compatibility.integration.test.ts +++ b/src/plugins/status.compatibility.integration.test.ts @@ -53,7 +53,7 @@ describe("plugin compatibility snapshot notices", () => { body: `module.exports = { id: "legacy-sidecar", register() {} };\n`, }); - expect(buildSnapshotCompatibilityNoticeCodes(plugin)).toEqual([]); + expect(buildSnapshotCompatibilityNoticeCodes(plugin)).toStrictEqual([]); }); it("does not report startup compatibility warnings for explicit startup-lazy manifests", () => { @@ -63,6 +63,6 @@ describe("plugin compatibility snapshot notices", () => { }); addStartupActivation(plugin.dir, false); - expect(buildSnapshotCompatibilityNoticeCodes(plugin)).toEqual([]); + expect(buildSnapshotCompatibilityNoticeCodes(plugin)).toStrictEqual([]); }); }); diff --git a/src/plugins/synthetic-auth.runtime.test.ts b/src/plugins/synthetic-auth.runtime.test.ts index 572d2c3efed..61a775e7bd2 100644 --- a/src/plugins/synthetic-auth.runtime.test.ts +++ b/src/plugins/synthetic-auth.runtime.test.ts @@ -74,7 +74,7 @@ describe("synthetic auth runtime refs", () => { diagnostics: [], }); - expect(resolveRuntimeSyntheticAuthProviderRefs()).toEqual([]); + expect(resolveRuntimeSyntheticAuthProviderRefs()).toStrictEqual([]); }); it("prefers the active runtime registry when plugins are already loaded", () => { diff --git a/src/shared/device-bootstrap-profile.test.ts b/src/shared/device-bootstrap-profile.test.ts index b2890aa8d19..61d71cf2fd5 100644 --- a/src/shared/device-bootstrap-profile.test.ts +++ b/src/shared/device-bootstrap-profile.test.ts @@ -21,7 +21,7 @@ describe("device bootstrap profile", () => { expect( resolveBootstrapProfileScopesForRole("node", ["node.exec", "operator.approvals"]), - ).toEqual([]); + ).toStrictEqual([]); }); test("bounds bootstrap handoff scopes across profile roles", () => { @@ -34,7 +34,7 @@ describe("device bootstrap profile", () => { expect( resolveBootstrapProfileScopesForRoles(["node"], ["node.exec", "operator.admin"]), - ).toEqual([]); + ).toStrictEqual([]); }); test("normalizes issued handoff profiles to the bootstrap allowlist", () => { diff --git a/src/shared/entry-status.test.ts b/src/shared/entry-status.test.ts index 68cce75c982..687c82ff42c 100644 --- a/src/shared/entry-status.test.ts +++ b/src/shared/entry-status.test.ts @@ -84,7 +84,7 @@ describe("shared/entry-status", () => { }); expect(result.requirementsSatisfied).toBe(true); - expect(result.missing.os).toEqual([]); + expect(result.missing.os).toStrictEqual([]); }); it("pulls metadata and frontmatter from entry objects in the entry wrapper", () => { diff --git a/src/shared/node-match.test.ts b/src/shared/node-match.test.ts index 2d16ca0ef59..03c093cca9e 100644 --- a/src/shared/node-match.test.ts +++ b/src/shared/node-match.test.ts @@ -19,8 +19,8 @@ describe("shared/node-match", () => { expect(resolveNodeMatches(nodes, "mac studio")).toEqual([nodes[0]]); expect(resolveNodeMatches(nodes, " Mac---Studio!! ")).toEqual([nodes[0]]); expect(resolveNodeMatches(nodes, "pi-456")).toEqual([nodes[1]]); - expect(resolveNodeMatches(nodes, "pi")).toEqual([]); - expect(resolveNodeMatches(nodes, " ")).toEqual([]); + expect(resolveNodeMatches(nodes, "pi")).toStrictEqual([]); + expect(resolveNodeMatches(nodes, " ")).toStrictEqual([]); }); it("resolves unique matches and prefers a unique connected node", () => { diff --git a/src/shared/string-normalization.test.ts b/src/shared/string-normalization.test.ts index 5e49c36ed14..d7ce98f8932 100644 --- a/src/shared/string-normalization.test.ts +++ b/src/shared/string-normalization.test.ts @@ -14,7 +14,7 @@ describe("shared/string-normalization", () => { "null", "obj", ]); - expect(normalizeStringEntries(undefined)).toEqual([]); + expect(normalizeStringEntries(undefined)).toStrictEqual([]); }); it("normalizes mixed allow-list entries to lowercase", () => { diff --git a/src/shared/usage-aggregates.test.ts b/src/shared/usage-aggregates.test.ts index dc6896b7490..3ab9af2a19b 100644 --- a/src/shared/usage-aggregates.test.ts +++ b/src/shared/usage-aggregates.test.ts @@ -120,7 +120,7 @@ describe("shared/usage-aggregates", () => { }); expect(tail.latency).toBeUndefined(); - expect(tail.dailyLatency).toEqual([]); + expect(tail.dailyLatency).toStrictEqual([]); }); it("normalizes zero-count daily latency entries to zero averages and mins", () => { diff --git a/src/terminal/table.test.ts b/src/terminal/table.test.ts index 8926da88958..c61082a661c 100644 --- a/src/terminal/table.test.ts +++ b/src/terminal/table.test.ts @@ -256,7 +256,7 @@ describe("wrapNoteMessage", () => { expect(lines.length).toBeGreaterThan(1); expect(lines[0]?.startsWith("- ")).toBe(true); const unindentedContinuationLines = lines.slice(1).filter((line) => !line.startsWith(" ")); - expect(unindentedContinuationLines).toEqual([]); + expect(unindentedContinuationLines).toStrictEqual([]); }); it("preserves long Windows paths without inserting spaces/newlines", () => { diff --git a/src/trajectory/cleanup.test.ts b/src/trajectory/cleanup.test.ts index 761d32fa3a2..0ad72c9844f 100644 --- a/src/trajectory/cleanup.test.ts +++ b/src/trajectory/cleanup.test.ts @@ -76,7 +76,7 @@ describe("trajectory cleanup", () => { restrictToStoreDir: true, }); - expect(removed).toEqual([]); + expect(removed).toStrictEqual([]); expect((await fs.stat(runtimeFile)).isFile()).toBe(true); expect((await fs.stat(pointerPath)).isFile()).toBe(true); }); diff --git a/src/trajectory/export.test.ts b/src/trajectory/export.test.ts index a8b99032d0a..35e2c777ef5 100644 --- a/src/trajectory/export.test.ts +++ b/src/trajectory/export.test.ts @@ -772,7 +772,7 @@ describe("exportTrajectoryBundle", () => { "tools.json", ]); const emptyContents = (manifest.contents ?? []).filter((entry) => entry.bytes <= 0); - expect(emptyContents).toEqual([]); + expect(emptyContents).toStrictEqual([]); const metadata = JSON.parse(fs.readFileSync(path.join(outputDir, "metadata.json"), "utf8")) as { skills?: { entries?: Array<{ id?: string; invoked?: boolean }> };