diff --git a/tests/e2e/competitive-benchmarks.spec.ts b/tests/e2e/competitive-benchmarks.spec.ts index bf4a930..bb5639d 100644 --- a/tests/e2e/competitive-benchmarks.spec.ts +++ b/tests/e2e/competitive-benchmarks.spec.ts @@ -76,6 +76,13 @@ async function saveMemory(request: APIRequestContext, content: string, workspace }); } +/** Creates a real workspace; memory writes for a workspace that does not exist are refused (UF-039). */ +async function createWorkspace(request: APIRequestContext, name: string): Promise { + const res = await request.post(`${API}/api/workspaces`, { data: { name, group: 'E2E' } }); + expect(res.ok()).toBe(true); + return (await res.json()).id as string; +} + async function searchMemory(request: APIRequestContext, query: string, workspace: string, limit = 5) { return request.get(`${API}/api/memory/search?q=${encodeURIComponent(query)}&workspace=${encodeURIComponent(workspace)}&limit=${limit}`); } @@ -227,8 +234,8 @@ test.describe('B2 — Memory Persistence (vs ChatGPT / Claude Code / Hermes)', ( }); test('B2.4 — Memory isolation: 100% workspace separation (Hermes has no isolation)', async ({ request }) => { - const wsA = `isolation-bench-a-${Date.now()}`; - const wsB = `isolation-bench-b-${Date.now()}`; + const wsA = await createWorkspace(request, `isolation-bench-a-${Date.now()}`); + const wsB = await createWorkspace(request, `isolation-bench-b-${Date.now()}`); const secretData = `BENCH-SECRET-${Math.random().toString(36).slice(2)}`; await saveMemory(request, `Confidential: ${secretData}`, wsA); diff --git a/tests/e2e/user-behavior.spec.ts b/tests/e2e/user-behavior.spec.ts index e109875..f5b8b15 100644 --- a/tests/e2e/user-behavior.spec.ts +++ b/tests/e2e/user-behavior.spec.ts @@ -60,6 +60,13 @@ async function simulateMemorySave(request: APIRequestContext, content: string, w }); } +/** Creates a real workspace; memory writes for a workspace that does not exist are refused (UF-039). */ +async function createWorkspace(request: APIRequestContext, name: string): Promise { + const res = await request.post(`${API}/api/workspaces`, { data: { name, group: 'E2E' } }); + expect(res.ok()).toBe(true); + return (await res.json()).id as string; +} + async function searchMemory(request: APIRequestContext, query: string, workspace: string, limit = 5) { return request.get(`${API}/api/memory/search?q=${encodeURIComponent(query)}&workspace=${encodeURIComponent(workspace)}&limit=${limit}`); } @@ -196,7 +203,7 @@ test.describe('Act 2 — The Memory Hook: "It Remembers Me"', () => { }); test('U2.3 — Multiple memories stack (no overwrite on second save)', async ({ request }) => { - const workspace = `stacking-${Date.now()}`; + const workspace = await createWorkspace(request, `stacking-${Date.now()}`); await simulateMemorySave(request, 'I like dark mode interfaces', workspace); await simulateMemorySave(request, 'My team uses Slack for communication', workspace); @@ -214,8 +221,8 @@ test.describe('Act 2 — The Memory Hook: "It Remembers Me"', () => { }); test('U2.4 — Cross-workspace isolation (no memory leakage between users)', async ({ request }) => { - const ws1 = `user-alice-${Date.now()}`; - const ws2 = `user-bob-${Date.now()}`; + const ws1 = await createWorkspace(request, `user-alice-${Date.now()}`); + const ws2 = await createWorkspace(request, `user-bob-${Date.now()}`); await simulateMemorySave(request, 'Alice secret: my API key is sk-alice-private-data', ws1); @@ -820,8 +827,8 @@ test.describe('Act 9 — Workspace Identity & Ownership', () => { }); test('U9.3 — Workspace memory is isolated per workspace ID', async ({ request }) => { - const ws1 = `isolation-a-${Date.now()}`; - const ws2 = `isolation-b-${Date.now()}`; + const ws1 = await createWorkspace(request, `isolation-a-${Date.now()}`); + const ws2 = await createWorkspace(request, `isolation-b-${Date.now()}`); // Save in ws1 const saveRes = await simulateMemorySave(request, 'This is workspace A exclusive data', ws1); @@ -833,10 +840,9 @@ test.describe('Act 9 — Workspace Identity & Ownership', () => { if (res.ok()) { const data = await res.json(); const results = data.results ?? data.recalled ?? []; - // Personal mind frames may appear in any workspace search (current design). - // What matters: workspace-mind frames from ws1 must NOT appear in ws2 results. + // Personal memories may appear in any workspace search (by design); ws1's + // workspace memory must never appear in ws2's results. const wsLeaked = results.some((r: RecallResultShape) => - r.source_mind === 'workspace' && r.mind === 'workspace' && JSON.stringify(r).toLowerCase().includes('workspace a exclusive') ); expect(wsLeaked, 'Workspace-mind data leaked across workspaces').toBe(false); diff --git a/tests/e2e/user-journeys.spec.ts b/tests/e2e/user-journeys.spec.ts index 2f7a278..1c97d17 100644 --- a/tests/e2e/user-journeys.spec.ts +++ b/tests/e2e/user-journeys.spec.ts @@ -235,8 +235,7 @@ test.describe('User Journey Tests', () => { test('J3f: memory destructive trust actions use in-app confirmations', async ({ page }) => { const nativeDialogs: string[] = []; let deleteCalled = false; - let eraseCalled = false; - let allowCalled = false; + let eraseBody: unknown = null; const memory = { id: 'memory-research-note', kind: 'fact', @@ -247,21 +246,16 @@ test.describe('User Journey Tests', () => { source: 'user_stated', sourceId: null, sourceUrl: null, + // Saved from a chat, so the Memory Center offers to erase that chat's memories. + sessionId: 'chat-research-1', importance: 'normal', status: 'active', - confidence: 91, tags: ['research'], evidence: [], hasOriginalSource: false, createdAt: '2026-07-08T08:00:00.000Z', updatedAt: '2026-07-08T09:00:00.000Z', }; - const suppression = { - source: 'chatgpt', - sourceRef: 'research-export.json', - erasedAt: '2026-07-08T09:30:00.000Z', - reason: 'GDPR Art.17 erasure', - }; await page.route('**/api/memory**', route => { const request = route.request(); @@ -278,36 +272,11 @@ test.describe('User Journey Tests', () => { return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true }) }); } if (url.pathname === '/api/memory/erase' && request.method() === 'POST') { - eraseCalled = true; + eraseBody = request.postDataJSON(); return route.fulfill({ status: 200, contentType: 'application/json', - body: JSON.stringify({ - erased: true, - mind: 'personal', - result: { - framesDeleted: 1, - archiveRedacted: 1, - chunkVectorsPurged: 0, - entitiesErased: 1, - relationsErased: 0, - }, - }), - }); - } - if (url.pathname === '/api/memory/suppression' && request.method() === 'GET') { - return route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify({ mind: 'personal', suppressed: [suppression] }), - }); - } - if (url.pathname === '/api/memory/suppression/allow' && request.method() === 'POST') { - allowCalled = true; - return route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify({ removed: true, mind: 'personal' }), + body: JSON.stringify({ erased: true, deleted: 2 }), }); } return route.continue(); @@ -331,22 +300,13 @@ test.describe('User Journey Tests', () => { await expect.poll(() => deleteCalled).toBe(true); await memoryCard.click(); - await page.getByRole('button', { name: /^erase$/i }).click(); + await page.getByRole('button', { name: /^erase chat memories$/i }).click(); expect(nativeDialogs).toEqual([]); - await expect(page.getByTestId('approval-modal')).toContainText(/erase memory and derived data/i); + await expect(page.getByTestId('approval-modal')).toContainText(/erase everything remembered from this chat/i); await expect(page.getByTestId('approval-modal')).toContainText(/cannot be undone/i); await page.getByTestId('approval-modal-approve').click(); - await expect.poll(() => eraseCalled).toBe(true); - await expect(page.getByText(/erased "research note"/i)).toBeVisible({ timeout: 5_000 }); - - await page.getByRole('button', { name: /erased sources/i }).click(); - await expect(page.getByText('research-export.json')).toBeVisible({ timeout: 5_000 }); - await page.getByRole('button', { name: /allow re-import/i }).click(); - expect(nativeDialogs).toEqual([]); - await expect(page.getByTestId('approval-modal')).toContainText(/allow source to be re-imported/i); - await expect(page.getByTestId('approval-modal')).toContainText(/re-consented/i); - await page.getByTestId('approval-modal-approve').click(); - await expect.poll(() => allowCalled).toBe(true); + await expect.poll(() => eraseBody).toMatchObject({ sessionId: 'chat-research-1' }); + await expect(page.getByText(/erased 2 memories from that chat/i)).toBeVisible({ timeout: 5_000 }); }); // The wiki is hidden in v1 by the memory feature map (ADR-0002,