From 8ad3a8968cc8c2d5c381c81293fafbf111ec7ae1 Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Wed, 4 Dec 2024 06:59:59 +0000 Subject: [PATCH] testing --- .github/workflows/ci.yml | 2 +- tests_notebooks/conftest.py | 7 +++++++ tests_notebooks/test_notification.py | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests_notebooks/test_notification.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 170ee9c..b33d86f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: run: echo "JUPYTER_TOKEN=$(openssl rand -hex 32)" >> $GITHUB_ENV - name: Run pytest - run: pytest -v --driver ${{ matrix.browser }} tests_notebooks + run: pytest -v --driver ${{ matrix.browser }} tests_notebooks -k test_notification env: TAG: edge diff --git a/tests_notebooks/conftest.py b/tests_notebooks/conftest.py index 379aa02..f188e7c 100644 --- a/tests_notebooks/conftest.py +++ b/tests_notebooks/conftest.py @@ -54,6 +54,13 @@ def execute(command, user=None, **kwargs): return execute +@pytest.fixture +def create_warning_file(aiidalab_exec): + aiidalab_exec( + "mkdir -p /home/jovyan/.aiidalab && echo 'This is a test warning' > /home/jovyan/.aiidalab/home_app_warning.md" + ) + + @pytest.fixture(scope="session", autouse=True) def notebook_service(docker_ip, docker_services, aiidalab_exec): """Ensure that HTTP service is up and responsive.""" diff --git a/tests_notebooks/test_notification.py b/tests_notebooks/test_notification.py new file mode 100644 index 0000000..0e11d2e --- /dev/null +++ b/tests_notebooks/test_notification.py @@ -0,0 +1,11 @@ +from selenium.webdriver.common.by import By + + +def test_home_notification(selenium_driver, create_warning_file, final_screenshot): + selenium = selenium_driver("start.ipynb") + selenium.set_window_size(1000, 941) + notifications = selenium.find_elements(By.CLASS_NAME, "home-notification") + assert len(notifications) == 1 + home_warning = notifications[0] + content_element = home_warning.find_element(By.TAG_NAME, "p") + assert content_element.text == "This is a test warning"