mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 06:14:34 +00:00
refactor(agent): dedupe harness and command workflows
This commit is contained in:
@@ -1,25 +1,32 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { setupOnboardingShellCompletion } from "./onboarding.completion.js";
|
||||
|
||||
function createPrompter(confirmValue = false) {
|
||||
return {
|
||||
confirm: vi.fn(async () => confirmValue),
|
||||
note: vi.fn(async () => {}),
|
||||
};
|
||||
}
|
||||
|
||||
function createDeps() {
|
||||
return {
|
||||
resolveCliName: () => "openclaw",
|
||||
checkShellCompletionStatus: vi.fn(async () => ({
|
||||
shell: "zsh",
|
||||
profileInstalled: false,
|
||||
cacheExists: false,
|
||||
cachePath: "/tmp/openclaw.zsh",
|
||||
usesSlowPattern: false,
|
||||
})),
|
||||
ensureCompletionCacheExists: vi.fn(async () => true),
|
||||
installCompletion: vi.fn(async () => {}),
|
||||
};
|
||||
}
|
||||
|
||||
describe("setupOnboardingShellCompletion", () => {
|
||||
it("QuickStart: installs without prompting", async () => {
|
||||
const prompter = {
|
||||
confirm: vi.fn(async () => false),
|
||||
note: vi.fn(async () => {}),
|
||||
};
|
||||
|
||||
const deps = {
|
||||
resolveCliName: () => "openclaw",
|
||||
checkShellCompletionStatus: vi.fn(async () => ({
|
||||
shell: "zsh",
|
||||
profileInstalled: false,
|
||||
cacheExists: false,
|
||||
cachePath: "/tmp/openclaw.zsh",
|
||||
usesSlowPattern: false,
|
||||
})),
|
||||
ensureCompletionCacheExists: vi.fn(async () => true),
|
||||
installCompletion: vi.fn(async () => {}),
|
||||
};
|
||||
const prompter = createPrompter();
|
||||
const deps = createDeps();
|
||||
|
||||
await setupOnboardingShellCompletion({ flow: "quickstart", prompter, deps });
|
||||
|
||||
@@ -30,23 +37,8 @@ describe("setupOnboardingShellCompletion", () => {
|
||||
});
|
||||
|
||||
it("Advanced: prompts; skip means no install", async () => {
|
||||
const prompter = {
|
||||
confirm: vi.fn(async () => false),
|
||||
note: vi.fn(async () => {}),
|
||||
};
|
||||
|
||||
const deps = {
|
||||
resolveCliName: () => "openclaw",
|
||||
checkShellCompletionStatus: vi.fn(async () => ({
|
||||
shell: "zsh",
|
||||
profileInstalled: false,
|
||||
cacheExists: false,
|
||||
cachePath: "/tmp/openclaw.zsh",
|
||||
usesSlowPattern: false,
|
||||
})),
|
||||
ensureCompletionCacheExists: vi.fn(async () => true),
|
||||
installCompletion: vi.fn(async () => {}),
|
||||
};
|
||||
const prompter = createPrompter();
|
||||
const deps = createDeps();
|
||||
|
||||
await setupOnboardingShellCompletion({ flow: "advanced", prompter, deps });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user