feat: add telemetry consent dialog + Settings privacy toggles

First-launch consent dialog asks users to opt-in to anonymous crash
reporting. Settings panel gains Privacy & Telemetry section with
toggles for crash reporting and usage analytics. Consent gate blocks
app shell until answered. UUID generated on accept for anonymous_id.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-03-25 16:10:39 +01:00
parent d7166ea993
commit 2fd5ce2e94
5 changed files with 191 additions and 6 deletions

View File

@@ -0,0 +1,30 @@
import { describe, it, expect, vi } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { TelemetryConsentDialog } from './TelemetryConsentDialog'
describe('TelemetryConsentDialog', () => {
it('renders the consent dialog', () => {
render(<TelemetryConsentDialog onAccept={vi.fn()} onDecline={vi.fn()} />)
expect(screen.getByText('Help improve Laputa')).toBeDefined()
expect(screen.getByText(/anonymous crash reports/i)).toBeDefined()
})
it('calls onAccept when Allow button is clicked', () => {
const onAccept = vi.fn()
render(<TelemetryConsentDialog onAccept={onAccept} onDecline={vi.fn()} />)
fireEvent.click(screen.getByTestId('telemetry-accept'))
expect(onAccept).toHaveBeenCalledOnce()
})
it('calls onDecline when No thanks button is clicked', () => {
const onDecline = vi.fn()
render(<TelemetryConsentDialog onAccept={vi.fn()} onDecline={onDecline} />)
fireEvent.click(screen.getByTestId('telemetry-decline'))
expect(onDecline).toHaveBeenCalledOnce()
})
it('shows a details section explaining what data is shared', () => {
render(<TelemetryConsentDialog onAccept={vi.fn()} onDecline={vi.fn()} />)
expect(screen.getByText(/no vault content, note titles/i)).toBeDefined()
})
})