88"""
99
1010import time
11+ import unittest
1112
1213from alttester import *
1314
@@ -197,14 +198,6 @@ def test_3_passport_functions(self):
197198 print ("COMPLETED TEST: test_3_passport_functions" )
198199 print ("=" * 60 )
199200
200- def test_4_imx_functions (self ):
201- print ("=" * 60 )
202- print ("STARTING TEST: test_4_imx_functions" )
203- print ("=" * 60 )
204- self .test_2_imx_functions ()
205- print ("COMPLETED TEST: test_4_imx_functions" )
206- print ("=" * 60 )
207-
208201 def test_5_zkevm_functions (self ):
209202 print ("=" * 60 )
210203 print ("STARTING TEST: test_5_zkevm_functions" )
@@ -231,11 +224,6 @@ def test_6_relogin(self):
231224 self .get_altdriver ().find_object (By .NAME , "GetAccessTokenBtn" ).tap ()
232225 output = self .get_altdriver ().find_object (By .NAME , "Output" )
233226 self .assertTrue (len (output .get_text ()) > 50 )
234-
235- # Click Connect to IMX button
236- self .get_altdriver ().find_object (By .NAME , "ConnectBtn" ).tap ()
237- time .sleep (5 )
238- self .assertEqual ("Connected to IMX" , output .get_text ())
239227
240228 print ("COMPLETED TEST: test_6_relogin" )
241229 print ("=" * 60 )
@@ -256,11 +244,14 @@ def test_7_reconnect_connect_imx(self):
256244
257245 # Get access token
258246 self .get_altdriver ().find_object (By .NAME , "GetAccessTokenBtn" ).tap ()
247+ time .sleep (2 ) # Give Unity time to fetch and display the access token
259248 output = self .get_altdriver ().find_object (By .NAME , "Output" )
260249 self .assertTrue (len (output .get_text ()) > 50 )
261250
262251 # Get address without having to click Connect to IMX button
263252 self .get_altdriver ().find_object (By .NAME , "GetAddressBtn" ).tap ()
253+ time .sleep (2 ) # Give Unity time to fetch and display the address
254+ output = self .get_altdriver ().find_object (By .NAME , "Output" ) # Re-fetch output after address is loaded
264255 self .assertEqual (TestConfig .WALLET_ADDRESS , output .get_text ())
265256
266257 # Logout
@@ -272,63 +263,17 @@ def test_7_reconnect_connect_imx(self):
272263 # Use controlled browser logout instead of waiting for scene change
273264 logout_with_controlled_browser ()
274265
266+ # Bring Unity app to foreground immediately so it can receive the logout callback
267+ bring_sample_app_to_foreground ()
268+
275269 # Give Unity time to process the logout callback
276270 time .sleep (5 )
277- bring_sample_app_to_foreground ()
278271
279- # Wait for authenticated screen
272+ # Wait for unauthenticated screen
280273 self .get_altdriver ().wait_for_current_scene_to_be ("UnauthenticatedScene" )
281274
282275 stop_browser ()
283276 print ("Logged out" )
284277
285278 print ("COMPLETED TEST: test_7_reconnect_connect_imx" )
286- print ("=" * 60 )
287-
288- def test_8_connect_imx (self ):
289- print ("=" * 60 )
290- print ("STARTING TEST: test_8_connect_imx" )
291- print ("=" * 60 )
292- # Ensure clean state regardless of previous tests
293- self .restart_app_and_altdriver ()
294-
295- # Wait for initial scene
296- self .get_altdriver ().wait_for_current_scene_to_be ("UnauthenticatedScene" )
297-
298- # Connect IMX
299- print ("Logging in and connecting to IMX..." )
300- launch_browser ()
301- bring_sample_app_to_foreground ()
302- self .get_altdriver ().wait_for_object (By .NAME , "ConnectBtn" ).tap ()
303- login ()
304- bring_sample_app_to_foreground ()
305-
306- # Wait for authenticated screen
307- self .get_altdriver ().wait_for_current_scene_to_be ("AuthenticatedScene" )
308- print ("Logged in and connected to IMX" )
309- stop_browser ()
310-
311- # Get access token
312- self .get_altdriver ().find_object (By .NAME , "GetAccessTokenBtn" ).tap ()
313- output = self .get_altdriver ().find_object (By .NAME , "Output" )
314- self .assertTrue (len (output .get_text ()) > 50 )
315-
316- # Get address without having to click Connect to IMX button
317- self .get_altdriver ().find_object (By .NAME , "GetAddressBtn" ).tap ()
318- self .assertEqual (TestConfig .WALLET_ADDRESS , output .get_text ())
319-
320- # Logout
321- launch_browser ()
322- bring_sample_app_to_foreground ()
323- print ("Logging out..." )
324- self .get_altdriver ().find_object (By .NAME , "LogoutBtn" ).tap ()
325- logout_with_controlled_browser ()
326- time .sleep (5 )
327- bring_sample_app_to_foreground ()
328-
329- # Wait for authenticated screen
330- self .get_altdriver ().wait_for_current_scene_to_be ("UnauthenticatedScene" )
331- stop_browser ()
332- print ("Logged out" )
333- print ("COMPLETED TEST: test_8_connect_imx" )
334- print ("=" * 60 )
279+ print ("=" * 60 )
0 commit comments