Refresh mobile dashboard and header
This commit is contained in:
@@ -42,14 +42,16 @@ vi.mock('../BottomNav', () => ({
|
||||
NavKey: {},
|
||||
}));
|
||||
|
||||
const eventContext = {
|
||||
events: [],
|
||||
activeEvent: { slug: 'event-1', name: 'Test Event', event_date: '2024-01-01', status: 'active', settings: {} },
|
||||
hasMultipleEvents: false,
|
||||
hasEvents: true,
|
||||
selectEvent: vi.fn(),
|
||||
};
|
||||
|
||||
vi.mock('../../../context/EventContext', () => ({
|
||||
useEventContext: () => ({
|
||||
events: [],
|
||||
activeEvent: { slug: 'event-1', name: 'Test Event', event_date: '2024-01-01', status: 'active', settings: {} },
|
||||
hasMultipleEvents: false,
|
||||
hasEvents: true,
|
||||
selectEvent: vi.fn(),
|
||||
}),
|
||||
useEventContext: () => eventContext,
|
||||
}));
|
||||
|
||||
vi.mock('../../../auth/context', () => ({
|
||||
@@ -105,6 +107,7 @@ vi.mock('../../theme', () => ({
|
||||
}));
|
||||
|
||||
import { MobileShell } from '../MobileShell';
|
||||
import { ADMIN_EVENTS_PATH } from '../../../constants';
|
||||
|
||||
describe('MobileShell', () => {
|
||||
beforeEach(() => {
|
||||
@@ -113,6 +116,9 @@ describe('MobileShell', () => {
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
});
|
||||
eventContext.events = [];
|
||||
eventContext.hasMultipleEvents = false;
|
||||
eventContext.activeEvent = { slug: 'event-1', name: 'Test Event', event_date: '2024-01-01', status: 'active', settings: {} };
|
||||
});
|
||||
|
||||
it('renders quick QR as icon-only button', async () => {
|
||||
@@ -149,4 +155,44 @@ describe('MobileShell', () => {
|
||||
|
||||
expect(screen.queryByText('Test Event')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the event switcher when multiple events are available', async () => {
|
||||
eventContext.hasMultipleEvents = true;
|
||||
eventContext.events = [
|
||||
{ slug: 'event-1', name: 'Test Event', event_date: '2024-01-01', status: 'active', settings: {} },
|
||||
{ slug: 'event-2', name: 'Second Event', event_date: '2024-02-01', status: 'active', settings: {} },
|
||||
];
|
||||
|
||||
await act(async () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<MobileShell activeTab="home">
|
||||
<div>Body</div>
|
||||
</MobileShell>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
|
||||
expect(screen.getByLabelText('Switch event')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the event switcher on the events list page', async () => {
|
||||
eventContext.hasMultipleEvents = true;
|
||||
eventContext.events = [
|
||||
{ slug: 'event-1', name: 'Test Event', event_date: '2024-01-01', status: 'active', settings: {} },
|
||||
{ slug: 'event-2', name: 'Second Event', event_date: '2024-02-01', status: 'active', settings: {} },
|
||||
];
|
||||
|
||||
await act(async () => {
|
||||
render(
|
||||
<MemoryRouter initialEntries={[ADMIN_EVENTS_PATH]}>
|
||||
<MobileShell activeTab="home">
|
||||
<div>Body</div>
|
||||
</MobileShell>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
|
||||
expect(screen.queryByLabelText('Switch event')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user