2026-04-12 17:08:07 +02:00
|
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
|
import { fireEvent, render, screen } from '@testing-library/react'
|
2026-02-22 13:42:20 +01:00
|
|
|
import { SettingsPanel } from './SettingsPanel'
|
|
|
|
|
import type { Settings } from '../types'
|
|
|
|
|
|
|
|
|
|
const emptySettings: Settings = {
|
feat: auto-pull vault changes from Git (background sync + conflict handling) (#79)
* feat: add auto-pull vault sync with conflict handling
- Add git_pull, has_remote, get_conflict_files to Rust backend
- Add GitPullResult type and auto_pull_interval_minutes to Settings
- Create useAutoSync hook (pull on launch, focus, periodic interval)
- Update StatusBar with real sync status indicator
- Add pull interval setting to SettingsPanel
- Add mock handler for git_pull
- Update existing tests for new Settings field
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add tests for git pull, settings, and useAutoSync hook
- Add Rust tests: has_remote, git_pull (no_remote, up_to_date, updated),
get_conflict_files, parse_updated_files, GitPullResult serialization
- Add frontend tests: useAutoSync (mount pull, focus pull, conflict,
error, manual trigger, concurrent prevention, no_remote)
- Fix existing settings tests for new auto_pull_interval_minutes field
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: add auto-pull-vault wireframes
Frames showing: sync idle, syncing, conflict indicator,
settings sync section, and conflict toast notification.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add auto_pull_interval_minutes to all Settings literals
Fix build error and test fixtures missing the new field.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: cargo fmt
* ci: re-trigger CI after flaky test
* ci: retrigger after disk space cleanup
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 01:55:16 +01:00
|
|
|
auto_pull_interval_minutes: null,
|
2026-03-25 16:05:13 +01:00
|
|
|
telemetry_consent: null,
|
|
|
|
|
crash_reporting_enabled: null,
|
|
|
|
|
analytics_enabled: null,
|
|
|
|
|
anonymous_id: null,
|
2026-04-04 12:11:26 +02:00
|
|
|
release_channel: null,
|
2026-02-22 13:42:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('SettingsPanel', () => {
|
|
|
|
|
const onSave = vi.fn()
|
|
|
|
|
const onClose = vi.fn()
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
vi.clearAllMocks()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('renders nothing when not open', () => {
|
|
|
|
|
const { container } = render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={false} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
expect(container.innerHTML).toBe('')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('renders modal when open', () => {
|
|
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
expect(screen.getByText('Settings')).toBeInTheDocument()
|
2026-04-12 17:08:07 +02:00
|
|
|
expect(screen.getByText('Sync')).toBeInTheDocument()
|
2026-02-22 13:42:20 +01:00
|
|
|
})
|
|
|
|
|
|
2026-04-05 01:34:30 +02:00
|
|
|
it('does not show AI Provider Keys section', () => {
|
2026-02-22 13:42:20 +01:00
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
2026-04-05 01:34:30 +02:00
|
|
|
expect(screen.queryByText('AI Provider Keys')).not.toBeInTheDocument()
|
|
|
|
|
expect(screen.queryByText('OpenAI')).not.toBeInTheDocument()
|
|
|
|
|
expect(screen.queryByText('Google AI')).not.toBeInTheDocument()
|
2026-02-22 13:42:20 +01:00
|
|
|
})
|
|
|
|
|
|
2026-04-05 01:34:30 +02:00
|
|
|
it('calls onSave with settings on save', () => {
|
2026-02-22 13:42:20 +01:00
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fireEvent.click(screen.getByTestId('settings-save'))
|
|
|
|
|
|
2026-03-25 16:05:13 +01:00
|
|
|
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({
|
feat: auto-pull vault changes from Git (background sync + conflict handling) (#79)
* feat: add auto-pull vault sync with conflict handling
- Add git_pull, has_remote, get_conflict_files to Rust backend
- Add GitPullResult type and auto_pull_interval_minutes to Settings
- Create useAutoSync hook (pull on launch, focus, periodic interval)
- Update StatusBar with real sync status indicator
- Add pull interval setting to SettingsPanel
- Add mock handler for git_pull
- Update existing tests for new Settings field
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add tests for git pull, settings, and useAutoSync hook
- Add Rust tests: has_remote, git_pull (no_remote, up_to_date, updated),
get_conflict_files, parse_updated_files, GitPullResult serialization
- Add frontend tests: useAutoSync (mount pull, focus pull, conflict,
error, manual trigger, concurrent prevention, no_remote)
- Fix existing settings tests for new auto_pull_interval_minutes field
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: add auto-pull-vault wireframes
Frames showing: sync idle, syncing, conflict indicator,
settings sync section, and conflict toast notification.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add auto_pull_interval_minutes to all Settings literals
Fix build error and test fixtures missing the new field.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: cargo fmt
* ci: re-trigger CI after flaky test
* ci: retrigger after disk space cleanup
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 01:55:16 +01:00
|
|
|
auto_pull_interval_minutes: 5,
|
2026-03-25 16:05:13 +01:00
|
|
|
}))
|
2026-02-22 13:42:20 +01:00
|
|
|
expect(onClose).toHaveBeenCalled()
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-10 13:52:39 +02:00
|
|
|
it('defaults the organization workflow switch to on', () => {
|
|
|
|
|
render(
|
|
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
|
|
|
|
)
|
|
|
|
|
expect(screen.getByRole('switch', { name: 'Organize notes explicitly' })).toHaveAttribute('aria-checked', 'true')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('saves the organization workflow preference when toggled off', () => {
|
|
|
|
|
const onSaveExplicitOrganization = vi.fn()
|
|
|
|
|
render(
|
|
|
|
|
<SettingsPanel
|
|
|
|
|
open={true}
|
|
|
|
|
settings={emptySettings}
|
|
|
|
|
onSave={onSave}
|
|
|
|
|
explicitOrganizationEnabled={true}
|
|
|
|
|
onSaveExplicitOrganization={onSaveExplicitOrganization}
|
|
|
|
|
onClose={onClose}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fireEvent.click(screen.getByRole('switch', { name: 'Organize notes explicitly' }))
|
|
|
|
|
fireEvent.click(screen.getByTestId('settings-save'))
|
|
|
|
|
|
|
|
|
|
expect(onSaveExplicitOrganization).toHaveBeenCalledWith(false)
|
|
|
|
|
})
|
|
|
|
|
|
2026-02-22 13:42:20 +01:00
|
|
|
it('calls onClose when Cancel is clicked', () => {
|
|
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
fireEvent.click(screen.getByText('Cancel'))
|
|
|
|
|
expect(onClose).toHaveBeenCalled()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('calls onClose when close button is clicked', () => {
|
|
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
fireEvent.click(screen.getByTitle('Close settings'))
|
|
|
|
|
expect(onClose).toHaveBeenCalled()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('calls onClose on Escape key', () => {
|
|
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
fireEvent.keyDown(screen.getByTestId('settings-panel'), { key: 'Escape' })
|
|
|
|
|
expect(onClose).toHaveBeenCalled()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('saves on Cmd+Enter', () => {
|
|
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
fireEvent.keyDown(screen.getByTestId('settings-panel'), { key: 'Enter', metaKey: true })
|
|
|
|
|
|
2026-03-25 16:05:13 +01:00
|
|
|
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({
|
feat: auto-pull vault changes from Git (background sync + conflict handling) (#79)
* feat: add auto-pull vault sync with conflict handling
- Add git_pull, has_remote, get_conflict_files to Rust backend
- Add GitPullResult type and auto_pull_interval_minutes to Settings
- Create useAutoSync hook (pull on launch, focus, periodic interval)
- Update StatusBar with real sync status indicator
- Add pull interval setting to SettingsPanel
- Add mock handler for git_pull
- Update existing tests for new Settings field
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add tests for git pull, settings, and useAutoSync hook
- Add Rust tests: has_remote, git_pull (no_remote, up_to_date, updated),
get_conflict_files, parse_updated_files, GitPullResult serialization
- Add frontend tests: useAutoSync (mount pull, focus pull, conflict,
error, manual trigger, concurrent prevention, no_remote)
- Fix existing settings tests for new auto_pull_interval_minutes field
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* design: add auto-pull-vault wireframes
Frames showing: sync idle, syncing, conflict indicator,
settings sync section, and conflict toast notification.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add auto_pull_interval_minutes to all Settings literals
Fix build error and test fixtures missing the new field.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: cargo fmt
* ci: re-trigger CI after flaky test
* ci: retrigger after disk space cleanup
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 01:55:16 +01:00
|
|
|
auto_pull_interval_minutes: 5,
|
2026-03-25 16:05:13 +01:00
|
|
|
}))
|
2026-02-22 13:42:20 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('calls onClose when clicking backdrop', () => {
|
|
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
fireEvent.click(screen.getByTestId('settings-panel'))
|
|
|
|
|
expect(onClose).toHaveBeenCalled()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('shows keyboard shortcut hint in footer', () => {
|
|
|
|
|
render(
|
refactor: remove theming system entirely
Remove all theme switching, creation, and management functionality
from the app — backend (Rust theme module, Tauri commands, menu items,
startup tasks, vault seeding), frontend (useThemeManager, ThemePropertyEditor,
themeSchema, command palette Appearance group, settings panel appearance
section, isDarkTheme prop chain), mock data, and all related tests.
Editor styling via theme.json/EditorTheme.css is preserved (not user theming).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:57:58 +01:00
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
2026-02-22 13:42:20 +01:00
|
|
|
)
|
|
|
|
|
expect(screen.getByText(/to open settings/)).toBeInTheDocument()
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-12 17:08:07 +02:00
|
|
|
it('does not show the removed GitHub auth section', () => {
|
|
|
|
|
render(
|
|
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
|
|
|
|
)
|
|
|
|
|
expect(screen.queryByText('GitHub')).not.toBeInTheDocument()
|
|
|
|
|
expect(screen.queryByText(/Connect your GitHub account/i)).not.toBeInTheDocument()
|
2026-02-23 19:57:59 +01:00
|
|
|
})
|
2026-03-25 16:10:39 +01:00
|
|
|
|
|
|
|
|
describe('Privacy & Telemetry section', () => {
|
|
|
|
|
it('renders crash reporting and analytics toggles', () => {
|
|
|
|
|
render(
|
|
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
|
|
|
|
)
|
|
|
|
|
expect(screen.getByTestId('settings-crash-reporting')).toBeInTheDocument()
|
|
|
|
|
expect(screen.getByTestId('settings-analytics')).toBeInTheDocument()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('toggles reflect initial settings state', () => {
|
|
|
|
|
const withTelemetry: Settings = {
|
|
|
|
|
...emptySettings,
|
|
|
|
|
telemetry_consent: true,
|
|
|
|
|
crash_reporting_enabled: true,
|
|
|
|
|
analytics_enabled: false,
|
|
|
|
|
anonymous_id: 'test-uuid',
|
|
|
|
|
}
|
|
|
|
|
render(
|
|
|
|
|
<SettingsPanel open={true} settings={withTelemetry} onSave={onSave} onClose={onClose} />
|
|
|
|
|
)
|
|
|
|
|
const crashCheckbox = screen.getByTestId('settings-crash-reporting').querySelector('input') as HTMLInputElement
|
|
|
|
|
const analyticsCheckbox = screen.getByTestId('settings-analytics').querySelector('input') as HTMLInputElement
|
|
|
|
|
expect(crashCheckbox.checked).toBe(true)
|
|
|
|
|
expect(analyticsCheckbox.checked).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('saves telemetry settings when toggled and saved', () => {
|
|
|
|
|
render(
|
|
|
|
|
<SettingsPanel open={true} settings={emptySettings} onSave={onSave} onClose={onClose} />
|
|
|
|
|
)
|
|
|
|
|
const crashCheckbox = screen.getByTestId('settings-crash-reporting').querySelector('input')!
|
|
|
|
|
fireEvent.click(crashCheckbox)
|
|
|
|
|
fireEvent.click(screen.getByTestId('settings-save'))
|
|
|
|
|
|
|
|
|
|
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({
|
|
|
|
|
crash_reporting_enabled: true,
|
|
|
|
|
analytics_enabled: false,
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
})
|
2026-02-22 13:42:20 +01:00
|
|
|
})
|