diff --git a/src/cli/completion-cli.write-state.test.ts b/src/cli/completion-cli.write-state.test.ts index 6278afc51f7..c50ccce7ada 100644 --- a/src/cli/completion-cli.write-state.test.ts +++ b/src/cli/completion-cli.write-state.test.ts @@ -94,16 +94,21 @@ describe("completion-cli write-state", () => { await program.parseAsync(["completion", "--write-state"], { from: "user" }); const cacheDir = path.join(stateDir, "completions"); - expect(await fs.readdir(cacheDir)).toEqual( - expect.arrayContaining(["openclaw.bash", "openclaw.fish", "openclaw.ps1", "openclaw.zsh"]), - ); - expect(registerSubCliByNameMock).toHaveBeenCalledWith(program, "qa", expect.any(Array), { - purpose: "completion", - }); + expect((await fs.readdir(cacheDir)).sort()).toEqual([ + "openclaw.bash", + "openclaw.fish", + "openclaw.ps1", + "openclaw.zsh", + ]); + expect(registerSubCliByNameMock.mock.calls).toEqual([ + [program, "qa", process.argv, { purpose: "completion" }], + ]); expect(registerPluginCliCommandsFromValidatedConfigMock).toHaveBeenCalledTimes(1); - expect(stderrWrites).toHaveBeenCalledWith( - expect.stringContaining("skipping subcommand `qa` while building completion cache"), - ); + expect(stderrWrites.mock.calls).toEqual([ + [ + "[completion] skipping subcommand `qa` while building completion cache: qa scenario pack not found: qa/scenarios/index.md\n", + ], + ]); await fs.rm(stateDir, { recursive: true, force: true }); await fs.rm(homeDir, { recursive: true, force: true }); @@ -128,13 +133,16 @@ describe("completion-cli write-state", () => { await program.parseAsync(["completion", "--write-state"], { from: "user" }); - expect(registerSubCliByNameMock).toHaveBeenCalledWith(program, "qa", expect.any(Array), { - purpose: "completion", - }); + expect(registerSubCliByNameMock.mock.calls).toEqual([ + [program, "qa", process.argv, { purpose: "completion" }], + ]); expect(registerPluginCliCommandsFromValidatedConfigMock).not.toHaveBeenCalled(); - expect(await fs.readdir(path.join(stateDir, "completions"))).toEqual( - expect.arrayContaining(["openclaw.bash", "openclaw.fish", "openclaw.ps1", "openclaw.zsh"]), - ); + expect((await fs.readdir(path.join(stateDir, "completions"))).sort()).toEqual([ + "openclaw.bash", + "openclaw.fish", + "openclaw.ps1", + "openclaw.zsh", + ]); } finally { delete process.env[COMPLETION_SKIP_PLUGIN_COMMANDS_ENV]; await fs.rm(stateDir, { recursive: true, force: true });