import { describe, expect, it } from "vitest"; import { formatExternalSiteNavigationError, isTransientNavigationError, } from "@/lib/rpa/page-goto"; describe("page-goto resilience", () => { it("detects connection reset as transient", () => { expect( isTransientNavigationError( new Error( "page.goto: net::ERR_CONNECTION_RESET at https://www.priority1.com/", ), ), ).toBe(true); }); it("formats user-facing Priority1 navigation error", () => { const msg = formatExternalSiteNavigationError( "Priority1 官网", new Error("page.goto: net::ERR_CONNECTION_RESET"), ); expect(msg).toContain("连接被重置"); expect(msg).toContain("网络与代理"); expect(msg).not.toMatch(/ERR_|page\.goto|RPA_PROXY/i); }); });