Skip to content

Commit

Permalink
Merge pull request #148 from sanderegg/odeimaiz-e2e/use-plus-button
Browse files Browse the repository at this point in the history
Odeimaiz e2e/use plus button
  • Loading branch information
odeimaiz authored Aug 12, 2024
2 parents 1f3048e + d8c4f15 commit 88a4b18
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
14 changes: 10 additions & 4 deletions tests/e2e-playwright/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,28 @@ $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L
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" >> $@; \
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
Expand Down
9 changes: 5 additions & 4 deletions tests/e2e-playwright/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand Down Expand Up @@ -491,12 +490,14 @@ 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)
expected_states = (RunningState.UNKNOWN,)
return create_new_project_and_delete(expected_states)
return create_new_project_and_delete(expected_states, False)

return _

Expand Down
12 changes: 12 additions & 0 deletions tests/e2e-playwright/tests/sim4life/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 12 additions & 2 deletions tests/e2e-playwright/tests/sim4life/test_sim4life.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MINUTE,
SECOND,
SOCKETIO_MESSAGE_PREFIX,
ServiceType,
SocketIOEvent,
decode_socketio_42_message,
wait_for_service_running,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 88a4b18

Please sign in to comment.