From 52547d8cbe3316f4866b03933882fb3411cd6ef1 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 12 Aug 2024 09:15:51 +0200 Subject: [PATCH 1/9] create_project_from_new_button --- tests/e2e-playwright/tests/conftest.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/e2e-playwright/tests/conftest.py b/tests/e2e-playwright/tests/conftest.py index 26992facc38..65f735a0740 100644 --- a/tests/e2e-playwright/tests/conftest.py +++ b/tests/e2e-playwright/tests/conftest.py @@ -453,6 +453,20 @@ def _( _INNER_CONTEXT_TIMEOUT_MS = 0.8 * _OUTER_CONTEXT_TIMEOUT_MS +@pytest.fixture +def start_study_from_plus_button( + page: Page, +) -> Callable[[str], None]: + def _(plus_button_test_id: str) -> None: + with log_context( + logging.INFO, f"Finding plus button {plus_button_test_id=} in study browser" + ): + page.get_by_test_id("studiesTabBtn").click() + page.get_by_test_id(plus_button_test_id).click() + + return _ + + @pytest.fixture def find_and_start_service_in_dashboard( page: Page, @@ -474,6 +488,19 @@ def _( return _ +@pytest.fixture +def create_project_from_new_button( + start_study_from_plus_button: Callable[[ServiceType, str, str | None], None], + create_new_project_and_delete: Callable[[tuple[RunningState]], dict[str, Any]], +) -> Callable[[ServiceType, str, str | None], dict[str, Any]]: + def _(plus_button_test_id: str) -> dict[str, Any]: + start_study_from_plus_button(plus_button_test_id) + expected_states = (RunningState.UNKNOWN,) + return create_new_project_and_delete(expected_states) + + return _ + + @pytest.fixture def create_project_from_service_dashboard( find_and_start_service_in_dashboard: Callable[[ServiceType, str, str | None], None], From 795c9ecd84107acb3695e18d25e7ebe1c9b6d6ed Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 12 Aug 2024 09:17:53 +0200 Subject: [PATCH 2/9] sim4life test uses plus button --- .../e2e-playwright/tests/sim4life/test_sim4life.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/e2e-playwright/tests/sim4life/test_sim4life.py b/tests/e2e-playwright/tests/sim4life/test_sim4life.py index b130fbae9e6..a0f9befa967 100644 --- a/tests/e2e-playwright/tests/sim4life/test_sim4life.py +++ b/tests/e2e-playwright/tests/sim4life/test_sim4life.py @@ -21,7 +21,6 @@ MINUTE, SECOND, SOCKETIO_MESSAGE_PREFIX, - ServiceType, SocketIOEvent, decode_socketio_42_message, wait_for_service_running, @@ -110,17 +109,13 @@ def __call__(self, message: str) -> bool: def test_sim4life( page: Page, - create_project_from_service_dashboard: Callable[ - [ServiceType, str, str | None], dict[str, Any] - ], + create_project_from_new_button: Callable[[str], dict[str, Any]], log_in_and_out: WebSocket, - service_key: str, + plus_button_test_id: str, autoscaled: bool, check_videostreaming: bool, ): - project_data = create_project_from_service_dashboard( - ServiceType.DYNAMIC, service_key, None - ) + project_data = create_project_from_new_button(plus_button_test_id) assert "workbench" in project_data, "Expected workbench to be in project data!" assert isinstance( project_data["workbench"], dict @@ -128,7 +123,7 @@ def test_sim4life( node_ids: list[str] = list(project_data["workbench"]) assert len(node_ids) == 1, "Expected 1 node in the workbench!" - with log_context(logging.INFO, "launch S4l") as ctx: + with log_context(logging.INFO, "launch S4L") as ctx: predicate = _S4LWaitForWebsocket(logger=ctx.logger) with page.expect_websocket( predicate, From 4045581254c3b22f932870dc733c7a96cea93f4c Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 12 Aug 2024 09:22:24 +0200 Subject: [PATCH 3/9] less args --- tests/e2e-playwright/tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e-playwright/tests/conftest.py b/tests/e2e-playwright/tests/conftest.py index 65f735a0740..64f71cb58d2 100644 --- a/tests/e2e-playwright/tests/conftest.py +++ b/tests/e2e-playwright/tests/conftest.py @@ -490,9 +490,9 @@ def _( @pytest.fixture def create_project_from_new_button( - start_study_from_plus_button: Callable[[ServiceType, str, str | None], None], + start_study_from_plus_button: Callable[[str], None], create_new_project_and_delete: Callable[[tuple[RunningState]], dict[str, Any]], -) -> Callable[[ServiceType, str, str | None], dict[str, Any]]: +) -> Callable[[str], dict[str, Any]]: def _(plus_button_test_id: str) -> dict[str, Any]: start_study_from_plus_button(plus_button_test_id) expected_states = (RunningState.UNKNOWN,) From ac374500fa6f6c9c7068c64622fb9f796b351621 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:27:51 +0200 Subject: [PATCH 4/9] add docs for make recipes --- tests/e2e-playwright/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e-playwright/Makefile b/tests/e2e-playwright/Makefile index f0ccd4322c0..82c19e3c682 100644 --- a/tests/e2e-playwright/Makefile +++ b/tests/e2e-playwright/Makefile @@ -142,16 +142,16 @@ $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L fi # Run the tests -test-sleepers-anywhere: _check_venv_active $(SLEEPERS_INPUT_FILE) +test-sleepers-anywhere: _check_venv_active $(SLEEPERS_INPUT_FILE) ## run sleepers test and cache settings @$(call run_test, $(SLEEPERS_INPUT_FILE), tests/sleepers/test_sleepers.py) -test-s4l-anywhere: _check_venv_active $(S4L_INPUT_FILE) +test-s4l-anywhere: _check_venv_active $(S4L_INPUT_FILE) ## run s4l test and cache settings @$(call run_test_on_chrome, $(S4L_INPUT_FILE), tests/sim4life/test_sim4life.py) -test-jupyterlab-anywhere: _check_venv_active $(JUPYTER_LAB_INPUT_FILE) +test-jupyterlab-anywhere: _check_venv_active $(JUPYTER_LAB_INPUT_FILE) ## run jupyterlab test and cache settings @$(call run_test, $(JUPYTER_LAB_INPUT_FILE), tests/jupyterlabs/test_jupyterlab.py) -test-tip-anywhere: _check_venv_active $(CLASSIC_TIP_INPUT_FILE) +test-tip-anywhere: _check_venv_active $(CLASSIC_TIP_INPUT_FILE) ## run classic tip test and cache settings $(call run_test, $(CLASSIC_TIP_INPUT_FILE), tests/tip/test_ti_plan.py) # Define the common test running function From 1f3048e37fa79bff7e0bd806ec32aab1c89d26e6 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Mon, 12 Aug 2024 09:51:31 +0200 Subject: [PATCH 5/9] startS4LButton --- tests/e2e-playwright/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e-playwright/Makefile b/tests/e2e-playwright/Makefile index f0ccd4322c0..dc8e340e098 100644 --- a/tests/e2e-playwright/Makefile +++ b/tests/e2e-playwright/Makefile @@ -131,7 +131,7 @@ $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L read -p "Enter the size of the large file (human readable form e.g. 3Gib): " LARGE_FILE_SIZE; \ echo "--service-key=jupyter-math --large-file-size=$$LARGE_FILE_SIZE" >> $@; \ elif [ "$@" = "$(S4L_INPUT_FILE)" ]; then \ - echo "--service-key=sim4life-8-0-0-dy" >> $@; \ + echo "--plus_button_test_id=startS4LButton" >> $@; \ read -p "Do you want to check the videostreaming ? (requires to run with chrome/msedge) [y/n]: " VIDEOSTREAM; \ if [ "$$VIDEOSTREAM" = "y" ]; then \ echo "--check-videostreaming" >> $@; \ From 3d90a03d2aa3d76730ab0f13a28b94c805d9ad77 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:53:34 +0200 Subject: [PATCH 6/9] don't click on unnecessary stuff --- tests/e2e-playwright/tests/conftest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e-playwright/tests/conftest.py b/tests/e2e-playwright/tests/conftest.py index 64f71cb58d2..802d0d46d6b 100644 --- a/tests/e2e-playwright/tests/conftest.py +++ b/tests/e2e-playwright/tests/conftest.py @@ -459,9 +459,8 @@ def start_study_from_plus_button( ) -> Callable[[str], None]: def _(plus_button_test_id: str) -> None: with log_context( - logging.INFO, f"Finding plus button {plus_button_test_id=} in study browser" + logging.INFO, f"Find plus button {plus_button_test_id=} in study browser" ): - page.get_by_test_id("studiesTabBtn").click() page.get_by_test_id(plus_button_test_id).click() return _ From 9d3dfaf932eff9c41a1bd9743044b10b4775476e Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:53:48 +0200 Subject: [PATCH 7/9] add option to use + button --- tests/e2e-playwright/tests/sim4life/conftest.py | 12 ++++++++++++ .../e2e-playwright/tests/sim4life/test_sim4life.py | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/e2e-playwright/tests/sim4life/conftest.py b/tests/e2e-playwright/tests/sim4life/conftest.py index d41448d97fc..0f927d22f13 100644 --- a/tests/e2e-playwright/tests/sim4life/conftest.py +++ b/tests/e2e-playwright/tests/sim4life/conftest.py @@ -19,9 +19,21 @@ def pytest_addoption(parser: pytest.Parser) -> None: default=False, help="check if video streaming is functional", ) + group.addoption( + "--use-plus-button", + action="store_true", + default=False, + help="The service key option will be used as the plus button ID instead of service key", + ) @pytest.fixture(scope="session") def check_videostreaming(request: pytest.FixtureRequest) -> bool: check_video = request.config.getoption("--check-videostreaming") return TypeAdapter(bool).validate_python(check_video) + + +@pytest.fixture(scope="session") +def use_plus_button(request: pytest.FixtureRequest) -> bool: + use_plus_button = request.config.getoption("--use-plus-button") + return TypeAdapter(bool).validate_python(use_plus_button) diff --git a/tests/e2e-playwright/tests/sim4life/test_sim4life.py b/tests/e2e-playwright/tests/sim4life/test_sim4life.py index a0f9befa967..3fca6f36b54 100644 --- a/tests/e2e-playwright/tests/sim4life/test_sim4life.py +++ b/tests/e2e-playwright/tests/sim4life/test_sim4life.py @@ -21,6 +21,7 @@ MINUTE, SECOND, SOCKETIO_MESSAGE_PREFIX, + ServiceType, SocketIOEvent, decode_socketio_42_message, wait_for_service_running, @@ -109,13 +110,22 @@ def __call__(self, message: str) -> bool: def test_sim4life( page: Page, + create_project_from_service_dashboard: Callable[ + [ServiceType, str, str | None], dict[str, Any] + ], create_project_from_new_button: Callable[[str], dict[str, Any]], log_in_and_out: WebSocket, - plus_button_test_id: str, + service_key: str, + use_plus_button: bool, autoscaled: bool, check_videostreaming: bool, ): - project_data = create_project_from_new_button(plus_button_test_id) + if use_plus_button: + project_data = create_project_from_new_button(service_key) + else: + project_data = create_project_from_service_dashboard( + ServiceType.DYNAMIC, service_key, None + ) assert "workbench" in project_data, "Expected workbench to be in project data!" assert isinstance( project_data["workbench"], dict From 6bcf481cbc52e4736021987df820deac481915c8 Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Mon, 12 Aug 2024 10:01:34 +0200 Subject: [PATCH 8/9] works with s4l-lite --- tests/e2e-playwright/Makefile | 7 ++++++- tests/e2e-playwright/tests/conftest.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/e2e-playwright/Makefile b/tests/e2e-playwright/Makefile index 82c19e3c682..e3cd3003fd4 100644 --- a/tests/e2e-playwright/Makefile +++ b/tests/e2e-playwright/Makefile @@ -131,11 +131,16 @@ $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L read -p "Enter the size of the large file (human readable form e.g. 3Gib): " LARGE_FILE_SIZE; \ echo "--service-key=jupyter-math --large-file-size=$$LARGE_FILE_SIZE" >> $@; \ elif [ "$@" = "$(S4L_INPUT_FILE)" ]; then \ - echo "--service-key=sim4life-8-0-0-dy" >> $@; \ read -p "Do you want to check the videostreaming ? (requires to run with chrome/msedge) [y/n]: " VIDEOSTREAM; \ if [ "$$VIDEOSTREAM" = "y" ]; then \ echo "--check-videostreaming" >> $@; \ fi; \ + read -p "Do you want to use the plus button (NOTE: if yes then pass the osparc-test-ID of the plus button in the service key) ? [y/n]: " PLUS_BUTTON; \ + if [ "$$PLUS_BUTTON" = "y" ]; then \ + echo "--use-plus-button" >> $@; \ + fi; \ + read -p "Enter the service key: " SERVICE_KEY; \ + echo "--service-key=$$SERVICE_KEY" >> $@; \ elif [ "$@" = "$(SLEEPERS_INPUT_FILE)" ]; then \ read -p "Enter the number of sleepers: " NUM_SLEEPERS; \ echo "--num-sleepers=$$NUM_SLEEPERS" >> $@; \ diff --git a/tests/e2e-playwright/tests/conftest.py b/tests/e2e-playwright/tests/conftest.py index 802d0d46d6b..839e68fe3b6 100644 --- a/tests/e2e-playwright/tests/conftest.py +++ b/tests/e2e-playwright/tests/conftest.py @@ -495,7 +495,7 @@ def create_project_from_new_button( def _(plus_button_test_id: str) -> dict[str, Any]: start_study_from_plus_button(plus_button_test_id) expected_states = (RunningState.UNKNOWN,) - return create_new_project_and_delete(expected_states) + return create_new_project_and_delete(expected_states, False) return _ From 1cf7718f15a465fc7e8be9d8e1c911b66310c0cb Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Mon, 12 Aug 2024 10:08:49 +0200 Subject: [PATCH 9/9] types --- tests/e2e-playwright/tests/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e-playwright/tests/conftest.py b/tests/e2e-playwright/tests/conftest.py index 839e68fe3b6..cdae590ad8e 100644 --- a/tests/e2e-playwright/tests/conftest.py +++ b/tests/e2e-playwright/tests/conftest.py @@ -490,7 +490,9 @@ def _( @pytest.fixture def create_project_from_new_button( start_study_from_plus_button: Callable[[str], None], - create_new_project_and_delete: Callable[[tuple[RunningState]], dict[str, Any]], + create_new_project_and_delete: Callable[ + [tuple[RunningState], bool], dict[str, Any] + ], ) -> Callable[[str], dict[str, Any]]: def _(plus_button_test_id: str) -> dict[str, Any]: start_study_from_plus_button(plus_button_test_id)