From 419b6e8993e4cdae729bba79edf3e48eb9f0d3f0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 8 May 2026 10:32:07 +0100 Subject: [PATCH] test: clarify legacy migration change assertions --- .../doctor/shared/legacy-config-migrate.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/commands/doctor/shared/legacy-config-migrate.test.ts b/src/commands/doctor/shared/legacy-config-migrate.test.ts index 65af434c683..ba9d3acbee6 100644 --- a/src/commands/doctor/shared/legacy-config-migrate.test.ts +++ b/src/commands/doctor/shared/legacy-config-migrate.test.ts @@ -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", () => {