Collapse branding controls on default mode
This commit is contained in:
@@ -640,6 +640,8 @@ export default function MobileBrandingPage() {
|
|||||||
</Text>
|
</Text>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
|
|
||||||
|
{form.useDefaultBranding ? null : (
|
||||||
|
<>
|
||||||
<MobileCard space="$3">
|
<MobileCard space="$3">
|
||||||
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
<Text fontSize="$md" fontWeight="800" color={textStrong}>
|
||||||
{t('events.branding.mode', 'Theme')}
|
{t('events.branding.mode', 'Theme')}
|
||||||
@@ -975,6 +977,8 @@ export default function MobileBrandingPage() {
|
|||||||
/>
|
/>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
</>
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
renderWatermarkTab()
|
renderWatermarkTab()
|
||||||
)}
|
)}
|
||||||
|
|||||||
166
resources/js/admin/mobile/__tests__/BrandingPage.test.tsx
Normal file
166
resources/js/admin/mobile/__tests__/BrandingPage.test.tsx
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||||
|
import { render, screen, waitFor } from '@testing-library/react';
|
||||||
|
|
||||||
|
const navigateMock = vi.fn();
|
||||||
|
const backMock = vi.fn();
|
||||||
|
|
||||||
|
vi.mock('react-router-dom', () => ({
|
||||||
|
useNavigate: () => navigateMock,
|
||||||
|
useParams: () => ({ slug: 'demo-event' }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('react-i18next', () => ({
|
||||||
|
useTranslation: () => ({
|
||||||
|
t: (key: string, fallback?: string) => fallback ?? key,
|
||||||
|
}),
|
||||||
|
initReactI18next: {
|
||||||
|
type: '3rdParty',
|
||||||
|
init: () => undefined,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('react-hot-toast', () => ({
|
||||||
|
default: {
|
||||||
|
error: vi.fn(),
|
||||||
|
success: vi.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../components/MobileShell', () => ({
|
||||||
|
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
HeaderActionButton: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../components/Primitives', () => ({
|
||||||
|
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
|
||||||
|
SkeletonCard: () => <div>Loading...</div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../components/Sheet', () => ({
|
||||||
|
MobileSheet: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../hooks/useBackNavigation', () => ({
|
||||||
|
useBackNavigation: () => backMock,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../theme', () => ({
|
||||||
|
ADMIN_COLORS: {
|
||||||
|
primary: '#ff5a5f',
|
||||||
|
accent: '#6d28d9',
|
||||||
|
},
|
||||||
|
ADMIN_GRADIENTS: { softCard: 'linear-gradient(180deg, #fff, #f3f4f6)' },
|
||||||
|
useAdminTheme: () => ({
|
||||||
|
textStrong: '#0f172a',
|
||||||
|
muted: '#64748b',
|
||||||
|
subtle: '#94a3b8',
|
||||||
|
border: '#e2e8f0',
|
||||||
|
primary: '#ff5a5f',
|
||||||
|
accentSoft: '#f5f3ff',
|
||||||
|
danger: '#dc2626',
|
||||||
|
surfaceMuted: '#f8fafc',
|
||||||
|
surface: '#ffffff',
|
||||||
|
backdrop: '#0f172a',
|
||||||
|
dangerBg: '#fee2e2',
|
||||||
|
dangerText: '#b91c1c',
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@tamagui/stacks', () => ({
|
||||||
|
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@tamagui/text', () => ({
|
||||||
|
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@tamagui/react-native-web-lite', () => ({
|
||||||
|
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
|
||||||
|
<button type="button" onClick={onPress}>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('tamagui', () => ({
|
||||||
|
Slider: Object.assign(
|
||||||
|
({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
{
|
||||||
|
Track: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
TrackActive: ({ children }: { children?: React.ReactNode }) => <div>{children}</div>,
|
||||||
|
Thumb: () => <div />,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const getEventMock = vi.fn();
|
||||||
|
const updateEventMock = vi.fn();
|
||||||
|
const getTenantFontsMock = vi.fn();
|
||||||
|
const getTenantSettingsMock = vi.fn();
|
||||||
|
const trackOnboardingMock = vi.fn();
|
||||||
|
|
||||||
|
vi.mock('../../api', () => ({
|
||||||
|
TenantEvent: {},
|
||||||
|
TenantFont: {},
|
||||||
|
WatermarkSettings: {},
|
||||||
|
getEvent: (...args: unknown[]) => getEventMock(...args),
|
||||||
|
updateEvent: (...args: unknown[]) => updateEventMock(...args),
|
||||||
|
getTenantFonts: (...args: unknown[]) => getTenantFontsMock(...args),
|
||||||
|
getTenantSettings: (...args: unknown[]) => getTenantSettingsMock(...args),
|
||||||
|
trackOnboarding: (...args: unknown[]) => trackOnboardingMock(...args),
|
||||||
|
}));
|
||||||
|
|
||||||
|
import MobileBrandingPage from '../BrandingPage';
|
||||||
|
|
||||||
|
const baseEvent = {
|
||||||
|
id: 9,
|
||||||
|
name: 'Demo Event',
|
||||||
|
slug: 'demo-event',
|
||||||
|
event_date: null,
|
||||||
|
event_type_id: 1,
|
||||||
|
event_type: null,
|
||||||
|
status: 'draft' as const,
|
||||||
|
settings: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('MobileBrandingPage', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
getTenantFontsMock.mockResolvedValue([]);
|
||||||
|
getTenantSettingsMock.mockResolvedValue({ settings: {} });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides custom branding controls when default branding is active', async () => {
|
||||||
|
getEventMock.mockResolvedValueOnce({
|
||||||
|
...baseEvent,
|
||||||
|
settings: { branding: { use_default_branding: true } },
|
||||||
|
});
|
||||||
|
|
||||||
|
render(<MobileBrandingPage />);
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(screen.getByText('Branding Source')).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();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user