|
19 | 19 | import arrow |
20 | 20 | import pytest |
21 | 21 | from faker import Faker |
22 | | -from playwright.sync_api import APIRequestContext, BrowserContext, Page |
| 22 | +from playwright.sync_api import APIRequestContext, BrowserContext, Page, expect |
23 | 23 | from playwright.sync_api._generated import Playwright |
24 | 24 | from pydantic import AnyUrl, TypeAdapter |
25 | 25 | from pytest_simcore.helpers.faker_factories import DEFAULT_TEST_PASSWORD |
@@ -414,6 +414,17 @@ def log_in_and_out( |
414 | 414 | page.wait_for_timeout(500) |
415 | 415 |
|
416 | 416 |
|
| 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 | + |
417 | 428 | @pytest.fixture |
418 | 429 | def create_new_project_and_delete( |
419 | 430 | page: Page, |
@@ -460,8 +471,7 @@ def _( |
460 | 471 | if template_id is not None: |
461 | 472 | if is_product_billable: |
462 | 473 | 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) |
465 | 475 | # it returns a Long Running Task |
466 | 476 | with page.expect_response( |
467 | 477 | re.compile(rf"/projects\?from_study\={template_id}") |
@@ -506,14 +516,10 @@ def wait_for_done(response): |
506 | 516 | else: |
507 | 517 | open_button.click() |
508 | 518 | 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) |
512 | 520 | open_with_resources_clicked = True |
513 | 521 | 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) |
517 | 523 | project_data = response_info.value.json() |
518 | 524 | assert project_data |
519 | 525 | project_uuid = project_data["data"]["uuid"] |
|
0 commit comments