mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-02 03:35:09 +02:00
test(sidebar-agent): regex-tolerant destructure check
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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<string, any>, 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', () => {
|
||||
|
||||
Reference in New Issue
Block a user