diff --git a/tests/e2e/wdio.electrobun.conf.js b/tests/e2e/wdio.electrobun.conf.js index 9870376..a20656b 100644 --- a/tests/e2e/wdio.electrobun.conf.js +++ b/tests/e2e/wdio.electrobun.conf.js @@ -142,17 +142,23 @@ export const config = { }, async before() { - // Wait for Electrobun app to render — use string script for CDP compatibility + // Navigate CEF to Vite dev server (views:// protocol can't serve ES modules in CEF) + console.log('[electrobun-cdp] Navigating to Vite dev server...'); + await browser.url('http://localhost:9760/'); + await browser.pause(3000); // Wait for Svelte to mount + + // Wait for app to render await browser.waitUntil( async () => { const hasEl = await browser.execute( - 'return document.querySelector(".app-shell") !== null' + - ' || document.querySelector(".project-grid") !== null' + - ' || document.querySelector(".status-bar") !== null' + 'return document.querySelector(".left-sidebar") !== null' + + ' || document.querySelector(".project-card") !== null' + + ' || document.querySelector(".status-bar") !== null' + + ' || document.querySelector("#app")?.children?.length > 0' ); return hasEl; }, - { timeout: 20_000, interval: 500, timeoutMsg: 'Electrobun app did not load in 20s' }, + { timeout: 20_000, interval: 500, timeoutMsg: 'Electrobun app did not render in 20s' }, ); console.log('[electrobun-cdp] App loaded.'); }, diff --git a/ui-electrobun/src/mainview/rpc.ts b/ui-electrobun/src/mainview/rpc.ts index e51a7c5..81e9f85 100644 --- a/ui-electrobun/src/mainview/rpc.ts +++ b/ui-electrobun/src/mainview/rpc.ts @@ -38,7 +38,14 @@ export function setAppRpc(rpc: AppRpcHandle): void { export const appRpc: AppRpcHandle = new Proxy({} as AppRpcHandle, { get(_target, prop) { if (!_rpc) { - throw new Error(`[rpc] accessed before init — property "${String(prop)}"`); + // Graceful degradation: return no-ops instead of throwing. + // This allows the app to mount even when RPC isn't available + // (e.g., E2E tests loading via http:// instead of views://). + if (prop === 'request') return new Proxy({}, { get: () => async () => null }); + if (prop === 'addMessageListener') return () => {}; + if (prop === 'removeMessageListener') return () => {}; + console.warn(`[rpc] accessed before init — property "${String(prop)}" (returning no-op)`); + return () => {}; } return (_rpc as Record)[prop]; },