Skip to content

Commit 9e00fcc

Browse files
committed
added service_version fixture
1 parent e0a69be commit 9e00fcc

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

tests/e2e-playwright/tests/conftest.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ def pytest_addoption(parser: pytest.Parser) -> None:
106106
default=None,
107107
help="Service Key",
108108
)
109+
group.addoption(
110+
"--service-version",
111+
action="store",
112+
type=str,
113+
default=None,
114+
help="The service version option defines a service specific version",
115+
)
109116
group.addoption(
110117
"--template-id",
111118
action="store",
@@ -260,6 +267,14 @@ def service_key(request: pytest.FixtureRequest) -> str:
260267
return os.environ["SERVICE_KEY"]
261268

262269

270+
@pytest.fixture(scope="session")
271+
def service_version(request: pytest.FixtureRequest) -> str | None:
272+
if key := request.config.getoption("--service-version"):
273+
assert isinstance(key, str)
274+
return key
275+
return None
276+
277+
263278
@pytest.fixture(scope="session")
264279
def template_id(request: pytest.FixtureRequest) -> str | None:
265280
if key := request.config.getoption("--template-id"):
@@ -426,13 +441,25 @@ def _open_with_resources(page: Page, *, click_it: bool):
426441
return open_with_resources_button
427442

428443

444+
def _select_service_version(page: Page, *, version: str) -> None:
445+
try:
446+
# since https://github.com/ITISFoundation/osparc-simcore/pull/7060
447+
page.get_by_test_id("serviceSelectBox", timeout=5 * SECOND).select_option(
448+
version
449+
)
450+
except TimeoutError:
451+
# we try the non robust way
452+
page.get_by_label("Version").select_option(version)
453+
454+
429455
@pytest.fixture
430456
def create_new_project_and_delete(
431457
page: Page,
432458
log_in_and_out: RestartableWebSocket,
433459
is_product_billable: bool,
434460
api_request_context: APIRequestContext,
435461
product_url: AnyUrl,
462+
service_version: str | None,
436463
) -> Iterator[Callable[[tuple[RunningState], bool], dict[str, Any]]]:
437464
"""The first available service currently displayed in the dashboard will be opened
438465
NOTE: cannot be used multiple times or going back to dashboard will fail!!
@@ -441,6 +468,7 @@ def create_new_project_and_delete(
441468

442469
def _(
443470
expected_states: tuple[RunningState] = (RunningState.NOT_STARTED,),
471+
*,
444472
press_open: bool = True,
445473
template_id: str | None = None,
446474
) -> dict[str, Any]:
@@ -467,6 +495,8 @@ def _(
467495
):
468496
open_with_resources_clicked = False
469497
# Project detail view pop-ups shows
498+
if service_version is not None:
499+
_select_service_version(page, version=service_version)
470500
if press_open:
471501
open_button = page.get_by_test_id("openResource")
472502
if template_id is not None:
@@ -632,7 +662,7 @@ def create_project_from_new_button(
632662
def _(plus_button_test_id: str) -> dict[str, Any]:
633663
start_study_from_plus_button(plus_button_test_id)
634664
expected_states = (RunningState.UNKNOWN,)
635-
return create_new_project_and_delete(expected_states, False)
665+
return create_new_project_and_delete(expected_states, press_open=False)
636666

637667
return _
638668

@@ -645,7 +675,9 @@ def create_project_from_template_dashboard(
645675
def _(template_id: str) -> dict[str, Any]:
646676
find_and_click_template_in_dashboard(template_id)
647677
expected_states = (RunningState.UNKNOWN,)
648-
return create_new_project_and_delete(expected_states, True, template_id)
678+
return create_new_project_and_delete(
679+
expected_states, press_open=True, template_id=template_id
680+
)
649681

650682
return _
651683

@@ -664,7 +696,7 @@ def _(
664696
expected_states = (RunningState.UNKNOWN,)
665697
if service_type is ServiceType.COMPUTATIONAL:
666698
expected_states = (RunningState.NOT_STARTED,)
667-
return create_new_project_and_delete(expected_states, True)
699+
return create_new_project_and_delete(expected_states, press_open=True)
668700

669701
return _
670702

tests/e2e-playwright/tests/sim4life/test_sim4life.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_sim4life(
2828
create_project_from_new_button: Callable[[str], dict[str, Any]],
2929
log_in_and_out: RestartableWebSocket,
3030
service_key: str,
31+
service_version: str | None,
3132
use_plus_button: bool,
3233
is_autoscaled: bool,
3334
check_videostreaming: bool,

0 commit comments

Comments
 (0)