From 28d3bd7da876903908df3ed5e87e2d47e29b2b8d Mon Sep 17 00:00:00 2001 From: timkjr Date: Tue, 15 Sep 2026 21:49:53 -0500 Subject: [PATCH] docs(plan): fix Task 2/4/5/6 tests against real test infrastructure Preflight scan for SDD execution caught two classes of defect before dispatch: Task 2's test invented a buildTestApp() helper and response envelope that don't exist for /api/settings; Tasks 4-6 used @playwright/test's runner against a test/browser/ directory that doesn't exist in this codebase. Both corrected against real patterns found in existing tests (system-routes-settings-partial-put.test.ts, terminal-copy-shortcut.test.ts, tab-rail-resize.browser.test.ts). Co-Authored-By: Claude Sonnet 5 --- .../plans/2026-09-15-split-pane-sessions.md | 462 +++++++++++------- 1 file changed, 295 insertions(+), 167 deletions(-) diff --git a/docs/superpowers/plans/2026-09-15-split-pane-sessions.md b/docs/superpowers/plans/2026-09-15-split-pane-sessions.md index 81ffd67b..ad1e5c11 100644 --- a/docs/superpowers/plans/2026-09-15-split-pane-sessions.md +++ b/docs/superpowers/plans/2026-09-15-split-pane-sessions.md @@ -182,24 +182,64 @@ git commit -m "feat(split-pane): add pure divider-clamp and picker-list helpers" - [ ] **Step 1: Write the failing test** +This mirrors the existing `test/routes/system-routes-settings-partial-put.test.ts` pattern exactly — there is no `buildTestApp()` helper in this codebase; route tests go through `createRouteTestHarness(registerFn)` from `test/routes/_route-test-utils.ts`, and `GET`/`PUT /api/settings` are NOT wrapped in the `{success,data}` envelope (see `src/web/routes/system-routes.ts:938`, `app.get('/api/settings', ...)` returns the raw settings object directly — read its own comment there for why). `registerSystemRoutes` also drives three watcher singletons on every PUT, so they must be mocked or the route throws. + ```typescript // test/routes/system-routes-split-button-setting.test.ts -import { describe, it, expect } from 'vitest'; -import { buildTestApp } from './_route-test-utils'; +import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; +import { createRouteTestHarness, type RouteTestHarness } from './_route-test-utils.js'; +import { registerSystemRoutes } from '../../src/web/routes/system-routes.js'; + +const { subagentWatcher, imageWatcher, workflowRunWatcher } = vi.hoisted(() => { + const makeWatcher = () => ({ + isRunning: vi.fn(() => false), + start: vi.fn(), + stop: vi.fn(), + getStats: vi.fn(() => ({})), + watchSession: vi.fn(), + getRecentRunSummaries: vi.fn(() => []), + }); + return { subagentWatcher: makeWatcher(), imageWatcher: makeWatcher(), workflowRunWatcher: makeWatcher() }; +}); + +vi.mock('node:fs/promises', () => ({ + default: { + readFile: vi.fn(async () => JSON.stringify({})), + writeFile: vi.fn(async () => undefined), + }, +})); + +vi.mock('node:fs', async (importOriginal) => { + const actual = await importOriginal(); + return { ...actual, existsSync: vi.fn(() => true), mkdirSync: vi.fn(), readdirSync: vi.fn(() => []) }; +}); + +vi.mock('../../src/subagent-watcher.js', () => ({ subagentWatcher })); +vi.mock('../../src/image-watcher.js', () => ({ imageWatcher })); +vi.mock('../../src/workflow-run-watcher.js', () => ({ workflowRunWatcher })); describe('showSplitButton setting', () => { + let harness: RouteTestHarness; + + beforeEach(async () => { + harness = await createRouteTestHarness(registerSystemRoutes); + }); + + afterEach(async () => { + await harness.app.close(); + }); + it('round-trips through PUT and GET /api/settings', async () => { - const app = await buildTestApp(); - const putRes = await app.inject({ + const putRes = await harness.app.inject({ method: 'PUT', url: '/api/settings', payload: { showSplitButton: true }, }); expect(putRes.statusCode).toBe(200); - const getRes = await app.inject({ method: 'GET', url: '/api/settings' }); + const getRes = await harness.app.inject({ method: 'GET', url: '/api/settings' }); const body = JSON.parse(getRes.body); - expect(body.data.showSplitButton).toBe(true); + expect(body.showSplitButton).toBe(true); }); }); ``` @@ -366,69 +406,112 @@ git commit -m "feat(split-pane): add split container/divider/pane-b CSS" - Create: `src/web/public/terminal-split.js` - Modify: `src/web/public/index.html` (add the `