diff --git a/packages/clerk-js/src/utils/__tests__/completeSignUpFlow.test.ts b/packages/clerk-js/src/utils/__tests__/completeSignUpFlow.test.ts index dab6d593c66..f4c1fcb5607 100644 --- a/packages/clerk-js/src/utils/__tests__/completeSignUpFlow.test.ts +++ b/packages/clerk-js/src/utils/__tests__/completeSignUpFlow.test.ts @@ -104,7 +104,35 @@ describe('completeSignUpFlow', () => { expect(mockHandleComplete).not.toHaveBeenCalled(); expect(mockNavigate).not.toHaveBeenCalled(); expect(mockAuthenticateWithRedirect).toHaveBeenCalledWith({ - strategy: 'saml', + strategy: 'enterprise_sso', + redirectUrl, + redirectUrlComplete, + continueSignUp: true, + }); + }); + + it('initiates a Enterprise SSO flow if enterprise_sso is listed as a missing field', async () => { + const redirectUrl = 'https://www.in.gr/acs'; + const redirectUrlComplete = 'https://www.in.gr/tada'; + + const mockSignUp = { + status: 'missing_requirements', + missingFields: ['enterprise_sso'], + authenticateWithRedirect: mockAuthenticateWithRedirect, + } as unknown as SignUpResource; + + await completeSignUpFlow({ + signUp: mockSignUp, + handleComplete: mockHandleComplete, + navigate: mockNavigate, + redirectUrl: 'https://www.in.gr/acs', + redirectUrlComplete: 'https://www.in.gr/tada', + }); + + expect(mockHandleComplete).not.toHaveBeenCalled(); + expect(mockNavigate).not.toHaveBeenCalled(); + expect(mockAuthenticateWithRedirect).toHaveBeenCalledWith({ + strategy: 'enterprise_sso', redirectUrl, redirectUrlComplete, continueSignUp: true, diff --git a/packages/clerk-js/src/utils/completeSignUpFlow.ts b/packages/clerk-js/src/utils/completeSignUpFlow.ts index 6d9742ad30b..baf951eba21 100644 --- a/packages/clerk-js/src/utils/completeSignUpFlow.ts +++ b/packages/clerk-js/src/utils/completeSignUpFlow.ts @@ -22,9 +22,9 @@ export const completeSignUpFlow = ({ if (signUp.status === 'complete') { return handleComplete && handleComplete(); } else if (signUp.status === 'missing_requirements') { - if (signUp.missingFields.some(mf => mf === 'saml')) { + if (signUp.missingFields.some(mf => mf === 'saml' || mf === 'enterprise_sso')) { return signUp.authenticateWithRedirect({ - strategy: 'saml', + strategy: 'enterprise_sso', redirectUrl, redirectUrlComplete, continueSignUp: true,