From af1b1352bf065d5d78f53e22fc6b55bb3719a8f9 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 20 Apr 2026 04:32:23 +0800 Subject: [PATCH] test(sidebar-agent): regex-tolerant destructure check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same class of brittleness as sidebar-security.test.ts fixed earlier (commit 65bf4514). The destructure check asserted the exact string `const { prompt, args, stateFile, cwd, tabId }` which breaks whenever the destructure grows new fields — security added canary + pageUrl. Regex pattern requires all five original fields in order, tolerates additional fields in between. Preserves the test's intent without churning on every field addition. Co-Authored-By: Claude Opus 4.7 (1M context) --- browse/test/sidebar-agent.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/browse/test/sidebar-agent.test.ts b/browse/test/sidebar-agent.test.ts index e28a9c00..065aa544 100644 --- a/browse/test/sidebar-agent.test.ts +++ b/browse/test/sidebar-agent.test.ts @@ -462,8 +462,11 @@ describe('per-tab agent concurrency', () => { test('sidebar-agent sends tabId with all events', () => { // sendEvent should accept tabId parameter expect(agentSrc).toContain('async function sendEvent(event: Record, tabId?: number)'); - // askClaude should extract tabId from queue entry - expect(agentSrc).toContain('const { prompt, args, stateFile, cwd, tabId }'); + // askClaude destructures tabId from queue entry (regex tolerates + // additional fields like `canary` and `pageUrl` from security module). + expect(agentSrc).toMatch( + /const \{[^}]*\bprompt\b[^}]*\bargs\b[^}]*\bstateFile\b[^}]*\bcwd\b[^}]*\btabId\b[^}]*\}/ + ); }); test('sidebar-agent allows concurrent agents across tabs', () => {