@@ -298,12 +298,9 @@ describe('Passwordless enabled', () => {
298298 ) . not . toBeInTheDocument ( )
299299 } )
300300
301- await waitFor (
302- ( ) => {
303- expect ( screen . getByText ( / Y o u ' r e n o w s i g n e d i n ./ i) ) . toBeInTheDocument ( )
304- } ,
305- { timeout : 5000 }
306- )
301+ await waitFor ( ( ) => {
302+ expect ( screen . getByText ( / Y o u ' r e n o w s i g n e d i n ./ i) ) . toBeInTheDocument ( )
303+ } )
307304 } )
308305
309306 test ( 'allows passwordless login via Enter key' , async ( ) => {
@@ -923,72 +920,54 @@ describe('Passkey login', () => {
923920 expect ( screen . queryByText ( / W e l c o m e b a c k / i) ) . not . toBeInTheDocument ( )
924921 } )
925922 } )
923+ } )
926924
927- describe ( 'Passkey Registration' , ( ) => {
928- beforeEach ( ( ) => {
929- getConfig . mockReturnValue ( {
930- ...mockConfig ,
931- app : {
932- ...mockConfig . app ,
933- login : {
934- ...mockConfig . app . login ,
935- passkey : { enabled : true }
936- }
925+ describe ( 'Passkey Registration' , ( ) => {
926+ beforeEach ( ( ) => {
927+ getConfig . mockReturnValue ( {
928+ ...mockConfig ,
929+ app : {
930+ ...mockConfig . app ,
931+ login : {
932+ ...mockConfig . app . login ,
933+ passkey : { enabled : true }
937934 }
938- } )
939-
940- // Mock WebAuthn API
941- global . PublicKeyCredential = {
942- isUserVerifyingPlatformAuthenticatorAvailable : jest . fn ( ) . mockResolvedValue ( true ) ,
943- isConditionalMediationAvailable : jest . fn ( ) . mockResolvedValue ( true )
944935 }
945- global . window . PublicKeyCredential = global . PublicKeyCredential
946-
947- global . server . use (
948- rest . post ( '*/oauth2/token' , ( req , res , ctx ) =>
949- res (
950- ctx . delay ( 0 ) ,
951- ctx . json ( {
952- customer_id : 'registeredCustomerId' ,
953- access_token : registerUserToken ,
954- refresh_token : 'testrefeshtoken' ,
955- usid : 'testusid' ,
956- enc_user_id : 'testEncUserId' ,
957- id_token : 'testIdToken'
958- } )
959- )
960- )
961- )
962936 } )
963937
964- afterEach ( ( ) => {
965- delete global . PublicKeyCredential
966- delete global . window . PublicKeyCredential
967- } )
938+ // Mock WebAuthn API
939+ global . PublicKeyCredential = {
940+ isUserVerifyingPlatformAuthenticatorAvailable : jest . fn ( ) . mockResolvedValue ( true ) ,
941+ isConditionalMediationAvailable : jest . fn ( ) . mockResolvedValue ( true )
942+ }
943+ global . window . PublicKeyCredential = global . PublicKeyCredential
944+ } )
968945
969- test ( 'shows passkey registration toast after login' , async ( ) => {
970- const { user } = renderWithProviders ( < MockedComponent isPasswordlessEnabled = { true } /> )
971- const validEmail = 'test@salesforce.com'
972- const validPassword = 'Password123!'
946+ afterEach ( ( ) => {
947+ delete global . PublicKeyCredential
948+ delete global . window . PublicKeyCredential
949+ } )
973950
974- const trigger = screen . getByText ( / o p e n m o d a l / i)
975- await user . click ( trigger )
951+ test ( 'shows passkey registration toast after login' , async ( ) => {
952+ const { user} = renderWithProviders ( < MockedComponent isPasswordlessEnabled = { true } /> )
953+ const validEmail = 'test@salesforce.com'
954+ const validPassword = 'Password123!'
976955
977- await waitFor ( ( ) => {
978- expect ( screen . getByText ( / C o n t i n u e / i) ) . toBeInTheDocument ( )
979- } )
956+ const trigger = screen . getByText ( / o p e n m o d a l / i)
957+ await user . click ( trigger )
980958
981- await user . type ( screen . getByLabelText ( 'Email' ) , validEmail )
982- await user . click ( screen . getByText ( / p a s s w o r d / i) )
983- await user . type ( screen . getByLabelText ( 'Password' ) , validPassword )
984- await user . keyboard ( '{Enter}' )
959+ await waitFor ( ( ) => {
960+ expect ( screen . getByText ( / W e l c o m e B a c k / i) ) . toBeInTheDocument ( )
961+ } )
985962
986- // Create passkey toast is shown after login
987- await waitFor ( ( ) => {
988- // 2 matches are found for the toast
989- const toasts = screen . getAllByText ( / C r e a t e P a s s k e y / i)
990- expect ( toasts . length ) . toBeGreaterThanOrEqual ( 1 )
991- } )
963+ await user . type ( screen . getByLabelText ( 'Email' ) , validEmail )
964+ await user . click ( screen . getByText ( / p a s s w o r d / i) )
965+ await user . type ( screen . getByLabelText ( 'Password' ) , validPassword )
966+ await user . keyboard ( '{Enter}' )
967+
968+ // Create passkey toast is shown after login
969+ await waitFor ( ( ) => {
970+ expect ( screen . getByText ( / C r e a t e P a s s k e y / i) ) . toBeInTheDocument ( )
992971 } )
993972 } )
994973} )
0 commit comments