@@ -252,10 +252,9 @@ async def test_client_side_state(
252252 assert client_side .frontend_url is not None
253253
254254 def poll_for_token ():
255- token_input = client_side . poll_for_result (
255+ token_input = AppHarness . poll_for_or_raise_timeout (
256256 lambda : driver .find_element (By .ID , "token" )
257257 )
258- assert token_input
259258
260259 # wait for the backend connection to send the token
261260 token = client_side .poll_for_value (token_input )
@@ -267,8 +266,8 @@ def set_sub(var: str, value: str):
267266 state_var_input = driver .find_element (By .ID , "state_var" )
268267 input_value_input = driver .find_element (By .ID , "input_value" )
269268 set_sub_state_button = driver .find_element (By .ID , "set_sub_state" )
270- AppHarness ._poll_for (lambda : state_var_input .get_attribute ("value" ) == "" )
271- AppHarness ._poll_for (lambda : input_value_input .get_attribute ("value" ) == "" )
269+ AppHarness .expect (lambda : state_var_input .get_attribute ("value" ) == "" )
270+ AppHarness .expect (lambda : input_value_input .get_attribute ("value" ) == "" )
272271
273272 # Set the values.
274273 state_var_input .send_keys (var )
@@ -280,8 +279,8 @@ def set_sub_sub(var: str, value: str):
280279 state_var_input = driver .find_element (By .ID , "state_var" )
281280 input_value_input = driver .find_element (By .ID , "input_value" )
282281 set_sub_sub_state_button = driver .find_element (By .ID , "set_sub_sub_state" )
283- AppHarness ._poll_for (lambda : state_var_input .get_attribute ("value" ) == "" )
284- AppHarness ._poll_for (lambda : input_value_input .get_attribute ("value" ) == "" )
282+ AppHarness .expect (lambda : state_var_input .get_attribute ("value" ) == "" )
283+ AppHarness .expect (lambda : input_value_input .get_attribute ("value" ) == "" )
285284
286285 # Set the values.
287286 state_var_input .send_keys (var )
@@ -418,7 +417,7 @@ def set_sub_sub(var: str, value: str):
418417 "value" : "c1s%20value" ,
419418 },
420419 }
421- AppHarness ._poll_for (
420+ AppHarness .expect (
422421 lambda : all (cookie_key in cookie_info_map (driver ) for cookie_key in exp_cookies )
423422 )
424423 cookies = cookie_info_map (driver )
@@ -429,7 +428,7 @@ def set_sub_sub(var: str, value: str):
429428
430429 # Test cookie with expiry by itself to avoid timing flakiness
431430 set_sub ("c3" , "c3 value" )
432- AppHarness ._poll_for (
431+ AppHarness .expect (
433432 lambda : f"{ sub_state_name } .c3" + FIELD_MARKER in cookie_info_map (driver )
434433 )
435434 c3_cookie = cookie_info_map (driver )[f"{ sub_state_name } .c3" + FIELD_MARKER ]
@@ -499,7 +498,7 @@ def set_sub_sub(var: str, value: str):
499498 driver .get (client_side .frontend_url .removesuffix ("/" ) + "/foo/" )
500499
501500 # get new references to all cookie and local storage elements
502- c1 = client_side . poll_for_result (lambda : driver .find_element (By .ID , "c1" ))
501+ c1 = AppHarness . poll_for_or_raise_timeout (lambda : driver .find_element (By .ID , "c1" ))
503502 c2 = driver .find_element (By .ID , "c2" )
504503 c3 = driver .find_element (By .ID , "c3" )
505504 c4 = driver .find_element (By .ID , "c4" )
@@ -541,7 +540,7 @@ def set_sub_sub(var: str, value: str):
541540 driver .refresh ()
542541
543542 # wait for the backend connection to send the token (again)
544- token_input = client_side . poll_for_result (
543+ token_input = AppHarness . poll_for_or_raise_timeout (
545544 lambda : driver .find_element (By .ID , "token" )
546545 )
547546 assert token_input
@@ -586,7 +585,7 @@ def set_sub_sub(var: str, value: str):
586585 assert s1s .text == "s1s value"
587586
588587 # make sure c5 cookie shows up on the `/foo` route
589- AppHarness ._poll_for (
588+ AppHarness .expect (
590589 lambda : f"{ sub_state_name } .c5" + FIELD_MARKER in cookie_info_map (driver )
591590 )
592591 assert cookie_info_map (driver )[f"{ sub_state_name } .c5" + FIELD_MARKER ] == {
@@ -612,15 +611,15 @@ def set_sub_sub(var: str, value: str):
612611 set_sub ("l6" , "l6 value" )
613612 l5 = driver .find_element (By .ID , "l5" )
614613 l6 = driver .find_element (By .ID , "l6" )
615- assert AppHarness ._poll_for (lambda : l6 .text == "l6 value" )
614+ AppHarness .expect (lambda : l6 .text == "l6 value" )
616615 assert l5 .text == "l5 value"
617616
618617 # Set session storage values in the new tab
619618 set_sub ("s1" , "other tab s1" )
620619 s1 = driver .find_element (By .ID , "s1" )
621620 s2 = driver .find_element (By .ID , "s2" )
622621 s3 = driver .find_element (By .ID , "s3" )
623- assert AppHarness ._poll_for (lambda : s1 .text == "other tab s1" )
622+ AppHarness .expect (lambda : s1 .text == "other tab s1" )
624623 assert s2 .text == "s2 default"
625624 assert s3 .text == ""
626625
@@ -630,13 +629,13 @@ def set_sub_sub(var: str, value: str):
630629 # The values should have updated automatically.
631630 l5 = driver .find_element (By .ID , "l5" )
632631 l6 = driver .find_element (By .ID , "l6" )
633- assert AppHarness ._poll_for (lambda : l6 .text == "l6 value" )
632+ AppHarness .expect (lambda : l6 .text == "l6 value" )
634633 assert l5 .text == "l5 value"
635634
636635 s1 = driver .find_element (By .ID , "s1" )
637636 s2 = driver .find_element (By .ID , "s2" )
638637 s3 = driver .find_element (By .ID , "s3" )
639- assert AppHarness ._poll_for (lambda : s1 .text == "s1 value" )
638+ AppHarness .expect (lambda : s1 .text == "s1 value" )
640639 assert s2 .text == "s2 value"
641640 assert s3 .text == "s3 value"
642641
@@ -748,10 +747,9 @@ async def poll_for_c1_set():
748747 driver .refresh ()
749748
750749 # wait for the backend connection to send the token (again)
751- token_input = client_side . poll_for_result (
750+ token_input = AppHarness . poll_for_or_raise_timeout (
752751 lambda : driver .find_element (By .ID , "token" )
753752 )
754- assert token_input
755753 token = client_side .poll_for_value (token_input )
756754 assert token is not None
757755
0 commit comments