test(7.1): add tests for untested settings pages

- SettingsGroups: page render, create/edit buttons, group list
- SettingsCurrencies: page render, form, API calls, error display
- SettingsTaxes: page render, form, API calls, error display
- SettingsSequences: page render, form, API calls, error display
- SettingsNotifications: page render, notification types, toggles
- SettingsPlugins: page render, install/activate/deactivate buttons
- SettingsSystem: page render, form fields, save button

All 82 settings tests passing.
This commit is contained in:
Agent Zero
2026-07-24 00:49:22 +02:00
parent efc49c7769
commit 62127c6544
7 changed files with 566 additions and 0 deletions
@@ -0,0 +1,54 @@
import React from 'react';
import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { SettingsNotificationsPage } from '@/pages/SettingsNotifications';
const mockNotificationTypes = {
items: [
{ type_key: 'mail.new', plugin_name: 'mail', category: 'mail', label: 'Neue E-Mail', description: 'Bei neuen E-Mails', is_enabled_by_default: true, is_enabled: true },
{ type_key: 'task.overdue', plugin_name: 'tasks', category: 'tasks', label: 'Überfällige Aufgabe', description: 'Aufgabe ist überfällig', is_enabled_by_default: false, is_enabled: false },
],
};
vi.mock('@/api/hooks', () => ({
useNotificationTypes: () => ({ data: mockNotificationTypes, isLoading: false, error: null }),
useUpdateNotificationPreference: () => ({
mutate: vi.fn(),
isPending: false,
}),
}));
vi.mock('@/components/ui/Toast', () => ({
useToast: () => ({ success: vi.fn(), error: vi.fn(), info: vi.fn() }),
}));
describe('SettingsNotificationsPage', () => {
it('renders notifications page', () => {
render(<SettingsNotificationsPage />);
expect(screen.getByTestId('settings-notifications-page')).toBeInTheDocument();
});
it('renders notification type labels', () => {
render(<SettingsNotificationsPage />);
expect(screen.getByText('Neue E-Mail')).toBeInTheDocument();
expect(screen.getByText('Überfällige Aufgabe')).toBeInTheDocument();
});
it('renders notification descriptions', () => {
render(<SettingsNotificationsPage />);
expect(screen.getByText('Bei neuen E-Mails')).toBeInTheDocument();
expect(screen.getByText('Aufgabe ist überfällig')).toBeInTheDocument();
});
it('renders plugin group headers', () => {
render(<SettingsNotificationsPage />);
expect(screen.getByText('mail')).toBeInTheDocument();
expect(screen.getByText('tasks')).toBeInTheDocument();
});
it('renders toggle switches for each notification type', () => {
render(<SettingsNotificationsPage />);
const switches = screen.getAllByRole('switch');
expect(switches.length).toBeGreaterThanOrEqual(2);
});
});