diff options
| author | Adam Malczewski <[email protected]> | 2026-05-27 19:20:50 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-27 19:20:50 +0900 |
| commit | 1e3f67ea0223fb77bfc8e2a0add7ba16e5fa1f1a (patch) | |
| tree | 9100999ef2d764e0bbc298addca35195f6330954 /packages/frontend/src/lib | |
| parent | faeb8fe6a2983cd9fc9ecb9167e16d625ccd56d0 (diff) | |
| download | dispatch-1e3f67ea0223fb77bfc8e2a0add7ba16e5fa1f1a.tar.gz dispatch-1e3f67ea0223fb77bfc8e2a0add7ba16e5fa1f1a.zip | |
test(frontend): drive tabStore through real $state via exported createTabStore + handleEvent (replaces POJO harness)
Diffstat (limited to 'packages/frontend/src/lib')
| -rw-r--r-- | packages/frontend/src/lib/tabs.svelte.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/frontend/src/lib/tabs.svelte.ts b/packages/frontend/src/lib/tabs.svelte.ts index 7850218..b07d37a 100644 --- a/packages/frontend/src/lib/tabs.svelte.ts +++ b/packages/frontend/src/lib/tabs.svelte.ts @@ -68,7 +68,17 @@ export interface Tab { queuedMessages: QueuedMessage[]; } -function createTabStore() { +/** + * Build a fresh tab store. Exported so tests can construct a real + * `$state`-backed instance per test — the production singleton is + * exported below as `tabStore`. The previous test harness duplicated + * the store logic against POJO arrays, which made the + * `structuredClone(svelteProxy)` bug undetectable: native `structuredClone` + * works on plain arrays and throws on Svelte reactive proxies. See the + * `chat-store.test.ts` rewrite for the proper integration tests that + * drive the actual reactive code path. + */ +export function createTabStore() { let tabs: Tab[] = $state([]); let activeTabId: string | null = $state(null); let pendingPermissions: PermissionPrompt[] = $state([]); @@ -1288,6 +1298,10 @@ function createTabStore() { promoteTab, openAgentTab, setWorkingDirectory, + // Exposed so tests can drive the real reactive code path that the + // WS callback uses in production. Not intended for use in + // components — they should rely on the WS subscription instead. + handleEvent, }; } |
