// Reads the in-memory websocket connection state for a given session via // the dev-only /internal/_test/ws-connection-state endpoint. Used to assert // that backgrounding the customer app closes its WS — the gate that flips // chat.service.sendMessage to the FCM fallback path. // // Env: // SESSION_ID (required) // BACKEND_INTERNAL_URL (optional, default http://localhost:3001) const sessionId = SESSION_ID const url = BACKEND_INTERNAL_URL || 'http://localhost:3001' if (!sessionId) throw new Error('SESSION_ID env not set') const resp = http.get(`${url}/internal/_test/ws-connection-state?session_id=${sessionId}`) if (resp.status !== 200) { throw new Error(`ws-connection-state failed (${resp.status}): ${resp.body}`) } const data = json(resp.body) output.CUSTOMER_CONNECTED = String(data.customer_connected) output.MITRA_CONNECTED = String(data.mitra_connected)