mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 21:41:35 +00:00
* fix(crestodian): keep onboarding RPCs restart-safe * fix(profiles): isolate approval state migrations * fix(crestodian): bypass configured gateway setup * test(crestodian): type onboarding mocks * fix(onboarding): require inference before Crestodian * fix(onboarding): enforce verified inference handoff * fix(macos): reset setup on gateway endpoint edits * chore(i18n): refresh native source inventory * fix(gateway): keep socket on request cancellation * test(packaging): require workspace templates * fix(onboarding): bind setup to verified inference * fix(onboarding): align inference gate contracts * fix(crestodian): classify concurrent policy rejection * test(crestodian): expect registry restoration * fix(onboarding): bind setup to configured gateways * fix(codex): preserve startup phase deadlines * test(crestodian): match fail-closed policy ordering * test(onboarding): assert bound gateway handoff * fix(codex): bind runtime resolution to spawn cwd * test(crestodian): assert policy rejection order * fix(cli): preserve gateway routing across restarts * fix(macos): fail closed during gateway edits * test(macos): cover gateway route generation races * chore: keep release notes out of onboarding PR * fix(ci): refresh onboarding generated checks * style(swift): align gateway channel formatting * fix(ci): refresh plugin SDK surface budgets * fix(ci): resync native string inventory * refactor(swift): split gateway channel support * test(doctor): isolate plugin compatibility registry * test(macos): isolate gateway onboarding fixtures * test(macos): assert gateway lease health ordering * fix(codex): reconcile computer-use startup changes
101 lines
3.6 KiB
TypeScript
101 lines
3.6 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import { withoutPluginInstallRecords } from "../plugins/installed-plugin-index-records.js";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
commitConfigWriteWithPendingPluginInstalls: vi.fn(),
|
|
replaceConfigFile: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("../config/config.js", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("../config/config.js")>()),
|
|
replaceConfigFile: mocks.replaceConfigFile,
|
|
}));
|
|
|
|
vi.mock("../plugins/install-record-commit.js", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("../plugins/install-record-commit.js")>()),
|
|
commitConfigWriteWithPendingPluginInstalls: mocks.commitConfigWriteWithPendingPluginInstalls,
|
|
}));
|
|
|
|
import { writeWizardConfigFile } from "./setup.shared.js";
|
|
|
|
describe("writeWizardConfigFile pending install ownership", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
mocks.commitConfigWriteWithPendingPluginInstalls.mockImplementation(
|
|
async (params: { nextConfig: OpenClawConfig }) => ({
|
|
config: withoutPluginInstallRecords(params.nextConfig),
|
|
installRecords: {},
|
|
movedInstallRecords: true,
|
|
persistedHash: "test-hash",
|
|
}),
|
|
);
|
|
mocks.replaceConfigFile.mockResolvedValue({ persistedHash: "next-hash" });
|
|
});
|
|
|
|
it("rejects a normal write with pending records but no migration base", async () => {
|
|
const config: OpenClawConfig = {
|
|
plugins: { installs: { demo: { source: "npm", spec: "demo@1.0.0" } } },
|
|
};
|
|
|
|
await expect(writeWizardConfigFile(config, { allowConfigSizeDrop: false })).rejects.toThrow(
|
|
"declare migration ownership",
|
|
);
|
|
expect(mocks.commitConfigWriteWithPendingPluginInstalls).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("migrates the baseline as source before the final wizard write", async () => {
|
|
const baseConfig: OpenClawConfig = {
|
|
plugins: { installs: { demo: { source: "npm", spec: "demo@1.0.0" } } },
|
|
};
|
|
|
|
await writeWizardConfigFile(baseConfig, {
|
|
allowConfigSizeDrop: false,
|
|
migrationBaseConfig: baseConfig,
|
|
});
|
|
|
|
expect(mocks.commitConfigWriteWithPendingPluginInstalls).toHaveBeenNthCalledWith(
|
|
1,
|
|
expect.objectContaining({
|
|
nextConfig: baseConfig,
|
|
sourceConfig: baseConfig,
|
|
writeOptions: { allowConfigSizeDrop: true },
|
|
}),
|
|
);
|
|
expect(mocks.commitConfigWriteWithPendingPluginInstalls).toHaveBeenCalledTimes(2);
|
|
});
|
|
|
|
it("commits fresh pending records after baseline migration is complete", async () => {
|
|
const config: OpenClawConfig = {
|
|
plugins: { installs: { fresh: { source: "npm", spec: "fresh@1.0.0" } } },
|
|
};
|
|
|
|
await writeWizardConfigFile(config, {
|
|
allowConfigSizeDrop: false,
|
|
migrationBaseConfig: undefined,
|
|
});
|
|
|
|
expect(mocks.commitConfigWriteWithPendingPluginInstalls).toHaveBeenCalledOnce();
|
|
expect(mocks.commitConfigWriteWithPendingPluginInstalls).toHaveBeenCalledWith(
|
|
expect.objectContaining({ nextConfig: config }),
|
|
);
|
|
});
|
|
|
|
it("binds the final write to the live-verified config hash", async () => {
|
|
const config: OpenClawConfig = { gateway: { port: 18789 } };
|
|
|
|
await writeWizardConfigFile(config, { baseHash: "verified-hash" });
|
|
|
|
const commit = mocks.commitConfigWriteWithPendingPluginInstalls.mock.calls[0]?.[0]?.commit;
|
|
expect(commit).toBeTypeOf("function");
|
|
await commit(config);
|
|
expect(mocks.replaceConfigFile).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
nextConfig: config,
|
|
baseHash: "verified-hash",
|
|
afterWrite: { mode: "auto" },
|
|
}),
|
|
);
|
|
});
|
|
});
|