1111import os
1212import random
1313import re
14+ import time
1415import urllib .parse
1516from collections .abc import Callable , Iterator
1617from contextlib import ExitStack
@@ -443,6 +444,7 @@ def _(
443444 re .compile (r"/projects/[^:]+:open" ), timeout = timeout + 5 * SECOND
444445 ) as response_info ,
445446 ):
447+ open_with_resources_clicked = False
446448 # Project detail view pop-ups shows
447449 if press_open :
448450 open_button = page .get_by_test_id ("openResource" )
@@ -451,11 +453,13 @@ def _(
451453 open_button .click ()
452454 # Open project with default resources
453455 open_button = page .get_by_test_id ("openWithResources" )
456+ time .sleep (2 ) # wait until the study options are filled up
454457 # it returns a Long Running Task
455458 with page .expect_response (
456459 re .compile (rf"/projects\?from_study\={ template_id } " )
457460 ) as lrt :
458461 open_button .click ()
462+ open_with_resources_clicked = True
459463 lrt_data = lrt .value .json ()
460464 lrt_data = lrt_data ["data" ]
461465 with log_context (
@@ -495,7 +499,15 @@ def wait_for_done(response):
495499 open_button .click ()
496500 if is_product_billable :
497501 # Open project with default resources
498- page .get_by_test_id ("openWithResources" ).click ()
502+ open_button = page .get_by_test_id ("openWithResources" )
503+ time .sleep (2 ) # wait until the study options are filled up
504+ open_button .click ()
505+ open_with_resources_clicked = True
506+ if is_product_billable and not open_with_resources_clicked :
507+ # Open project with default resources
508+ open_button = page .get_by_test_id ("openWithResources" )
509+ time .sleep (2 ) # wait until the study options are filled up
510+ open_button .click ()
499511 project_data = response_info .value .json ()
500512 assert project_data
501513 project_uuid = project_data ["data" ]["uuid" ]
0 commit comments