Files
bonaminandClaude Opus 5.5 584dd1e510 test: end-to-end suites (install.sh, licensing, browser, Android emulator) + runner
tests/e2e (see its README):
- install.mjs: real install.sh in a Debian container - VPN-safe HOST_IP
  detection on simulated hosts, fresh/upgrade/re-run, and the proxy config
  byte-identical to nginx-proxy/nginx.conf (guards rule CS-5)
- license_e2e.py: real cloud + site processes with a throwaway signing key -
  400 days offline, tampered file, clock rollback, expiry deferred to workday
  close, renewal, remote lock
- browser.mjs: web delivery modes (same-origin, plain HTTP by LAN IP, venue
  mode) and the install dialog on Android/iPhone/desktop/no-APK
- android.mjs basics|rediscovery|stacks: pairing, venues, camera, back
  button, restart; IP change / server down / cold start; TLS pinning
  (wrong-key QR, impostor, upgrade, renewal, rediscovery) and UI bundles
  (apply, staged, tampered, APK too old, rollback, two venues) on isolated
  compose stacks built from the repo
- lib/: env (paths, LAN IP autodetect, settings), proc (seeded throwaway
  DBs via demo_seed.py, backends, nginx, Vite, compose stacks), android
  (adb + WebView DevTools, boots the AVD), cdp
- run-all.mjs runs everything fastest-first with a summary
Nothing machine-specific is hard-coded; developer stacks/DBs are never touched.
Results on this machine: install 9/9, license 17/17, browser 22/22,
android basics 19/19, rediscovery 10/10, stacks 21/21.

Pack README: Testing section + rule CS-11 (tests follow the code; run
run-all before a release).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 23:38:18 +03:00

42 lines
1.9 KiB
JavaScript

// Minimal Chrome DevTools Protocol client for the app's Android WebView
// (exposed with `adb forward tcp:9333 localabstract:webview_devtools_remote_<pid>`).
// Playwright can't drive an Android WebView's browser context, so this speaks CDP directly.
export async function connectWebView(port = 9333) {
const targets = await fetch(`http://127.0.0.1:${port}/json`).then(r => r.json())
const target = targets.find(t => t.type === 'page')
if (!target) throw new Error('no WebView page target')
const ws = new WebSocket(target.webSocketDebuggerUrl)
await new Promise((resolve, reject) => { ws.onopen = resolve; ws.onerror = reject })
let id = 0
const pending = new Map()
const logs = []
ws.onmessage = ev => {
const msg = JSON.parse(ev.data)
if (msg.id && pending.has(msg.id)) {
const { resolve, reject } = pending.get(msg.id)
pending.delete(msg.id)
msg.error ? reject(new Error(msg.error.message)) : resolve(msg.result)
} else if (msg.method === 'Runtime.consoleAPICalled') {
logs.push(`[${msg.params.type}] ` + msg.params.args.map(a => a.value ?? a.description ?? '').join(' ').slice(0, 300))
} else if (msg.method === 'Runtime.exceptionThrown') {
const d = msg.params.exceptionDetails
logs.push('EXCEPTION ' + (d.exception?.description || d.text).slice(0, 400))
}
}
const send = (method, params = {}) => new Promise((resolve, reject) => {
const msgId = ++id
pending.set(msgId, { resolve, reject })
ws.send(JSON.stringify({ id: msgId, method, params }))
})
await send('Runtime.enable')
await send('Page.enable')
const evaluate = async expression => {
const r = await send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true })
if (r.exceptionDetails) throw new Error('eval failed: ' + (r.exceptionDetails.exception?.description || r.exceptionDetails.text))
return r.result.value
}
return { send, evaluate, logs, close: () => ws.close() }
}