fix(web-probe): verify prompt chat submission
This commit is contained in:
@@ -355,9 +355,21 @@ async function sendPrompt(text) {
|
||||
'[aria-label*="发送"]'
|
||||
].join(", ")).last();
|
||||
await submit.waitFor({ state: "visible", timeout: 15000 });
|
||||
const chatResponsePromise = page.waitForResponse((response) => {
|
||||
const request = response.request();
|
||||
return request.method().toUpperCase() === "POST" && response.url().includes("/v1/agent/chat");
|
||||
}, { timeout: 20000 }).catch((error) => ({ waitError: errorSummary(error) }));
|
||||
await submit.click();
|
||||
await page.waitForTimeout(1500);
|
||||
return { beforeUrl, afterUrl: currentPageUrl(), textHash: sha256Text(text), textBytes: Buffer.byteLength(text), pageId };
|
||||
const chatResponse = await chatResponsePromise;
|
||||
await page.waitForTimeout(500);
|
||||
if (chatResponse?.waitError) {
|
||||
throw new Error("sendPrompt did not observe POST /v1/agent/chat response after submit: " + (chatResponse.waitError.message || chatResponse.waitError.name || "timeout"));
|
||||
}
|
||||
const chatStatus = chatResponse.status();
|
||||
if (chatStatus < 200 || chatStatus >= 300) {
|
||||
throw new Error("sendPrompt observed POST /v1/agent/chat HTTP " + chatStatus + " " + chatResponse.statusText());
|
||||
}
|
||||
return { beforeUrl, afterUrl: currentPageUrl(), textHash: sha256Text(text), textBytes: Buffer.byteLength(text), chatSubmit: { status: chatStatus, statusText: chatResponse.statusText(), urlPath: urlPath(chatResponse.url()) }, pageId };
|
||||
}
|
||||
|
||||
async function selectProvider(provider) {
|
||||
|
||||
Reference in New Issue
Block a user