upgrade to tamagui v2 and guest pwa overhaul
This commit is contained in:
53
resources/js/guest-v2/__tests__/EventLayout.test.tsx
Normal file
53
resources/js/guest-v2/__tests__/EventLayout.test.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import React from 'react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
let identityState = { hydrated: true, name: '' };
|
||||
|
||||
vi.mock('react-router-dom', () => ({
|
||||
useParams: () => ({ token: 'demo-token' }),
|
||||
Navigate: ({ to }: { to: string }) => <div>navigate:{to}</div>,
|
||||
Outlet: () => <div>outlet</div>,
|
||||
}));
|
||||
|
||||
vi.mock('../context/EventDataContext', () => ({
|
||||
EventDataProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
useEventData: () => ({ event: null }),
|
||||
}));
|
||||
|
||||
vi.mock('@/guest/context/EventBrandingContext', () => ({
|
||||
EventBrandingProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
}));
|
||||
|
||||
vi.mock('@/guest/i18n/LocaleContext', () => ({
|
||||
LocaleProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
DEFAULT_LOCALE: 'de',
|
||||
isLocaleCode: () => true,
|
||||
}));
|
||||
|
||||
vi.mock('@/guest/context/NotificationCenterContext', () => ({
|
||||
NotificationCenterProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
}));
|
||||
|
||||
vi.mock('../context/GuestIdentityContext', () => ({
|
||||
GuestIdentityProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
useOptionalGuestIdentity: () => identityState,
|
||||
}));
|
||||
|
||||
import EventLayout from '../layouts/EventLayout';
|
||||
|
||||
describe('EventLayout profile gate', () => {
|
||||
it('redirects to setup when profile is missing', () => {
|
||||
identityState = { hydrated: true, name: '' };
|
||||
render(<EventLayout requireProfile />);
|
||||
|
||||
expect(screen.getByText('navigate:/setup/demo-token')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders outlet when profile exists', () => {
|
||||
identityState = { hydrated: true, name: 'Ava' };
|
||||
render(<EventLayout requireProfile />);
|
||||
|
||||
expect(screen.getByText('outlet')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user