Files
waggle-os/apps/web/src/test/memory-features.test.tsx
shumeiko.it f3eb6b6652 feat(web): ask before sending analytics, drop team screens, hide v1-absent memory features (P1.3a)
- Analytics are opt-in (decision Q7, ADR-0006). PostHog does not start or
  capture anything until the user clicks Allow in a first-run dialog that
  says what is sent. Escape or closing stores nothing and asks again. The
  existing Privacy & Telemetry toggle in Settings withdraws consent at once.
  Builds without VITE_POSTHOG_KEY show no dialog and send nothing.
- Remove the remaining upsell copy: the /team page with its per-seat price,
  Stripe and Teams wording in the erase-data dialog, Teams/Enterprise hints.
- Remove team screens (decision Q3): Waggle Dance, team presence in chat,
  team storage and sharing in workspace creation, storage and files.
- Hide memory features that are not in v1 (decision Q2) behind one map in
  lib/memory-features.ts: the knowledge graph, import history, wiki, agent
  memory hooks and Room launches. The map is the seam P1.5 fills from the
  memory store's capabilities.
- Say Windows, macOS and Linux instead of "Linux soon".
- Update the e2e specs for the removed and hidden screens.

Also logs UF-029: the Settings "Import Data" button has no handler.
2026-10-23 14:51:29 +02:00

68 lines
2.4 KiB
TypeScript

/**
* ADR-0002: the v1 memory feature map and the onboarding import step it hides.
*/
import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, cleanup, waitFor } from '@testing-library/react';
import { hasMemoryFeature, isMemoryViewAvailable, type MemoryFeature } from '@/lib/memory-features';
const mocks = vi.hoisted(() => ({
adapter: {
connect: vi.fn(),
getProfile: vi.fn(),
trackTelemetry: vi.fn(),
scanClaudeCode: vi.fn(),
},
}));
vi.mock('@/lib/adapter', () => ({ adapter: mocks.adapter, default: vi.fn() }));
vi.mock('@/hooks/useOfflineStatus', () => ({ useOfflineStatus: () => false }));
vi.mock('@/lib/posthog', () => ({ captureOnboardingComplete: vi.fn() }));
afterEach(() => {
cleanup();
vi.clearAllMocks();
});
describe('memory feature map (v1 defaults)', () => {
it.each<MemoryFeature>(['knowledgeGraph', 'importHistory', 'wiki', 'agentHooks', 'room', 'memoryMcp'])(
'%s is hidden',
(feature) => {
expect(hasMemoryFeature(feature)).toBe(false);
},
);
it('keeps the v1 Memory Center views and hides Graph, Imports and Wiki', () => {
for (const view of ['trust', 'memories', 'timeline', 'weaver']) {
expect(isMemoryViewAvailable(view), view).toBe(true);
}
for (const view of ['graph', 'harvest', 'wiki']) {
expect(isMemoryViewAvailable(view), view).toBe(false);
}
});
});
describe('OnboardingWizard without history import', () => {
it('resumes a persisted import step on the template step and never scans Claude Code', async () => {
mocks.adapter.connect.mockResolvedValue(undefined);
mocks.adapter.getProfile.mockResolvedValue(null);
const { default: OnboardingWizard } = await import('@/components/os/overlays/OnboardingWizard');
render(
<OnboardingWizard
serverBaseUrl="http://127.0.0.1:3333"
state={{ completed: false, step: 3 }}
onUpdate={vi.fn()}
onComplete={vi.fn()}
onDismiss={vi.fn()}
onFinish={vi.fn()}
/>,
);
expect(await screen.findByRole('heading', { name: /pick a starting point/i })).toBeInTheDocument();
// who-are-you · model · template · first-task: the import step has no number.
expect(screen.getByText('Step 3 of 4')).toBeInTheDocument();
await waitFor(() => expect(mocks.adapter.getProfile).toHaveBeenCalled());
expect(mocks.adapter.scanClaudeCode).not.toHaveBeenCalled();
});
});