Adjust branding defaults and tenant presets

This commit is contained in:
Codex Agent
2026-01-30 18:15:52 +01:00
parent b3bf45482a
commit 6e19c3d7b6
9 changed files with 592 additions and 220 deletions

View File

@@ -10,9 +10,11 @@ vi.mock('react-router-dom', () => ({
useParams: () => ({ slug: 'demo-event' }),
}));
const tMock = (key: string, fallback?: string) => fallback ?? key;
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string) => fallback ?? key,
t: tMock,
}),
initReactI18next: {
type: '3rdParty',
@@ -152,35 +154,18 @@ describe('MobileBrandingPage', () => {
getTenantSettingsMock.mockResolvedValue({ settings: {} });
});
it('hides custom branding controls when default branding is active', async () => {
it('shows branding controls when the event loads', async () => {
getEventMock.mockResolvedValueOnce({
...baseEvent,
settings: { branding: { use_default_branding: true } },
settings: { branding: {} },
});
render(<MobileBrandingPage />);
await waitFor(() => {
expect(screen.getByText('Branding Source')).toBeInTheDocument();
expect(screen.getByText('Theme')).toBeInTheDocument();
});
expect(screen.queryByText('Theme')).toBeNull();
expect(screen.queryByText('Colors')).toBeNull();
});
it('shows custom branding controls when event branding is active', async () => {
getEventMock.mockResolvedValueOnce({
...baseEvent,
settings: { branding: { use_default_branding: false } },
});
render(<MobileBrandingPage />);
await waitFor(() => {
expect(screen.getByText('Branding Source')).toBeInTheDocument();
});
expect(screen.getByText('Theme')).toBeInTheDocument();
expect(screen.getByText('Colors')).toBeInTheDocument();
});
@@ -210,7 +195,7 @@ describe('MobileBrandingPage', () => {
render(<MobileBrandingPage />);
await waitFor(() => {
expect(screen.getByText('Branding Source')).toBeInTheDocument();
expect(screen.getByText('Theme')).toBeInTheDocument();
});
fireEvent.click(screen.getByText('Wasserzeichen'));

View File

@@ -11,6 +11,9 @@ vi.mock('../hooks/useBackNavigation', () => ({
vi.mock('../../api', () => ({
fetchTenantProfile: vi.fn(),
updateTenantProfile: vi.fn(),
getTenantPackagesOverview: vi.fn(),
getTenantSettings: vi.fn(),
updateTenantSettings: vi.fn(),
}));
vi.mock('react-hot-toast', () => ({
@@ -47,6 +50,7 @@ vi.mock('../components/FormControls', () => ({
MobileInput: ({ hasError, compact, ...props }: React.InputHTMLAttributes<HTMLInputElement> & { hasError?: boolean; compact?: boolean }) => (
<input {...props} />
),
MobileColorInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileSelect: ({ children, ...props }: { children: React.ReactNode }) => <select {...props}>{children}</select>,
}));
@@ -59,6 +63,14 @@ vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, ...props }: { children: React.ReactNode } & React.ButtonHTMLAttributes<HTMLButtonElement>) => (
<button type="button" {...props}>
{children}
</button>
),
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
text: '#111827',
@@ -77,7 +89,7 @@ vi.mock('../theme', () => ({
}),
}));
import { fetchTenantProfile, updateTenantProfile } from '../../api';
import { fetchTenantProfile, updateTenantProfile, getTenantPackagesOverview, getTenantSettings } from '../../api';
import MobileProfileAccountPage from '../ProfileAccountPage';
const profileFixture = {
@@ -90,6 +102,14 @@ const profileFixture = {
};
describe('MobileProfileAccountPage', () => {
beforeEach(() => {
vi.mocked(getTenantPackagesOverview).mockResolvedValue({
packages: [],
activePackage: { branding_allowed: false },
});
vi.mocked(getTenantSettings).mockResolvedValue({ id: 1, settings: {}, updated_at: null });
});
it('submits account updates with name, email, and locale', async () => {
vi.mocked(fetchTenantProfile).mockResolvedValue(profileFixture);
vi.mocked(updateTenantProfile).mockResolvedValue(profileFixture);