Files
coa-server-manager/tests/e2e/cdp.mjs
T
ДмитрийandClaude Sonnet 5.5 2e8803a067 Phase 1/2: Tauri shell, React UI (welcome, read-only import, overview with start/stop), e2e driver
Verified in the native window against a disposable fixture: import writes only
<folder>.manager + registry; start surfaces a human 'database update required'
message; stop returns to Offline. Live install untouched throughout.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 07:13:59 +05:00

25 lines
950 B
JavaScript

// Drives the real Tauri window over WebView2's DevTools protocol. Usage: node cdp.mjs <expression>
const port = process.env.CDP_PORT ?? "9222";
const targets = await (await fetch(`http://127.0.0.1:${port}/json`)).json();
const page = targets.find((t) => t.type === "page");
const ws = new WebSocket(page.webSocketDebuggerUrl);
await new Promise((r) => (ws.onopen = r));
let id = 0;
const pending = new Map();
ws.onmessage = (m) => {
const d = JSON.parse(m.data);
if (d.id && pending.has(d.id)) pending.get(d.id)(d);
};
export function evaluate(expression) {
return new Promise((resolve) => {
const n = ++id;
pending.set(n, resolve);
ws.send(JSON.stringify({ id: n, method: "Runtime.evaluate", params: { expression, awaitPromise: true, returnByValue: true } }));
});
}
if (process.argv[2]) {
const r = await evaluate(process.argv[2]);
console.log(JSON.stringify(r.result?.result?.value ?? r.result, null, 2));
ws.close();
}