diff --git a/src/daemon/gateway-fleet.e2e.test.ts b/src/daemon/gateway-fleet.e2e.test.ts index 975b7ece5..feaab82e0 100644 --- a/src/daemon/gateway-fleet.e2e.test.ts +++ b/src/daemon/gateway-fleet.e2e.test.ts @@ -227,6 +227,8 @@ describe("gateway fleet smoke (ADR 0005 §35)", () => { readonly npm?: NpmCli; /** why: a worker that runs a real command runs it in its lease folder, which has to exist on disk. */ readonly realFilesystem?: boolean; + /** why: holds the gateway's first catalog read open, so a view shows `connected` before it lists the worker's model. */ + readonly catalogLatencyMs?: number; }): Promise<{ daemon: DaemonServer; filesystem: Filesystem; directory: string }> { const directory = options.existing?.directory ?? @@ -247,6 +249,9 @@ describe("gateway fleet smoke (ADR 0005 §35)", () => { }), clock: new SystemClock(), knownModels: [options.model], + ...(options.catalogLatencyMs === undefined + ? {} + : { latencyMs: { listCatalog: options.catalogLatencyMs } }), platform: "android", }); options.onDriver?.(driver); @@ -662,6 +667,8 @@ describe("gateway fleet smoke (ADR 0005 §35)", () => { stdout: "hello-from-b", gatewayUrl: restartGatewayUrl(), existing: { directory: workerB.directory, filesystem: workerB.filesystem }, + // why: #1628: the catalog lands after `connected` and `drained`; held here so the wait below must cover it on every run. + catalogLatencyMs: 1_000, }); await vi.waitFor( async () => { @@ -669,6 +676,8 @@ describe("gateway fleet smoke (ADR 0005 §35)", () => { const view = workers.find((worker) => worker.id === workerBId); expect(view?.connection).toBe("connected"); expect(view?.drained).toBe(true); + // why: `connected` and `drained` show before the catalog read lands; a fresh gateway has no older catalog, so routing answers UNKNOWN_MODEL until then. + expect(view?.catalog?.some((entry) => entry.models.includes("Pixel-B"))).toBe(true); }, { timeout: 15_000 }, );