Skip to content

Commit

Permalink
Add default timeout (#343)
Browse files Browse the repository at this point in the history
* Add default timeout

add default timeout

* comment broken stuff so i can look at the video

* yaml button has been renamed

* remove sleep since we now have timeout

* timeouts are deprecated on is_visible

* thats what i get for editing on gh

* silly mistakes

* rework the dropdown expansion check
  • Loading branch information
kcpevey authored Dec 6, 2023
1 parent c871df9 commit ddb89cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions test/playwright/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytest

from playwright.sync_api import expect



def pytest_addoption(parser):
parser.addoption("--screenshots", action="store", default="false")
Expand Down
20 changes: 11 additions & 9 deletions test/playwright/test_ux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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):
Expand Down

0 comments on commit ddb89cc

Please sign in to comment.