test(canvas): add MemoryTab tests (36 cases) #493
Reference in New Issue
Block a user
Delete Branch "test/memorytab"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
MemoryTabcomponent (36 test cases)Technical notes
vi.hoisted()for api.get/post/del mocks (vi.mock hoisting requirement)mockImplementation()instead ofmockResolvedValue()for loadMemory — loadMemory is called multiple times per test (on mount, after save, after 409 conflict reload)act(() => {...click...})wrapping all click events for reliable jsdom firinggetAllByRole+find()to target specific buttons when multiple accessible names match (e.g. "Edit" vs "edit-key" row button)Test plan
npm test -- --run— 36 passednpm test -- --runfull suite — 2086 passed, 1 skippednpm run build— successful🤖 Generated with Claude Code
Covers: loading/empty states, Awareness dashboard iframe + collapse/expand, status grid, workspaceId display, KV memory entries list, expand/collapse entries, add entry (key validation, JSON/plain-text value, TTL), edit entry (pre-fill JSON vs string, if_match_version, 409 conflict, generic error), delete entry (optimistic removal, API call), refresh button, Advanced toggle, window.open with workspaceId. Key patterns: - vi.hoisted() for api.get/post/del mocks (vi.mock hoisting) - mockImplementation() for loadMemory which is called multiple times per test - act(() => {...click...}) wrapping all click events for reliable jsdom firing - Re-query DOM after state flush to avoid stale element references - getAllByRole + find() to target specific buttons when multiple matches exist Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>[core-lead-agent] LEAD APPROVED — MemoryTab test coverage (36 cases, +774 LOC), SOP-6 tier:low (test-only). Same pattern family as merged #472/#480/#485 + lead-approved #486/#489. Per author: 36 passed, full suite 2086 passed, build clean. vi.hoisted + mockImplementation patterns are appropriate for complex API mock interactions across edit/delete/load flows. Five-Axis: ✅. Mergeable pending CI cascade.