diff --git a/desktop/src/features/communities/useCommunityInit.test.mjs b/desktop/src/features/communities/useCommunityInit.test.mjs index 8f8004c778..9c9165eb9f 100644 --- a/desktop/src/features/communities/useCommunityInit.test.mjs +++ b/desktop/src/features/communities/useCommunityInit.test.mjs @@ -330,7 +330,7 @@ test("useCommunityInit keeps cancellation visible while browser enterprise login try { const hook = renderHook(() => - useCommunityInit(testCommunity(), "community-key", false, true), + useCommunityInit(testCommunity(), "community-key", null, false, true), ); await waitFor(() => assert.ok("enterpriseLogin" in hook.result.current)); @@ -408,7 +408,7 @@ test("useCommunityInit surfaces recovery after rejected enterprise browser login try { const hook = renderHook(() => - useCommunityInit(testCommunity(), "community-key", false, true), + useCommunityInit(testCommunity(), "community-key", null, false, true), ); await waitFor(() => assert.ok("enterpriseLogin" in hook.result.current)); @@ -466,7 +466,7 @@ test("useCommunityInit ignores successful enterprise login completion after canc try { const hook = renderHook(() => - useCommunityInit(testCommunity(), "community-key", false, true), + useCommunityInit(testCommunity(), "community-key", 7, false, true), ); await waitFor(() => assert.ok("enterpriseLogin" in hook.result.current)); @@ -488,6 +488,7 @@ test("useCommunityInit ignores successful enterprise login completion after canc await waitFor(() => assert.equal(hook.result.current.error, "Enterprise sign-in canceled"), ); + assert.equal(hook.result.current.initAttempt, 7); assert.equal("enterpriseLogin" in hook.result.current, false); assert.equal( calls.some(([command]) => command === "apply_workspace"), @@ -540,7 +541,8 @@ test("useCommunityInit keeps a newer community prompt when stale enterprise logi try { const hook = renderHook( - ({ community, key }) => useCommunityInit(community, key, false, true), + ({ community, key }) => + useCommunityInit(community, key, null, false, true), { initialProps: { community: communityA, key: "community-a-key" } }, ); diff --git a/desktop/src/features/communities/useCommunityInit.ts b/desktop/src/features/communities/useCommunityInit.ts index e4af1ce60c..ffb9df2bac 100644 --- a/desktop/src/features/communities/useCommunityInit.ts +++ b/desktop/src/features/communities/useCommunityInit.ts @@ -152,6 +152,7 @@ type CommunityInitResult = type EnterpriseLoginController = { attemptId: string; + initAttempt: number | null; browserStarted: boolean; resolve: ((allowed: boolean) => void) | null; retired: boolean; @@ -211,6 +212,7 @@ export function useCommunityInit( isReady: false, needsSetup: false, appliedKey: null, + initAttempt: controller?.initAttempt ?? null, error: "Enterprise sign-in canceled", }); if (controller?.browserStarted) { @@ -428,6 +430,7 @@ export function useCommunityInit( }`; const enterpriseLoginController: EnterpriseLoginController = { attemptId: enterpriseLoginAttemptId, + initAttempt, browserStarted: false, resolve: null, retired: false,