From 5605b31375ec9ae92c207a7aaf4d0cfd4ba144aa Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 29 Apr 2026 14:23:57 +0100 Subject: [PATCH] test: make doctor migration assertion order independent --- ...egacy-state-migrations-yes-mode-without.e2e.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts b/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts index 6ea4658bf4f..5a896425fd1 100644 --- a/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts +++ b/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts @@ -126,7 +126,15 @@ describe("doctor command", () => { } } - const written = writeConfigFile.mock.calls.at(-1)?.[0] as Record; + const written = writeConfigFile.mock.calls + .map((call) => call[0] as Record) + .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 }).profiles; expect(profiles["anthropic:me@example.com"]).toBeTruthy(); expect(profiles["anthropic:default"]).toBeUndefined();