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