mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 00:11:23 +00:00
refactor(test): share onboarding and model auth test helpers
This commit is contained in:
@@ -34,6 +34,23 @@ describe("applyAuthChoice (moonshot)", () => {
|
||||
}>(requireOpenClawAgentDir());
|
||||
}
|
||||
|
||||
async function runMoonshotCnFlow(params: {
|
||||
config: Record<string, unknown>;
|
||||
setDefaultModel: boolean;
|
||||
}) {
|
||||
const text = vi.fn().mockResolvedValue("sk-moonshot-cn-test");
|
||||
const prompter = createPrompter({ text: text as unknown as WizardPrompter["text"] });
|
||||
const runtime = createExitThrowingRuntime();
|
||||
const result = await applyAuthChoice({
|
||||
authChoice: "moonshot-api-key-cn",
|
||||
config: params.config,
|
||||
prompter,
|
||||
runtime,
|
||||
setDefaultModel: params.setDefaultModel,
|
||||
});
|
||||
return { result, text };
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await lifecycle.cleanup();
|
||||
});
|
||||
@@ -41,12 +58,7 @@ describe("applyAuthChoice (moonshot)", () => {
|
||||
it("keeps the .cn baseUrl when setDefaultModel is false", async () => {
|
||||
await setupTempState();
|
||||
|
||||
const text = vi.fn().mockResolvedValue("sk-moonshot-cn-test");
|
||||
const prompter = createPrompter({ text: text as unknown as WizardPrompter["text"] });
|
||||
const runtime = createExitThrowingRuntime();
|
||||
|
||||
const result = await applyAuthChoice({
|
||||
authChoice: "moonshot-api-key-cn",
|
||||
const { result, text } = await runMoonshotCnFlow({
|
||||
config: {
|
||||
agents: {
|
||||
defaults: {
|
||||
@@ -54,8 +66,6 @@ describe("applyAuthChoice (moonshot)", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
prompter,
|
||||
runtime,
|
||||
setDefaultModel: false,
|
||||
});
|
||||
|
||||
@@ -73,15 +83,8 @@ describe("applyAuthChoice (moonshot)", () => {
|
||||
it("sets the default model when setDefaultModel is true", async () => {
|
||||
await setupTempState();
|
||||
|
||||
const text = vi.fn().mockResolvedValue("sk-moonshot-cn-test");
|
||||
const prompter = createPrompter({ text: text as unknown as WizardPrompter["text"] });
|
||||
const runtime = createExitThrowingRuntime();
|
||||
|
||||
const result = await applyAuthChoice({
|
||||
authChoice: "moonshot-api-key-cn",
|
||||
const { result } = await runMoonshotCnFlow({
|
||||
config: {},
|
||||
prompter,
|
||||
runtime,
|
||||
setDefaultModel: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user