diff --git a/test/e2e/live/dashboard-remote-bind-env.ts b/test/e2e/live/dashboard-remote-bind-env.ts index 415ab072dfc..623a8d47c18 100644 --- a/test/e2e/live/dashboard-remote-bind-env.ts +++ b/test/e2e/live/dashboard-remote-bind-env.ts @@ -28,14 +28,19 @@ export function buildDashboardRemoteBindEnv( } export function dashboardRemoteBindConnectStarted( - result: { exitCode: number | null; stdout: string; stderr: string }, + result: { + exitCode: number | null; + stdout: string; + stderr: string; + timedOut?: boolean; + }, sandboxName: string, dashboardPort: string, ): boolean { const output = stripAnsi(`${result.stdout}\n${result.stderr}`); return ( result.exitCode === 0 || - (result.exitCode === null && + ((result.exitCode === null || result.timedOut === true) && (output.includes("Dashboard port forward re-established.") || (output.includes(`Forwarding port ${dashboardPort}`) && output.includes(`sandbox ${sandboxName}`)))) diff --git a/test/e2e/support/dashboard-remote-bind-env.test.ts b/test/e2e/support/dashboard-remote-bind-env.test.ts index 8d7a89b2279..f319b2235ee 100644 --- a/test/e2e/support/dashboard-remote-bind-env.test.ts +++ b/test/e2e/support/dashboard-remote-bind-env.test.ts @@ -46,6 +46,19 @@ describe("dashboard remote-bind E2E environment", () => { ).toBe(true); }); + it("accepts recovery proof after the interactive connect reaches its test deadline (#9606)", () => { + const timedOutRecovery = { + exitCode: 143, + timedOut: true, + stdout: "\u001B[32m✓\u001B[0m Dashboard port forward re-established.\n", + stderr: "client_loop: send disconnect: Broken pipe\n", + }; + + expect(dashboardRemoteBindConnectStarted(timedOutRecovery, "e2e-dashboard-bind", "18789")).toBe( + true, + ); + }); + it("rejects a connect result with no numeric exit code and no forward proof", () => { expect( dashboardRemoteBindConnectStarted( @@ -59,4 +72,34 @@ describe("dashboard remote-bind E2E environment", () => { ), ).toBe(false); }); + + it("rejects a completed nonzero connect even when it printed recovery proof (#9606)", () => { + expect( + dashboardRemoteBindConnectStarted( + { + exitCode: 1, + timedOut: false, + stdout: "Dashboard port forward re-established.\n", + stderr: "connect failed\n", + }, + "e2e-dashboard-bind", + "18789", + ), + ).toBe(false); + }); + + it("rejects a timed-out interactive connect without background-forward proof (#9606)", () => { + expect( + dashboardRemoteBindConnectStarted( + { + exitCode: 143, + timedOut: true, + stdout: "Connecting to sandbox...\n", + stderr: "client_loop: send disconnect: Broken pipe\n", + }, + "e2e-dashboard-bind", + "18789", + ), + ).toBe(false); + }); });