The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): move the token download-transport invariant beside the extracted function
Tekniumff662b6b4324
diff --git a/apps/desktop/electron/gateway-download-transport.test.ts b/apps/desktop/electron/gateway-download-transport.test.tsindex c5a9a9b612f..e5304d6f121 100644--- a/apps/desktop/electron/gateway-download-transport.test.ts+++ b/apps/desktop/electron/gateway-download-transport.test.ts@@ -35,6 +35,31 @@ test('download transport never follows redirects or retries after the save phase}})+test('the connect timeout is dropped once headers arrive so a slow body streams to completion', async () => {+ // The transport hands the raw response stream to the finalizer instead of+ // buffering it, so the socket must stay open for as long as the save takes.+ // A body that trickles in slower than the connect timeout must still land+ // in full; only the wait for headers is bounded.+ const server = http.createServer((_req, res) => {+ res.writeHead(200, { 'Content-Type': 'application/octet-stream' })+ res.write('head-')+ setTimeout(() => res.end('tail'), 120)+ })+ await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve))+ const url = `http://127.0.0.1:${(server.address() as net.AddressInfo).port}/file`+ const finish = async (res: http.IncomingMessage) => {+ const chunks: Buffer[] = []+ for await (const chunk of res) { chunks.push(Buffer.from(chunk)) }+ return Buffer.concat(chunks).toString()+ }+ try {+ await expect(downloadViaTokenToFile(url, 'remote-static', {}, finish, { timeoutMs: 30 })).resolves.toBe('head-tail')+ } finally {+ destroyKeepaliveAgents()+ await new Promise<void>(resolve => server.close(() => resolve()))+ }+})+test.skipIf(process.platform === 'win32')('download retries mint a new private grant for every wire attempt and preserve remote auth', async () => {const home = await fs.mkdtemp(path.join(os.tmpdir(), 'download-auth-'))const grants: string[] = []diff --git a/apps/desktop/electron/gateway-file-download-transport.test.ts b/apps/desktop/electron/gateway-file-download-transport.test.tsindex 128510ebbf5..afd5a91a3c8 100644--- a/apps/desktop/electron/gateway-file-download-transport.test.ts+++ b/apps/desktop/electron/gateway-file-download-transport.test.ts@@ -1,9 +1,11 @@/*** Wiring coverage for the main.ts gateway download transports. These functions- * pull in main-process singletons (https/http, electronNet, the OAuth session,- * the save dialog), so we assert on their source shape — the same approach as+ * pull in main-process singletons (electronNet, the OAuth session, the save+ * dialog), so we assert on their source shape — the same approach as* oauth-session-request.test.ts — while gateway-file-download.test.ts unit-tests- * the extracted streaming/decoding logic behaviorally.+ * the extracted streaming/decoding logic behaviorally. The token transport+ * lives in gateway-download-transport.ts and is covered behaviorally by+ * gateway-download-transport.test.ts.*/import assert from 'node:assert/strict'@@ -25,18 +27,6 @@ function extract(startMarker: string, endMarker: string): string {return source.slice(start, end)}-test('token transport streams to disk instead of buffering the whole body', () => {- const fn = extract('function downloadViaTokenToFile', '\nfunction ')-- // Delegates byte-moving to the streaming finalizer...- assert.match(fn, /finalizeGatewayDownload\(/)- // ...and must NOT accumulate the full response before writing.- assert.doesNotMatch(fn, /Buffer\.concat/)- assert.doesNotMatch(fn, /chunks\.push/)- // Idle timeout is dropped once headers arrive so the dialog/stream isn't killed.- assert.match(fn, /setTimeout\(0\)/)-})-test('oauth transport streams to disk instead of buffering the whole body', () => {const fn = extract('function downloadViaOauthSessionToFile', '\nasync function finalizeGatewayDownload')