@@ -70,45 +70,102 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes], withPattern:
7070 console . log ( '[DIAG] password field appeared after filling identifier' ) ;
7171 } catch {
7272 console . log ( '[DIAG] password field did NOT appear after 5s' ) ;
73- // Capture what the form looks like
7473 const formHTML = await page . locator ( '.cl-signIn-root' ) . innerHTML ( ) ;
7574 console . log ( '[DIAG] sign-in form HTML:' , formHTML . substring ( 0 , 3000 ) ) ;
7675 }
7776
78- // Fill password and check Continue button
77+ // Install event listeners on password input BEFORE filling
78+ await page . evaluate ( ( ) => {
79+ const pwInput = document . querySelector ( 'input[name=password]' ) as HTMLInputElement ;
80+ if ( pwInput ) {
81+ ( window as any ) . __pwEvents = [ ] ;
82+ [ 'input' , 'change' , 'focus' , 'blur' , 'keydown' , 'keyup' ] . forEach ( evt => {
83+ pwInput . addEventListener ( evt , ( e : Event ) => {
84+ ( window as any ) . __pwEvents . push ( {
85+ type : e . type ,
86+ value : ( e . target as HTMLInputElement ) . value . length ,
87+ isTrusted : e . isTrusted ,
88+ } ) ;
89+ } ) ;
90+ } ) ;
91+ // Also track React's synthetic event by monkey-patching the value setter
92+ const origDescriptor = Object . getOwnPropertyDescriptor ( HTMLInputElement . prototype , 'value' ) ;
93+ ( window as any ) . __valueSetCount = 0 ;
94+ if ( origDescriptor ?. set ) {
95+ Object . defineProperty ( pwInput , 'value' , {
96+ set ( val : string ) {
97+ ( window as any ) . __valueSetCount ++ ;
98+ origDescriptor . set ! . call ( this , val ) ;
99+ } ,
100+ get ( ) {
101+ return origDescriptor . get ! . call ( this ) ;
102+ } ,
103+ } ) ;
104+ }
105+ }
106+ } ) ;
107+
108+ // Fill password
79109 const isPasswordVisible = await passwordInput . isVisible ( ) ;
80110 console . log ( `[DIAG] password visible: ${ isPasswordVisible } ` ) ;
81111 if ( isPasswordVisible ) {
82112 await passwordInput . fill ( fakeUser . password , { force : true } ) ;
83113 }
84114
115+ // Check what events fired and the password field state
116+ const pwDiag = await page . evaluate ( ( ) => {
117+ const pwInput = document . querySelector ( 'input[name=password]' ) as HTMLInputElement ;
118+ return {
119+ domValue : pwInput ?. value ?? 'NOT_FOUND' ,
120+ domValueLength : pwInput ?. value ?. length ?? 0 ,
121+ events : ( window as any ) . __pwEvents ?? [ ] ,
122+ valueSetCount : ( window as any ) . __valueSetCount ?? 0 ,
123+ // Check password field's computed styles (Activity hiding?)
124+ computedDisplay : pwInput ? getComputedStyle ( pwInput ) . display : 'N/A' ,
125+ computedOpacity : pwInput ? getComputedStyle ( pwInput ) . opacity : 'N/A' ,
126+ computedPointerEvents : pwInput ? getComputedStyle ( pwInput ) . pointerEvents : 'N/A' ,
127+ // Check parent container styles
128+ parentOpacity : pwInput ?. closest ( '[class*="instant"]' )
129+ ? getComputedStyle ( pwInput . closest ( '[class*="instant"]' ) ! ) . opacity
130+ : pwInput ?. parentElement
131+ ? getComputedStyle ( pwInput . parentElement ) . opacity
132+ : 'N/A' ,
133+ } ;
134+ } ) ;
135+ console . log ( '[DIAG] Password field after fill:' , JSON . stringify ( pwDiag , null , 2 ) ) ;
136+
85137 const continueBtn = page . getByRole ( 'button' , { name : 'Continue' , exact : true } ) ;
86138 const isContinueVisible = await continueBtn . isVisible ( ) ;
87139 const isContinueEnabled = await continueBtn . isEnabled ( ) ;
88140 console . log ( `[DIAG] continue button visible: ${ isContinueVisible } , enabled: ${ isContinueEnabled } ` ) ;
89141
90- // Track API calls during sign-in
142+ // Track API calls with response bodies for sign-in calls
91143 const apiCalls : string [ ] = [ ] ;
92- page . on ( 'response' , res => {
93- if ( res . url ( ) . includes ( 'clerk' ) || res . url ( ) . includes ( 'sign_in' ) ) {
94- apiCalls . push ( `${ res . status ( ) } ${ res . url ( ) . split ( '?' ) [ 0 ] } ` ) ;
144+ page . on ( 'response' , async res => {
145+ const url = res . url ( ) ;
146+ if ( url . includes ( 'sign_in' ) ) {
147+ try {
148+ const body = await res . json ( ) ;
149+ const status = body ?. response ?. status || body ?. status || 'unknown' ;
150+ apiCalls . push ( `${ res . status ( ) } ${ url . split ( '?' ) [ 0 ] . split ( '/' ) . slice ( - 2 ) . join ( '/' ) } signInStatus=${ status } ` ) ;
151+ } catch {
152+ apiCalls . push ( `${ res . status ( ) } ${ url . split ( '?' ) [ 0 ] . split ( '/' ) . slice ( - 2 ) . join ( '/' ) } ` ) ;
153+ }
95154 }
96155 } ) ;
97156
98157 // Click continue
99158 await continueBtn . click ( ) ;
100159
101- // Wait a few seconds for the sign-in to process
160+ // Wait for the sign-in to process
102161 await page . waitForTimeout ( 5000 ) ;
103162
104163 const diagAfterWait = await page . evaluate ( ( ) => {
105164 return {
106165 url : window . location . href ,
107- clerkLoaded : ! ! ( window as any ) . Clerk ?. loaded ,
108166 hasSession : ! ! ( window as any ) . Clerk ?. session ,
109- hasUser : ! ! ( window as any ) . Clerk ?. user ,
110- cookies : document . cookie ,
111167 signInCardClass : document . querySelector ( '.cl-cardBox' ) ?. className ?? 'NOT_FOUND' ,
168+ signInStatus : ( window as any ) . Clerk ?. client ?. signIn ?. status ?? 'N/A' ,
112169 } ;
113170 } ) ;
114171 console . log ( '[DIAG] State 5s after click:' , JSON . stringify ( diagAfterWait , null , 2 ) ) ;
0 commit comments