mirror of
https://github.com/aiclientproxy/proxycast.git
synced 2026-10-16 15:34:08 +08:00
test: wait for workspace readiness in at command e2e
This commit is contained in:
@@ -92,6 +92,12 @@ function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function readConsoleText(consoleMessages) {
|
||||
return consoleMessages
|
||||
.map((item) => String(item?.text || ""))
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
function timeoutAfter(ms) {
|
||||
return new Promise((resolve) => {
|
||||
const timer = setTimeout(resolve, ms);
|
||||
@@ -486,12 +492,14 @@ async function main() {
|
||||
|
||||
const page = await context.newPage();
|
||||
const invokes = [];
|
||||
const consoleMessages = [];
|
||||
|
||||
page.on("console", (message) => {
|
||||
const entry = {
|
||||
type: message.type(),
|
||||
text: message.text(),
|
||||
};
|
||||
consoleMessages.push(entry);
|
||||
if (message.type() === "error") {
|
||||
summary.consoleErrors.push(entry);
|
||||
} else if (message.type() === "warning") {
|
||||
@@ -542,6 +550,33 @@ async function main() {
|
||||
{ timeout: options.timeoutMs },
|
||||
);
|
||||
|
||||
logStage(options, "wait-workspace-ready");
|
||||
const workspaceReadySignal = await waitForCondition(
|
||||
"等待默认工作区完成加载",
|
||||
() => {
|
||||
const consoleText = readConsoleText(consoleMessages);
|
||||
if (consoleText.includes("AgentChatPage.loadData.projectOnlyComplete")) {
|
||||
return "AgentChatPage.loadData.projectOnlyComplete";
|
||||
}
|
||||
if (consoleText.includes("AgentChatPage.loadData.projectLoaded")) {
|
||||
return "AgentChatPage.loadData.projectLoaded";
|
||||
}
|
||||
if (consoleText.includes("AgentChatPage.workspaceCheck.success")) {
|
||||
return "AgentChatPage.workspaceCheck.success";
|
||||
}
|
||||
if (invokes.some((item) => item.cmd === "workspace_ensure_ready")) {
|
||||
return "invoke:workspace_ensure_ready";
|
||||
}
|
||||
if (invokes.some((item) => item.cmd === "aster_agent_init")) {
|
||||
return "invoke:aster_agent_init";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
options.timeoutMs,
|
||||
options.intervalMs,
|
||||
);
|
||||
summary.workspaceReadySignal = workspaceReadySignal;
|
||||
|
||||
logStage(options, "open-at-panel");
|
||||
await textarea.click();
|
||||
await textarea.fill("@");
|
||||
|
||||
Reference in New Issue
Block a user