mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-20 01:11:18 +00:00
test: remove duplicate and theatrical tests (#2677)
Consolidated redundant test setups in agent-tarball and cmdrun-happy-path test suites: - agent-tarball.test.ts: merged 4 mirror-cmd tests (all invoking the same tryTarballInstall call and inspecting the same mirrorCmd string) into a single test with shared beforeEach setup. Retained the non-fatal failure test separately since it has a different mock setup. - cmdrun-happy-path.test.ts: collapsed 3 identical-setup dry-run tests into one consolidated test, and merged the two same-invocation launch-message tests into one. Each removed test was a pure duplicate of setup + assertion that could be expressed as additional expects in the same test. Net: 1417 → 1411 tests (-6), 0 regressions. Co-authored-by: spawn-qa-bot <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
This commit is contained in:
parent
0ea2692e1e
commit
0f0bdf229f
2 changed files with 15 additions and 67 deletions
|
|
@ -171,15 +171,21 @@ describe("tryTarballInstall", () => {
|
|||
});
|
||||
|
||||
describe("non-root home directory mirroring", () => {
|
||||
it("mirrors dotfiles from /root/ to $HOME for non-root users", async () => {
|
||||
let mirrorCmd: string;
|
||||
|
||||
beforeEach(async () => {
|
||||
const fetchFn = mockFetch(new Response(JSON.stringify(RELEASE_PAYLOAD)));
|
||||
const runner = createMockRunner();
|
||||
|
||||
await tryTarballInstall(runner, "openclaw", fetchFn);
|
||||
mirrorCmd = String(runner.runServer.mock.calls[1][0]);
|
||||
});
|
||||
|
||||
const mirrorCmd = String(runner.runServer.mock.calls[1][0]);
|
||||
it("mirrors dotfiles from /root/ to $HOME with non-root guard and ownership fix", () => {
|
||||
expect(mirrorCmd).toContain("cp -a");
|
||||
expect(mirrorCmd).toContain('"$HOME/$_d"');
|
||||
expect(mirrorCmd).toContain('if [ "$(id -u)" != "0" ]; then');
|
||||
expect(mirrorCmd).toContain('chown -R "$(id -u):$(id -g)"');
|
||||
expect(mirrorCmd).toContain('cp /root/.spawn-tarball "$HOME/.spawn-tarball"');
|
||||
for (const dir of [
|
||||
".claude",
|
||||
".local",
|
||||
|
|
@ -193,16 +199,6 @@ describe("tryTarballInstall", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("mirrors the .spawn-tarball marker file", async () => {
|
||||
const fetchFn = mockFetch(new Response(JSON.stringify(RELEASE_PAYLOAD)));
|
||||
const runner = createMockRunner();
|
||||
|
||||
await tryTarballInstall(runner, "openclaw", fetchFn);
|
||||
|
||||
const mirrorCmd = String(runner.runServer.mock.calls[1][0]);
|
||||
expect(mirrorCmd).toContain('cp /root/.spawn-tarball "$HOME/.spawn-tarball"');
|
||||
});
|
||||
|
||||
it("returns true even when mirror step fails (non-fatal)", async () => {
|
||||
const fetchFn = mockFetch(new Response(JSON.stringify(RELEASE_PAYLOAD)));
|
||||
const runner = createMockRunner();
|
||||
|
|
@ -212,25 +208,5 @@ describe("tryTarballInstall", () => {
|
|||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("guards mirror behind non-root check (id -u)", async () => {
|
||||
const fetchFn = mockFetch(new Response(JSON.stringify(RELEASE_PAYLOAD)));
|
||||
const runner = createMockRunner();
|
||||
|
||||
await tryTarballInstall(runner, "openclaw", fetchFn);
|
||||
|
||||
const mirrorCmd = String(runner.runServer.mock.calls[1][0]);
|
||||
expect(mirrorCmd).toContain('if [ "$(id -u)" != "0" ]; then');
|
||||
});
|
||||
|
||||
it("fixes ownership of mirrored files with chown", async () => {
|
||||
const fetchFn = mockFetch(new Response(JSON.stringify(RELEASE_PAYLOAD)));
|
||||
const runner = createMockRunner();
|
||||
|
||||
await tryTarballInstall(runner, "openclaw", fetchFn);
|
||||
|
||||
const mirrorCmd = String(runner.runServer.mock.calls[1][0]);
|
||||
expect(mirrorCmd).toContain('chown -R "$(id -u):$(id -g)"');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ describe("cmdRun happy-path pipeline", () => {
|
|||
// ── Dry-run mode ──────────────────────────────────────────────────────────
|
||||
|
||||
describe("dry-run mode skips download", () => {
|
||||
it("should not download script in dry-run mode", async () => {
|
||||
it("should skip download, skip history, and show preview with agent/cloud info", async () => {
|
||||
global.fetch = mockFetchForDownload({
|
||||
primaryOk: true,
|
||||
});
|
||||
|
|
@ -449,31 +449,15 @@ describe("cmdRun happy-path pipeline", () => {
|
|||
|
||||
await cmdRun("claude", "sprite", undefined, true);
|
||||
|
||||
// In dry-run, only manifest fetch should occur (no script download)
|
||||
// No script download — only manifest fetch
|
||||
const scriptFetches = fetchCalls.filter((c) => c.url.includes("openrouter.ai") && !c.url.includes("manifest"));
|
||||
expect(scriptFetches).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("should not save history in dry-run mode", async () => {
|
||||
global.fetch = mockFetchForDownload({
|
||||
primaryOk: true,
|
||||
});
|
||||
await loadManifest(true);
|
||||
|
||||
await cmdRun("claude", "sprite", undefined, true);
|
||||
|
||||
// No history written
|
||||
const historyPath = join(historyDir, "history.json");
|
||||
expect(existsSync(historyPath)).toBe(false);
|
||||
});
|
||||
|
||||
it("should show dry-run preview with agent and cloud info", async () => {
|
||||
global.fetch = mockFetchForDownload({
|
||||
primaryOk: true,
|
||||
});
|
||||
await loadManifest(true);
|
||||
|
||||
await cmdRun("claude", "sprite", undefined, true);
|
||||
|
||||
// Preview shows agent and cloud names
|
||||
const allOutput = consoleMocks.log.mock.calls.map((c: unknown[]) => c.join(" ")).join("\n");
|
||||
expect(allOutput).toContain("Claude Code");
|
||||
expect(allOutput).toContain("Sprite");
|
||||
|
|
@ -495,7 +479,7 @@ describe("cmdRun happy-path pipeline", () => {
|
|||
// ── Launch message formatting ─────────────────────────────────────────────
|
||||
|
||||
describe("launch step message", () => {
|
||||
it("should show 'Launching <agent> on <cloud>' for normal run", async () => {
|
||||
it("should show 'Launching <agent> on <cloud>' without 'with prompt' when no prompt given", async () => {
|
||||
global.fetch = mockFetchForDownload({
|
||||
primaryOk: true,
|
||||
});
|
||||
|
|
@ -508,6 +492,7 @@ describe("cmdRun happy-path pipeline", () => {
|
|||
expect(launchMsg).toBeDefined();
|
||||
expect(launchMsg).toContain("Claude Code");
|
||||
expect(launchMsg).toContain("Sprite");
|
||||
expect(launchMsg).not.toContain("with prompt");
|
||||
});
|
||||
|
||||
it("should append 'with prompt...' when prompt is provided", async () => {
|
||||
|
|
@ -522,19 +507,6 @@ describe("cmdRun happy-path pipeline", () => {
|
|||
const launchMsg = stepCalls.find((msg: string) => msg.includes("Launching"));
|
||||
expect(launchMsg).toContain("with prompt");
|
||||
});
|
||||
|
||||
it("should append '...' without prompt when no prompt provided", async () => {
|
||||
global.fetch = mockFetchForDownload({
|
||||
primaryOk: true,
|
||||
});
|
||||
await loadManifest(true);
|
||||
|
||||
await cmdRun("claude", "sprite");
|
||||
|
||||
const stepCalls = mockLogStep.mock.calls.map((c: unknown[]) => c.join(" "));
|
||||
const launchMsg = stepCalls.find((msg: string) => msg.includes("Launching"));
|
||||
expect(launchMsg).not.toContain("with prompt");
|
||||
});
|
||||
});
|
||||
|
||||
// ── Script content validation ─────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue