From e793b650734281ce643a8288f38904d70f9621d2 Mon Sep 17 00:00:00 2001 From: Shakker Date: Mon, 11 May 2026 20:36:57 +0100 Subject: [PATCH] test: refine external cli sync helpers --- .../auth-profiles.external-cli-sync.test.ts | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/agents/auth-profiles.external-cli-sync.test.ts b/src/agents/auth-profiles.external-cli-sync.test.ts index 9b7775b1eac..46d236cb37e 100644 --- a/src/agents/auth-profiles.external-cli-sync.test.ts +++ b/src/agents/auth-profiles.external-cli-sync.test.ts @@ -47,9 +47,12 @@ function expectSingleProfileCredential( profiles: ReturnType, profileId: string, ) { - expect(profiles).toHaveLength(1); - expect(profiles[0]?.profileId).toBe(profileId); - expect(profiles[0]?.credential).toBeTruthy(); + expect(profiles).toStrictEqual([ + expect.objectContaining({ + credential: expect.any(Object), + profileId, + }), + ]); return profiles[0]?.credential as Record; } @@ -57,9 +60,12 @@ function expectSingleProfile( profiles: ReturnType, profileId: string, ) { - expect(profiles).toHaveLength(1); - expect(profiles[0]?.profileId).toBe(profileId); - expect(profiles[0]?.credential).toBeTruthy(); + expect(profiles).toStrictEqual([ + expect.objectContaining({ + credential: expect.any(Object), + profileId, + }), + ]); return profiles[0]; } @@ -74,13 +80,13 @@ function expectCredentialFields( } function expectReaderPolicyCall(mock: { mock: { calls: unknown[][] } }) { - expect(mock.mock.calls).toHaveLength(1); - const [arg] = mock.mock.calls[0] ?? []; - expect(arg).toBeTruthy(); - if (!arg || typeof arg !== "object") { - throw new Error("Expected CLI reader options"); - } - expect((arg as { allowKeychainPrompt?: unknown }).allowKeychainPrompt).toBe(false); + expect(mock.mock.calls).toStrictEqual([ + [ + expect.objectContaining({ + allowKeychainPrompt: false, + }), + ], + ]); } describe("external cli oauth resolution", () => {