test: make doctor migration assertion order independent

This commit is contained in:
Peter Steinberger
2026-04-29 14:23:57 +01:00
parent 0be8d127d6
commit 5605b31375

View File

@@ -126,7 +126,15 @@ describe("doctor command", () => {
}
}
const written = writeConfigFile.mock.calls.at(-1)?.[0] as Record<string, unknown>;
const written = writeConfigFile.mock.calls
.map((call) => call[0] as Record<string, unknown>)
.find((candidate) => {
const auth = candidate.auth as { profiles?: unknown } | undefined;
return Boolean(auth?.profiles);
});
if (!written) {
throw new Error("Expected doctor to write migrated auth profiles");
}
const profiles = (written.auth as { profiles: Record<string, unknown> }).profiles;
expect(profiles["anthropic:me@example.com"]).toBeTruthy();
expect(profiles["anthropic:default"]).toBeUndefined();