@@ -93,35 +93,21 @@ def record(name: str, payload: dict[str, Any]) -> None:
9393
9494 # 2. ui-event 직접 fetch — 위젯 클릭 round-trip
9595 ctx2 = browser .new_context ()
96- page2 = ctx2 .new_page ()
97- page2 .goto (base , wait_until = "domcontentloaded" , timeout = 15000 )
98- createResp = page2 .evaluate (
99- """async () => {
100- const create = await fetch('/api/kernel/create', {
101- method: 'POST',
102- headers: { 'Content-Type': 'application/json' },
103- body: JSON.stringify({ workingDirectory: null }),
104- });
105- return await create.json();
106- }"""
96+ createResponse = ctx2 .request .post (
97+ f"{ base } /api/kernel/create" ,
98+ data = {"workingDirectory" : None },
10799 )
100+ createResp = createResponse .json ()
108101 sessionId = createResp .get ("sessionId" )
109- clickResp = page2 .evaluate (
110- """async ({ sessionId, callbackId }) => {
111- const r = await fetch(`/api/kernel/${sessionId}/ui-event`, {
112- method: 'POST',
113- headers: { 'Content-Type': 'application/json' },
114- body: JSON.stringify({ callbackId, eventType: 'click', payload: null }),
115- });
116- return { status: r.status, body: await r.json() };
117- }""" ,
118- {"sessionId" : sessionId , "callbackId" : callbackId },
102+ clickResponse = ctx2 .request .post (
103+ f"{ base } /api/kernel/{ sessionId } /ui-event" ,
104+ data = {"callbackId" : callbackId , "eventType" : "click" , "payload" : None },
119105 )
120106 record ("widget-click-round-trip" , {
121107 "sessionId" : sessionId ,
122- "httpStatus" : clickResp [ " status" ] ,
108+ "httpStatus" : clickResponse . status ,
123109 "callbackFired" : clicks == ["clicked" ],
124- "responseStatus" : clickResp [ "body" ] .get ("status" ),
110+ "responseStatus" : clickResponse . json () .get ("status" ),
125111 })
126112 ctx2 .close ()
127113
0 commit comments