fix(browser-cli): rename --profile to --browser-profile to avoid conflict with global --profile flag
This commit is contained in:
committed by
Peter Steinberger
parent
2dd6b3aeb2
commit
40758b16a9
79
src/cli/browser-cli.test.ts
Normal file
79
src/cli/browser-cli.test.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { Command } from "commander";
|
||||
|
||||
describe("browser CLI --browser-profile flag", () => {
|
||||
it("parses --browser-profile from parent command options", () => {
|
||||
const program = new Command();
|
||||
program.name("test");
|
||||
|
||||
const browser = program
|
||||
.command("browser")
|
||||
.option("--browser-profile <name>", "Browser profile name");
|
||||
|
||||
let capturedProfile: string | undefined;
|
||||
|
||||
browser.command("status").action((_opts, cmd) => {
|
||||
const parent = cmd.parent?.opts?.() as { browserProfile?: string };
|
||||
capturedProfile = parent?.browserProfile;
|
||||
});
|
||||
|
||||
program.parse(["node", "test", "browser", "--browser-profile", "onasset", "status"]);
|
||||
|
||||
expect(capturedProfile).toBe("onasset");
|
||||
});
|
||||
|
||||
it("defaults to undefined when --browser-profile not provided", () => {
|
||||
const program = new Command();
|
||||
program.name("test");
|
||||
|
||||
const browser = program
|
||||
.command("browser")
|
||||
.option("--browser-profile <name>", "Browser profile name");
|
||||
|
||||
let capturedProfile: string | undefined = "should-be-undefined";
|
||||
|
||||
browser.command("status").action((_opts, cmd) => {
|
||||
const parent = cmd.parent?.opts?.() as { browserProfile?: string };
|
||||
capturedProfile = parent?.browserProfile;
|
||||
});
|
||||
|
||||
program.parse(["node", "test", "browser", "status"]);
|
||||
|
||||
expect(capturedProfile).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not conflict with global --profile flag", () => {
|
||||
// The global --profile flag is handled by entry.js before Commander
|
||||
// This test verifies --browser-profile is a separate option
|
||||
const program = new Command();
|
||||
program.name("test");
|
||||
program.option("--profile <name>", "Global config profile");
|
||||
|
||||
const browser = program
|
||||
.command("browser")
|
||||
.option("--browser-profile <name>", "Browser profile name");
|
||||
|
||||
let globalProfile: string | undefined;
|
||||
let browserProfile: string | undefined;
|
||||
|
||||
browser.command("status").action((_opts, cmd) => {
|
||||
const parent = cmd.parent?.opts?.() as { browserProfile?: string };
|
||||
browserProfile = parent?.browserProfile;
|
||||
globalProfile = program.opts().profile;
|
||||
});
|
||||
|
||||
program.parse([
|
||||
"node",
|
||||
"test",
|
||||
"--profile",
|
||||
"dev",
|
||||
"browser",
|
||||
"--browser-profile",
|
||||
"onasset",
|
||||
"status",
|
||||
]);
|
||||
|
||||
expect(globalProfile).toBe("dev");
|
||||
expect(browserProfile).toBe("onasset");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user