Update guest v2 branding and theming
This commit is contained in:
59
resources/js/guest-v2/__tests__/EventLogo.test.tsx
Normal file
59
resources/js/guest-v2/__tests__/EventLogo.test.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import EventLogo from '../components/EventLogo';
|
||||
import { EventBrandingProvider } from '@/guest/context/EventBrandingContext';
|
||||
import type { EventBranding } from '@/guest/types/event-branding';
|
||||
|
||||
vi.mock('@tamagui/stacks', () => ({
|
||||
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
}));
|
||||
|
||||
vi.mock('@tamagui/text', () => ({
|
||||
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
|
||||
}));
|
||||
|
||||
const baseBranding: EventBranding = {
|
||||
primaryColor: '#ff5a5f',
|
||||
secondaryColor: '#fbcfe8',
|
||||
backgroundColor: '#fff7f5',
|
||||
fontFamily: null,
|
||||
logoUrl: null,
|
||||
logo: {
|
||||
mode: 'emoticon',
|
||||
value: '🎉',
|
||||
size: 'm',
|
||||
},
|
||||
mode: 'auto',
|
||||
};
|
||||
|
||||
describe('EventLogo', () => {
|
||||
it('renders an uploaded logo image when configured', () => {
|
||||
const branding: EventBranding = {
|
||||
...baseBranding,
|
||||
logo: {
|
||||
mode: 'upload',
|
||||
value: 'https://example.com/logo.png',
|
||||
size: 'm',
|
||||
},
|
||||
};
|
||||
|
||||
render(
|
||||
<EventBrandingProvider branding={branding}>
|
||||
<EventLogo name="Demo Event" />
|
||||
</EventBrandingProvider>
|
||||
);
|
||||
|
||||
expect(screen.getByAltText('Demo Event')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders an emoji fallback when configured', () => {
|
||||
render(
|
||||
<EventBrandingProvider branding={baseBranding}>
|
||||
<EventLogo name="Demo Event" />
|
||||
</EventBrandingProvider>
|
||||
);
|
||||
|
||||
expect(screen.getByText('🎉')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -32,8 +32,12 @@ vi.mock('../components/SurfaceCard', () => ({
|
||||
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
}));
|
||||
|
||||
vi.mock('../components/ShareSheet', () => ({
|
||||
default: () => <div>ShareSheet</div>,
|
||||
}));
|
||||
|
||||
vi.mock('../context/EventDataContext', () => ({
|
||||
useEventData: () => ({ token: 'token' }),
|
||||
useEventData: () => ({ token: 'token', event: { name: 'Demo Event' } }),
|
||||
}));
|
||||
|
||||
vi.mock('../services/photosApi', () => ({
|
||||
|
||||
@@ -103,6 +103,14 @@ vi.mock('../services/emotionsApi', () => ({
|
||||
fetchEmotions: vi.fn().mockResolvedValue([]),
|
||||
}));
|
||||
|
||||
vi.mock('../hooks/usePollStats', () => ({
|
||||
usePollStats: () => ({ stats: { onlineGuests: 0, tasksSolved: 0, latestPhotoAt: null } }),
|
||||
}));
|
||||
|
||||
vi.mock('../services/qrApi', () => ({
|
||||
fetchEventQrCode: () => Promise.resolve({ qr_code_data_url: null }),
|
||||
}));
|
||||
|
||||
vi.mock('@/guest/hooks/useGuestTaskProgress', () => ({
|
||||
useGuestTaskProgress: () => ({ completedCount: 0 }),
|
||||
}));
|
||||
|
||||
63
resources/js/guest-v2/__tests__/ShareScreen.test.tsx
Normal file
63
resources/js/guest-v2/__tests__/ShareScreen.test.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import React from 'react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
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/button', () => ({
|
||||
Button: ({ children, ...rest }: { children: React.ReactNode }) => (
|
||||
<button type="button" {...rest}>
|
||||
{children}
|
||||
</button>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('../components/AppShell', () => ({
|
||||
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
}));
|
||||
|
||||
vi.mock('../context/EventDataContext', () => ({
|
||||
useEventData: () => ({
|
||||
token: 'demo-token',
|
||||
event: { name: 'Demo Event', join_token: 'demo-token' },
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock('../hooks/usePollStats', () => ({
|
||||
usePollStats: () => ({ stats: { onlineGuests: 12, tasksSolved: 0, latestPhotoAt: null } }),
|
||||
}));
|
||||
|
||||
vi.mock('../services/qrApi', () => ({
|
||||
fetchEventQrCode: () => Promise.resolve({ qr_code_data_url: 'data:image/png;base64,abc' }),
|
||||
}));
|
||||
|
||||
vi.mock('@/guest/i18n/useTranslation', () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, arg2?: Record<string, string | number> | string, arg3?: string) =>
|
||||
typeof arg2 === 'string' || arg2 === undefined ? (arg2 ?? arg3 ?? key) : (arg3 ?? key),
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock('@/hooks/use-appearance', () => ({
|
||||
useAppearance: () => ({ resolved: 'light' }),
|
||||
}));
|
||||
|
||||
import ShareScreen from '../screens/ShareScreen';
|
||||
|
||||
describe('ShareScreen', () => {
|
||||
it('shows guests online from stats', async () => {
|
||||
render(<ShareScreen />);
|
||||
|
||||
expect(await screen.findByText('12')).toBeInTheDocument();
|
||||
expect(screen.getByText('Guests joined')).toBeInTheDocument();
|
||||
expect(screen.getByText('Guests online')).toBeInTheDocument();
|
||||
expect(screen.getByAltText('Event QR code')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user