test: clarify legacy migration change assertions

This commit is contained in:
Peter Steinberger
2026-05-08 10:32:07 +01:00
parent 3f1e422859
commit 419b6e8993

View File

@@ -19,6 +19,13 @@ function migrateLegacyConfigForTest(raw: unknown): {
: { config: next as OpenClawConfig, changes };
}
function expectMigrationChangesToIncludeFragments(changes: string[], fragments: string[]): void {
const unmatchedFragments = fragments.filter((fragment) =>
changes.every((change) => !change.includes(fragment)),
);
expect({ changes, unmatchedFragments }).toMatchObject({ unmatchedFragments: [] });
}
describe("legacy session maintenance migrate", () => {
it("removes deprecated session.maintenance.rotateBytes", () => {
const res = migrateLegacyConfigForTest({
@@ -666,8 +673,10 @@ describe("legacy migrate controlUi.allowedOrigins seed (issue #29385)", () => {
"http://localhost:18789",
"http://127.0.0.1:18789",
]);
expect(res.changes.some((c) => c.includes("gateway.controlUi.allowedOrigins"))).toBe(true);
expect(res.changes.some((c) => c.includes("bind=lan"))).toBe(true);
expectMigrationChangesToIncludeFragments(res.changes, [
"gateway.controlUi.allowedOrigins",
"bind=lan",
]);
});
it("seeds allowedOrigins using configured port", () => {
@@ -734,7 +743,7 @@ describe("legacy migrate controlUi.allowedOrigins seed (issue #29385)", () => {
"http://localhost:18789",
"http://127.0.0.1:18789",
]);
expect(res.changes.some((c) => c.includes("gateway.controlUi.allowedOrigins"))).toBe(true);
expectMigrationChangesToIncludeFragments(res.changes, ["gateway.controlUi.allowedOrigins"]);
});
it("does not migrate loopback bind — returns null", () => {