Skip to content

Commit 75d3f71

Browse files
committed
creating function works
1 parent cbf68a4 commit 75d3f71

File tree

2 files changed

+94
-39
lines changed

2 files changed

+94
-39
lines changed

tests/e2e-playwright/tests/conftest.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -597,22 +597,29 @@ def wait_for_done(response):
597597
yield _
598598

599599
# go back to dashboard and wait for project to close
600-
with ExitStack() as stack:
601-
for project_uuid in created_project_uuids:
602-
ctx = stack.enter_context(
603-
log_context(logging.INFO, f"Wait for closed project {project_uuid=}")
604-
)
605-
stack.enter_context(
606-
log_in_and_out.expect_event(
607-
"framereceived",
608-
SocketIOProjectClosedWaiter(ctx.logger),
609-
timeout=_PROJECT_CLOSING_TIMEOUT,
610-
)
600+
with log_context(logging.INFO, "Go back to dashboard") as ctx1:
601+
if page.get_by_test_id("dashboardBtn").is_visible():
602+
with ExitStack() as stack:
603+
for project_uuid in created_project_uuids:
604+
ctx = stack.enter_context(
605+
log_context(
606+
logging.INFO, f"Wait for closed project {project_uuid=}"
607+
)
608+
)
609+
stack.enter_context(
610+
log_in_and_out.expect_event(
611+
"framereceived",
612+
SocketIOProjectClosedWaiter(ctx.logger),
613+
timeout=_PROJECT_CLOSING_TIMEOUT,
614+
)
615+
)
616+
if created_project_uuids:
617+
page.get_by_test_id("dashboardBtn").click()
618+
page.get_by_test_id("confirmDashboardBtn").click()
619+
else:
620+
ctx1.logger.warning(
621+
"Cannot go back to dashboard, 'dashboard' button is not visible, we are probably already there"
611622
)
612-
if created_project_uuids:
613-
with log_context(logging.INFO, "Go back to dashboard"):
614-
page.get_by_test_id("dashboardBtn").click()
615-
page.get_by_test_id("confirmDashboardBtn").click()
616623

617624
for project_uuid in created_project_uuids:
618625
with log_context(

tests/e2e-playwright/tests/metamodeling/test_response_surface_modeling.py

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
r"/flask/list_function_job_collections_for_functionid"
1919
)
2020

21+
_STUDY_FUNCTION_NAME: Final[str] = "playwright_test_study_for_rsm"
2122
_FUNCTION_NAME: Final[str] = "playwright_test_function"
2223

2324

@@ -33,7 +34,7 @@ def test_response_surface_modeling(
3334
is_service_legacy: bool,
3435
):
3536
# 1. create the initial study with jsonifier
36-
with log_context(logging.INFO, "Create new study..."):
37+
with log_context(logging.INFO, "Create new study for function"):
3738
jsonifier_project_data = create_project_from_service_dashboard(
3839
ServiceType.COMPUTATIONAL, "jsonifier", None, service_version
3940
)
@@ -52,34 +53,81 @@ def test_response_surface_modeling(
5253
].click()
5354

5455
# create the probe
55-
page.get_by_test_id("connect_probe_btn_number_3").click()
56+
with page.expect_response(
57+
lambda response: re.compile(
58+
rf"/projects/{jsonifier_project_data['uuid']}"
59+
).search(response.url)
60+
is not None
61+
and response.request.method == "PATCH"
62+
):
63+
page.get_by_test_id("connect_probe_btn_number_3").click()
5664

5765
# # create the parameter
58-
# with page.expect_response(
59-
# re.compile(rf"/projects/{jsonifier_project_data['uuid']}/nodes")
60-
# ):
61-
# page.get_by_test_id("newNodeBtn").click()
62-
# page.get_by_placeholder("Filter").click()
63-
# page.get_by_placeholder("Filter").fill("number parameter")
64-
# page.get_by_placeholder("Filter").press("Enter")
65-
66-
# # connect the parameter
67-
# page.get_by_test_id("nodeTreeItem").filter(has_text="jsonifier").all()[
68-
# 1
69-
# ].click()
70-
# page.get_by_test_id("connect_input_btn_number_1").click()
71-
# page.get_by_text("set existing parameter").nth(1).click()
72-
# page.wait_for_timeout(1000)
73-
# page.get_by_text("Number Parameter").click()
74-
# page.wait_for_timeout(5000)
7566
page.get_by_test_id("connect_input_btn_number_1").click()
76-
page.get_by_text("new parameter").click()
67+
with page.expect_response(
68+
lambda response: re.compile(
69+
rf"/projects/{jsonifier_project_data['uuid']}"
70+
).search(response.url)
71+
is not None
72+
and response.request.method == "PATCH"
73+
):
74+
page.get_by_text("new parameter").click()
7775

7876
# rename the project to identify it
79-
page.get_by_test_id("nodesTree").first.click()
80-
page.get_by_test_id("nodesTree").first.press("F2")
81-
page.get_by_test_id("nodesTree").first.fill("RSM study")
82-
# 2. convert it to a function
77+
page.get_by_test_id("studyTitleRenamer").click()
78+
with page.expect_response(
79+
lambda response: re.compile(
80+
rf"/projects/{jsonifier_project_data['uuid']}"
81+
).search(response.url)
82+
is not None
83+
and response.request.method == "PATCH"
84+
):
85+
page.get_by_test_id("studyTitleRenamer").locator("input").fill(
86+
_STUDY_FUNCTION_NAME
87+
)
88+
89+
# 2. go back to dashboard
90+
with (
91+
log_context(logging.INFO, "Go back to dashboard"),
92+
page.expect_response(re.compile(r"/projects\?.+")) as list_projects_response,
93+
):
94+
page.get_by_test_id("dashboardBtn").click()
95+
page.get_by_test_id("confirmDashboardBtn").click()
96+
assert (
97+
list_projects_response.value.ok
98+
), f"Failed to list projects: {list_projects_response.value.status}"
99+
project_listing = list_projects_response.value.json()
100+
assert "data" in project_listing
101+
assert len(project_listing["data"]) > 0
102+
# find the project we just created, it's the first one
103+
our_project = project_listing["data"][0]
104+
assert (
105+
our_project["name"] == _STUDY_FUNCTION_NAME
106+
), f"Expected to find our project named {_STUDY_FUNCTION_NAME} in {project_listing}"
107+
our_project_uuid = our_project["uuid"]
108+
109+
# 3. convert it to a function
110+
with log_context(
111+
logging.INFO,
112+
f"Convert {our_project_uuid=} / {our_project['name']} to a function",
113+
) as ctx:
114+
with page.expect_response(re.compile(rf"/projects/{our_project_uuid}")):
115+
page.get_by_test_id(f"studyBrowserListItem_{our_project_uuid}").click()
116+
page.wait_for_timeout(2000)
117+
page.get_by_text("create function").first.click()
118+
page.wait_for_timeout(2000)
119+
120+
with page.expect_response(
121+
lambda response: re.compile(r"/functions").search(response.url) is not None
122+
and response.request.method == "POST"
123+
) as create_function_response:
124+
page.get_by_test_id("create_function_page_btn").click()
125+
assert (
126+
create_function_response.value.ok
127+
), f"Failed to create function: {create_function_response.value.status}"
128+
function_data = create_function_response.value.json()
129+
ctx.logger.info("Created function: %s", function_data)
130+
83131
# 3. start a RSM with that function
84132

85133
# with log_context(

0 commit comments

Comments
 (0)