GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into fix/issue-26082 · pingdotgg/t3code@6ae3fe8
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docs/operations/scenarios.md +13-1Lines changed: 13 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -70,7 +70,19 @@ cd scripts && pnpm exec e2e run scenarios/replay-turn-streams.e2e.ts --headed | 70 | 70 |
| 71 | 71 | e2e starts the dev stack through [`start-app.ts`](../../scripts/scenarios/start-app.ts) on a free | 72 | 72 | port, runs the tests, and stops it. Results land in `scripts/.e2e`: `report.json`, `summary.md`, | 73 | | -and per test a `trace.md`, its screenshots, and a video. The first run downloads e2e's browser. | | 73 | +and per test a `trace.md`, its screenshots, and a video. `vp run scenarios --target web` runs one | | 74 | +target; flags go straight after the script name, without `--`. | | 75 | + | | 76 | +The first run downloads e2e's browser (about 120 MB). To fetch it ahead of time, such as in a | | 77 | +machine image, run this from the repository root after `vp i`: | | 78 | + | | 79 | +```sh | | 80 | +node scripts/node_modules/playwright-core/cli.js install --only-shell chromium ffmpeg | | 81 | +``` | | 82 | + | | 83 | +e2e opens the web app at `127.0.0.1`, and the start script tells the web dev server to bind that | | 84 | +address. It does not use `localhost`, which some machines resolve to `::1` first. | | 85 | + | 74 | 86 | `e2e run --help` lists the rest: `--grep`, `--watch`, `--last-failed`, `--changed-since`. | 75 | 87 |
| 76 | 88 | Run one at a time per checkout: a run recreates the checkout's scenario T3 home and its `.e2e` | |
Collapse file Copy file name to clipboardExpand all lines: scripts/e2e.config.ts +8-3Lines changed: 8 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,6 +46,11 @@ export const T3_HOME = resolved.home; | 46 | 46 | export const MOBILE_T3_HOME = `${T3_HOME}-mobile`; | 47 | 47 | export const MOBILE = resolved.mobile; | 48 | 48 | const startApp = resolved.startApp; | | 49 | +/** | | 50 | + * The one address e2e opens the web app at and the app is told to bind. Never `localhost`: the | | 51 | + * runner and the app can resolve that name to different addresses. | | 52 | + */ | | 53 | +const LOOPBACK = "127.0.0.1"; | 49 | 54 |
| 50 | 55 | /** | 51 | 56 | * Leases a device from the Simlock pool, whose gateway speaks agent-device's lease protocol. | @@ -131,12 +136,12 @@ export default { | 131 | 136 | name: "web", | 132 | 137 | engine: web({ viewport: { width: 1280, height: 800 } }), | 133 | 138 | app: { | 134 | | - url: "http://127.0.0.1:0", | | 139 | + url: `http://${LOOPBACK}:0`, | 135 | 140 | // Vite answers before the server does; this path is proxied to the server. | 136 | | - readyUrl: "http://127.0.0.1:{port}/.well-known/t3/environment", | | 141 | + readyUrl: `http://${LOOPBACK}:{port}/.well-known/t3/environment`, | 137 | 142 | command: { | 138 | 143 | executable: resolved.node, | 139 | | - args: [startApp, "web", T3_HOME, "{port}"], | | 144 | + args: [startApp, "web", T3_HOME, LOOPBACK, "{port}"], | 140 | 145 | cwd: APP_DIR, | 141 | 146 | startupTimeout: 300_000, | 142 | 147 | log: ".e2e/app.log", | |
Collapse file Copy file name to clipboardExpand all lines: scripts/scenarios/start-app.ts +40-9Lines changed: 40 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -141,17 +141,21 @@ const startApp = Effect.fn("startApp")(function* (input: { | 141 | 141 | ]; | 142 | 142 |
| 143 | 143 | if (input.surface === "web") { | 144 | | - const [webPort = ""] = input.ports; | 145 | | - const serverPort = yield* net.reserveLoopbackPort(); | | 144 | + // e2e opens the app at this host, so the web server is told to bind exactly it. Left to its | | 145 | + // default, `localhost`, it binds ::1 alone on machines that resolve the name to IPv6 first. | | 146 | + const [host = "", webPort = ""] = input.ports; | | 147 | + const origin = `http://${host}:${webPort}`; | | 148 | + const serverPort = String(yield* net.reserveLoopbackPort()); | 146 | 149 | const token = yield* (yield* SecureRandom.SecureRandom).uuidV4(); | 147 | | - const runner = yield* start({ | | 150 | + const ports = ["--port", serverPort, "--dev-url", origin]; | | 151 | + const webEnv = { ...env, T3CODE_PORT_OFFSET: String(Number(webPort) - BASE_WEB_PORT) }; | | 152 | + const server = yield* start({ | 148 | 153 | cwd: checkout, | 149 | 154 | command: node, | 150 | | - args: devRunner("dev", ["--port", String(serverPort)]), | | 155 | + args: devRunner("dev:server", ports), | 151 | 156 | env: { | 152 | | - ...env, | 153 | | - T3CODE_PORT_OFFSET: String(Number(webPort) - BASE_WEB_PORT), | 154 | | - T3CODE_DEV_ALLOWED_ORIGINS: `http://127.0.0.1:${webPort}`, | | 157 | + ...webEnv, | | 158 | + T3CODE_DEV_ALLOWED_ORIGINS: origin, | 155 | 159 | // Makes the startup pairing link reusable, so every test can sign in with it. | 156 | 160 | T3CODE_DEV_AUTH_TOKEN: `${token}${token}`.replaceAll("-", ""), | 157 | 161 | }, | @@ -165,7 +169,32 @@ const startApp = Effect.fn("startApp")(function* (input: { | 165 | 169 | .pipe(Effect.ignore); | 166 | 170 | }, | 167 | 171 | }); | 168 | | - return yield* runner.exitCode; | | 172 | + const web = yield* start({ | | 173 | + cwd: checkout, | | 174 | + command: node, | | 175 | + args: devRunner("dev:web", [...ports, "--", "--host", host]), | | 176 | + env: webEnv, | | 177 | + onLine: Console.log, | | 178 | + }); | | 179 | + // A web server that came up on another loopback address would leave e2e waiting out its | | 180 | + // whole startup timeout; say so at once instead. | | 181 | + const boundElsewhere = Effect.gen(function* () { | | 182 | + const elsewhere = host === "::1" ? "127.0.0.1" : "::1"; | | 183 | + if (yield* net.hasListenerOnHost(Number(webPort), host)) return yield* Effect.never; | | 184 | + if (!(yield* net.hasListenerOnHost(Number(webPort), elsewhere))) { | | 185 | + return yield* new ScenarioError({ message: "The web server is not listening yet." }); | | 186 | + } | | 187 | + yield* Console.error( | | 188 | + `The web server listens on ${elsewhere}:${webPort}, not on ${host}: it ignored --host.`, | | 189 | + ); | | 190 | + return 1; | | 191 | + }).pipe( | | 192 | + Effect.retry({ | | 193 | + schedule: Schedule.spaced("1 second"), | | 194 | + while: (error) => error._tag === "ScenarioError", | | 195 | + }), | | 196 | + ); | | 197 | + return yield* Effect.raceAll([server.exitCode, web.exitCode, boundElsewhere]); | 169 | 198 | } | 170 | 199 |
| 171 | 200 | // The device is another machine: the server listens on every interface, and Metro serves the | @@ -212,7 +241,9 @@ const command = Command.make( | 212 | 241 | ), | 213 | 242 | home: Argument.String("t3-home").pipe(Argument.withDescription("T3 home to recreate.")), | 214 | 243 | ports: Argument.String("port").pipe( | 215 | | - Argument.withDescription("web: <web-port>. mobile: <server-port> <metro-port> <host>."), | | 244 | + Argument.withDescription( | | 245 | + "web: <host> <web-port>. mobile: <server-port> <metro-port> <host>.", | | 246 | + ), | 216 | 247 | Argument.variadic(), | 217 | 248 | ), | 218 | 249 | }, | |
|