diff --git a/test/playwright/conftest.py b/test/playwright/conftest.py index 1b09f67e..c7737983 100644 --- a/test/playwright/conftest.py +++ b/test/playwright/conftest.py @@ -1,5 +1,8 @@ import pytest +from playwright.sync_api import expect + + def pytest_addoption(parser): parser.addoption("--screenshots", action="store", default="false") diff --git a/test/playwright/test_ux.py b/test/playwright/test_ux.py index 5260e280..46355617 100644 --- a/test/playwright/test_ux.py +++ b/test/playwright/test_ux.py @@ -6,11 +6,14 @@ import time import pytest -from playwright.sync_api import Page -from playwright.sync_api import sync_playwright +from playwright.sync_api import Page, sync_playwright, expect import random +DEFAULT_TIMEOUT = 30_000 # time in ms + +expect.set_options(timeout=DEFAULT_TIMEOUT) + CONDA_STORE_SERVER_PORT = os.environ.get( "CONDA_STORE_SERVER_PORT", f"8080" ) @@ -119,11 +122,11 @@ def _create_new_environment(page, screenshot=False): # click on the Active environment on the dropdown menu item (which is currently building) page.get_by_role("option", name=" - Active", exact=False).click() # ensure that the environment is building - assert page.get_by_text("Building").is_visible() + expect(page.get_by_text("Building")).to_be_visible() # wait until the status is `Completed` completed = page.get_by_text("Completed", exact=False) completed.wait_for(state='attached', timeout=time_to_build_env) - assert completed.is_visible() + expect(completed).to_be_visible() return new_env_name @@ -177,7 +180,9 @@ def _existing_environment_interactions(page, env_name, time_to_build_env=3*60*10 completed.wait_for(state='attached', timeout=time_to_build_env) # ensure the namespace is expanded - if not page.get_by_role("button", name=env_name).is_visible(): + try: + expect(page.get_by_role("button", name=env_name)).to_be_visible() + except Exception as e: # click to expand the `username` name space (but not click the +) page.get_by_role("button", name="username Create a new environment in the username namespace").click() @@ -217,7 +222,6 @@ def _existing_environment_interactions(page, env_name, time_to_build_env=3*60*10 completed = page.get_by_text("Completed", exact=False) completed.wait_for(state='attached', timeout=time_to_build_env) - # Edit -> Cancel editing page.get_by_role("button", name=env_name).click() page.get_by_role("button", name="Edit").click() @@ -228,9 +232,7 @@ def _existing_environment_interactions(page, env_name, time_to_build_env=3*60*10 page.get_by_text("Delete environment").click() page.get_by_role("button", name="Delete").click() - time.sleep(5) # wait for it to render, flaky otherwise - assert not page.get_by_role("button", name=env_name).is_visible() - + expect(page.get_by_role("button", name=env_name)).not_to_be_visible() def test_integration(page: Page, test_config, screenshot):