@@ -106,25 +106,36 @@ def test_2_imx_functions(self):
106106 self .assertEqual ("Registered" , text )
107107
108108 # Register off-chain
109- # Wait up to 3 times for "Passport account already registered" to appear
109+ # Wait up to 3 times for successful registration or already- registered error
110110 attempts = 0
111111 while attempts < 3 :
112112 self .altdriver .find_object (By .NAME , "RegisterOffchainBtn" ).tap ()
113113 text = output .get_text ()
114114 print (f"RegisterOffchainBtn output: { text } " )
115+
116+ # Check if we got an immediate "already registered" error (400 or 409)
117+ if ("400" in text and "USER_REGISTRATION_ERROR" in text ) or \
118+ ("409" in text and "USER_REGISTRATION_ERROR" in text ):
119+ print (f"Account already registered (got error immediately): { text } " )
120+ break
121+
115122 self .assertEqual ("Registering off-chain..." , text )
116123 time .sleep (20 )
117124 output_text = output .get_text ()
118- # Accept either success message or 409 error (account already registered)
119- if "Successfully registered" in output_text or ("409" in output_text and "USER_REGISTRATION_ERROR" in output_text ):
125+ # Accept either success message or 400/409 error (account already registered)
126+ if "Successfully registered" in output_text or \
127+ ("400" in output_text and "USER_REGISTRATION_ERROR" in output_text ) or \
128+ ("409" in output_text and "USER_REGISTRATION_ERROR" in output_text ):
120129 break
121130 attempts += 1
122131
123- # Assert that registration completed (either success or 409 error for already registered)
132+ # Assert that registration completed (either success or 400/ 409 error for already registered)
124133 output_text = output .get_text ()
125134 self .assertTrue (
126- "Successfully registered" in output_text or ("409" in output_text and "USER_REGISTRATION_ERROR" in output_text ),
127- f"Expected 'Successfully registered' or '409 (USER_REGISTRATION_ERROR)' not found. Actual output: '{ output_text } '"
135+ "Successfully registered" in output_text or \
136+ ("400" in output_text and "USER_REGISTRATION_ERROR" in output_text ) or \
137+ ("409" in output_text and "USER_REGISTRATION_ERROR" in output_text ),
138+ f"Expected 'Successfully registered' or '400/409 (USER_REGISTRATION_ERROR)' not found. Actual output: '{ output_text } '"
128139 )
129140
130141 # Get address
0 commit comments