The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { NETWORK_BLOCKING_HINT } from "./network.ts"; |
| 4 | import { isTransportConnectionErrorMessage, sanitizeThreadErrorMessage } from "./transport.ts"; |
| 5 | |
| 6 | describe("isTransportConnectionErrorMessage", () => { |
| 7 | it("returns true for React Native disconnected socket errors", () => { |
| 8 | expect( |
| 9 | isTransportConnectionErrorMessage( |
| 10 | "The operation couldn't be completed. Socket is not connected", |
| 11 | ), |
| 12 | ).toBe(true); |
| 13 | }); |
| 14 | |
| 15 | it("recognizes relay connection errors that carry the network hint", () => { |
| 16 | for (const sentence of [ |
| 17 | "Relay environment disconnected.", |
| 18 | "Relay environment stopped responding.", |
| 19 | "Relay environment could not establish a WebSocket connection.", |
| 20 | ]) { |
| 21 | expect(isTransportConnectionErrorMessage(`${sentence} ${NETWORK_BLOCKING_HINT}`)).toBe(true); |
| 22 | } |
| 23 | expect( |
| 24 | isTransportConnectionErrorMessage( |
| 25 | "Your ChatGPT connection expired or was disconnected. Sign in again.", |
| 26 | ), |
| 27 | ).toBe(false); |
| 28 | }); |
| 29 | }); |
| 30 | |
| 31 | describe("sanitizeThreadErrorMessage", () => { |
| 32 | it("strips transport errors", () => { |
| 33 | expect(sanitizeThreadErrorMessage("SocketCloseError: oops")).toBeNull(); |
| 34 | }); |
| 35 | }); |