Skip to content

Commit 1eb6dd0

Browse files
authored
🐛 [e2e] open_with_resources (#6809)
1 parent 28a54d6 commit 1eb6dd0

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/e2e-playwright/tests/conftest.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import arrow
2020
import pytest
2121
from faker import Faker
22-
from playwright.sync_api import APIRequestContext, BrowserContext, Page
22+
from playwright.sync_api import APIRequestContext, BrowserContext, Page, expect
2323
from playwright.sync_api._generated import Playwright
2424
from pydantic import AnyUrl, TypeAdapter
2525
from pytest_simcore.helpers.faker_factories import DEFAULT_TEST_PASSWORD
@@ -414,6 +414,17 @@ def log_in_and_out(
414414
page.wait_for_timeout(500)
415415

416416

417+
def _open_with_resources(page: Page, *, click_it: bool):
418+
study_title_field = page.get_by_test_id("studyTitleField")
419+
# wait until the title is automatically filled up
420+
expect(study_title_field).not_to_have_value("", timeout=5000)
421+
422+
open_with_resources_button = page.get_by_test_id("openWithResources")
423+
if click_it:
424+
open_with_resources_button.click()
425+
return open_with_resources_button
426+
427+
417428
@pytest.fixture
418429
def create_new_project_and_delete(
419430
page: Page,
@@ -460,8 +471,7 @@ def _(
460471
if template_id is not None:
461472
if is_product_billable:
462473
open_button.click()
463-
# Open project with default resources
464-
open_button = page.get_by_test_id("openWithResources")
474+
open_button = _open_with_resources(page, click_it=False)
465475
# it returns a Long Running Task
466476
with page.expect_response(
467477
re.compile(rf"/projects\?from_study\={template_id}")
@@ -506,14 +516,10 @@ def wait_for_done(response):
506516
else:
507517
open_button.click()
508518
if is_product_billable:
509-
# Open project with default resources
510-
open_button = page.get_by_test_id("openWithResources")
511-
open_button.click()
519+
_open_with_resources(page, click_it=True)
512520
open_with_resources_clicked = True
513521
if is_product_billable and not open_with_resources_clicked:
514-
# Open project with default resources
515-
open_button = page.get_by_test_id("openWithResources")
516-
open_button.click()
522+
_open_with_resources(page, click_it=True)
517523
project_data = response_info.value.json()
518524
assert project_data
519525
project_uuid = project_data["data"]["uuid"]

0 commit comments

Comments
 (0)