Files
paseo/packages/cli/src/run.test.ts
T
Mohamed BoudraandGitHub d2de309fc3 Make relay opt-in when pairing devices (#2706)
* feat: make relay opt-in for device pairing

* fix(relay): keep pairing state authoritative

* fix(relay): refresh pairing state across transports

* fix(onboard): honor explicit relay opt-out

* fix(relay): surface transport startup failures

* fix(pairing): gate offers for older daemons

* test(cli): rely on real pairing transport coverage

* fix(cli): report live relay without a pid file

* fix(relay): synchronize config during daemon startup

* fix(relay): preserve mutability for ignored overrides

* fix(cli): use reachable daemon for pairing

* fix(app): redirect invalid pair device routes

* fix(pairing): support remote host device pairing

Keep Pair Device host-relative through the existing settings and daemon RPC flow. Route CLI output through an injected adapter so workflow tests do not mutate process globals.

* fix(pairing): validate pairing destinations

Expose the host-relative Pair Device flow on every supported app platform. Reject a reachable daemon whose identity does not match the requested Paseo home before reading or mutating its pairing state.

* fix(pairing): render QR codes across platforms

Generate SVG text without DOM or canvas and render it through the existing cross-platform SVG stack.

* fix(cli): pair from persisted relay state

Allow explicit relay pairing while the daemon is stopped when relay is already enabled in persisted configuration.
2026-08-01 04:35:06 +08:00

76 lines
2.0 KiB
TypeScript

import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { createCliParseArgv } from "./run";
describe("runCli", () => {
it("defaults an empty CLI invocation to onboard", () => {
expect(
createCliParseArgv({
argv: [],
cwd: process.cwd(),
nodeArgv: ["node", "paseo"],
}),
).toEqual(["node", "paseo", "onboard"]);
});
it("routes explicit root relay flags to onboard", () => {
expect(
createCliParseArgv({
argv: ["--relay"],
cwd: process.cwd(),
nodeArgv: ["node", "paseo"],
}),
).toEqual(["node", "paseo", "onboard", "--relay"]);
expect(
createCliParseArgv({
argv: ["--no-relay"],
cwd: process.cwd(),
nodeArgv: ["node", "paseo"],
}),
).toEqual(["node", "paseo", "onboard", "--no-relay"]);
});
it("preserves known CLI command argv", () => {
expect(
createCliParseArgv({
argv: ["daemon", "set-password"],
cwd: process.cwd(),
nodeArgv: ["node", "paseo"],
}),
).toEqual(["node", "paseo", "daemon", "set-password"]);
});
it("preserves the hooks command argv", () => {
expect(
createCliParseArgv({
argv: ["hooks", "claude", "UserPromptSubmit"],
cwd: process.cwd(),
nodeArgv: ["node", "paseo"],
}),
).toEqual(["node", "paseo", "hooks", "claude", "UserPromptSubmit"]);
});
it("classifies existing unknown directories as open-project invocations", () => {
const root = mkdtempSync(path.join(tmpdir(), "paseo-cli-run-"));
const project = path.join(root, "project");
mkdirSync(project);
try {
expect(
createCliParseArgv({
argv: ["project"],
cwd: root,
nodeArgv: ["node", "paseo"],
}),
).toEqual({
kind: "open-project",
resolvedPath: project,
});
} finally {
rmSync(root, { recursive: true, force: true });
}
});
});