refactor(test): share onboarding and model auth test helpers

This commit is contained in:
Peter Steinberger
2026-02-16 16:48:36 +00:00
parent ac5f6e7c9d
commit 2d8edf85ad
10 changed files with 253 additions and 244 deletions

View File

@@ -67,6 +67,14 @@ async function runInitialValueForChannel(channel: "dev" | "beta") {
return select.mock.calls[0]?.[0]?.initialValue;
}
function expectPluginLoadedFromLocalPath(
result: Awaited<ReturnType<typeof ensureOnboardingPluginInstalled>>,
) {
const expectedPath = path.resolve(process.cwd(), "extensions/zalo");
expect(result.installed).toBe(true);
expect(result.cfg.plugins?.load?.paths).toContain(expectedPath);
}
describe("ensureOnboardingPluginInstalled", () => {
it("installs from npm and enables the plugin", async () => {
const runtime = makeRuntime();
@@ -115,9 +123,7 @@ describe("ensureOnboardingPluginInstalled", () => {
runtime,
});
const expectedPath = path.resolve(process.cwd(), "extensions/zalo");
expect(result.installed).toBe(true);
expect(result.cfg.plugins?.load?.paths).toContain(expectedPath);
expectPluginLoadedFromLocalPath(result);
expect(result.cfg.plugins?.entries?.zalo?.enabled).toBe(true);
});
@@ -152,9 +158,7 @@ describe("ensureOnboardingPluginInstalled", () => {
runtime,
});
const expectedPath = path.resolve(process.cwd(), "extensions/zalo");
expect(result.installed).toBe(true);
expect(result.cfg.plugins?.load?.paths).toContain(expectedPath);
expectPluginLoadedFromLocalPath(result);
expect(note).toHaveBeenCalled();
expect(runtime.error).not.toHaveBeenCalled();
});