@@ -112,6 +112,13 @@ def pytest_addoption(parser: pytest.Parser) -> None:
112112 default = False ,
113113 help = "Whether service is a legacy service (no sidecar)" ,
114114 )
115+ group .addoption (
116+ "--service-version" ,
117+ action = "store" ,
118+ type = str ,
119+ default = None ,
120+ help = "The service version option defines a service specific version" ,
121+ )
115122 group .addoption (
116123 "--template-id" ,
117124 action = "store" ,
@@ -272,6 +279,14 @@ def is_service_legacy(request: pytest.FixtureRequest) -> bool:
272279 return TypeAdapter (bool ).validate_python (autoscaled )
273280
274281
282+ @pytest .fixture (scope = "session" )
283+ def service_version (request : pytest .FixtureRequest ) -> str | None :
284+ if key := request .config .getoption ("--service-version" ):
285+ assert isinstance (key , str )
286+ return key
287+ return None
288+
289+
275290@pytest .fixture (scope = "session" )
276291def template_id (request : pytest .FixtureRequest ) -> str | None :
277292 if key := request .config .getoption ("--template-id" ):
@@ -438,13 +453,25 @@ def _open_with_resources(page: Page, *, click_it: bool):
438453 return open_with_resources_button
439454
440455
456+ def _select_service_version (page : Page , * , version : str ) -> None :
457+ try :
458+ # since https://github.com/ITISFoundation/osparc-simcore/pull/7060
459+ page .get_by_test_id ("serviceSelectBox" , timeout = 5 * SECOND ).select_option (
460+ version
461+ )
462+ except TimeoutError :
463+ # we try the non robust way
464+ page .get_by_label ("Version" ).select_option (version )
465+
466+
441467@pytest .fixture
442468def create_new_project_and_delete (
443469 page : Page ,
444470 log_in_and_out : RestartableWebSocket ,
445471 is_product_billable : bool ,
446472 api_request_context : APIRequestContext ,
447473 product_url : AnyUrl ,
474+ service_version : str | None ,
448475) -> Iterator [Callable [[tuple [RunningState ], bool ], dict [str , Any ]]]:
449476 """The first available service currently displayed in the dashboard will be opened
450477 NOTE: cannot be used multiple times or going back to dashboard will fail!!
@@ -453,12 +480,13 @@ def create_new_project_and_delete(
453480
454481 def _ (
455482 expected_states : tuple [RunningState ] = (RunningState .NOT_STARTED ,),
483+ * ,
456484 press_open : bool = True ,
457485 template_id : str | None = None ,
458486 ) -> dict [str , Any ]:
459- assert (
460- len ( created_project_uuids ) == 0
461- ), "misuse of this fixture! only 1 study can be opened at a time. Otherwise please modify the fixture"
487+ assert len ( created_project_uuids ) == 0 , (
488+ "misuse of this fixture! only 1 study can be opened at a time. Otherwise please modify the fixture"
489+ )
462490 with log_context (
463491 logging .INFO ,
464492 f"Open project in { product_url = } as { is_product_billable = } " ,
@@ -479,6 +507,8 @@ def _(
479507 ):
480508 open_with_resources_clicked = False
481509 # Project detail view pop-ups shows
510+ if service_version is not None :
511+ _select_service_version (page , version = service_version )
482512 if press_open :
483513 open_button = page .get_by_test_id ("openResource" )
484514 if template_id is not None :
@@ -573,9 +603,9 @@ def wait_for_done(response):
573603 response = api_request_context .delete (
574604 f"{ product_url } v0/projects/{ project_uuid } "
575605 )
576- assert (
577- response . status == 204
578- ), f"Unexpected error while deleting project: ' { response . json () } '"
606+ assert response . status == 204 , (
607+ f"Unexpected error while deleting project: ' { response . json () } '"
608+ )
579609
580610
581611# SEE https://github.com/ITISFoundation/osparc-simcore/pull/5618#discussion_r1553943415
@@ -644,7 +674,7 @@ def create_project_from_new_button(
644674 def _ (plus_button_test_id : str ) -> dict [str , Any ]:
645675 start_study_from_plus_button (plus_button_test_id )
646676 expected_states = (RunningState .UNKNOWN ,)
647- return create_new_project_and_delete (expected_states , False )
677+ return create_new_project_and_delete (expected_states , press_open = False )
648678
649679 return _
650680
@@ -657,7 +687,9 @@ def create_project_from_template_dashboard(
657687 def _ (template_id : str ) -> dict [str , Any ]:
658688 find_and_click_template_in_dashboard (template_id )
659689 expected_states = (RunningState .UNKNOWN ,)
660- return create_new_project_and_delete (expected_states , True , template_id )
690+ return create_new_project_and_delete (
691+ expected_states , press_open = True , template_id = template_id
692+ )
661693
662694 return _
663695
@@ -676,7 +708,7 @@ def _(
676708 expected_states = (RunningState .UNKNOWN ,)
677709 if service_type is ServiceType .COMPUTATIONAL :
678710 expected_states = (RunningState .NOT_STARTED ,)
679- return create_new_project_and_delete (expected_states , True )
711+ return create_new_project_and_delete (expected_states , press_open = True )
680712
681713 return _
682714
0 commit comments