test: add tests for extraArgs filtering logic

Address review feedback: add tests covering empty strings,
non-strings, mixed arrays, and non-array inputs for extraArgs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JayMishra-github
2026-02-16 10:44:47 -08:00
committed by Peter Steinberger
parent cc3c25e413
commit 47f8c9209f

View File

@@ -149,4 +149,37 @@ describe("browser config", () => {
expect(resolveProfile(resolved, "chrome")).toBe(null);
expect(resolved.defaultProfile).toBe("openclaw");
});
it("defaults extraArgs to empty array when not provided", () => {
const resolved = resolveBrowserConfig(undefined);
expect(resolved.extraArgs).toEqual([]);
});
it("passes through valid extraArgs strings", () => {
const resolved = resolveBrowserConfig({
extraArgs: ["--no-sandbox", "--disable-gpu"],
});
expect(resolved.extraArgs).toEqual(["--no-sandbox", "--disable-gpu"]);
});
it("filters out empty strings and whitespace-only entries from extraArgs", () => {
const resolved = resolveBrowserConfig({
extraArgs: ["--flag", "", " ", "--other"],
});
expect(resolved.extraArgs).toEqual(["--flag", "--other"]);
});
it("filters out non-string entries from extraArgs", () => {
const resolved = resolveBrowserConfig({
extraArgs: ["--flag", 42, null, undefined, true, "--other"] as unknown as string[],
});
expect(resolved.extraArgs).toEqual(["--flag", "--other"]);
});
it("defaults extraArgs to empty array when set to non-array", () => {
const resolved = resolveBrowserConfig({
extraArgs: "not-an-array" as unknown as string[],
});
expect(resolved.extraArgs).toEqual([]);
});
});