88 lines
2.6 KiB
TypeScript
88 lines
2.6 KiB
TypeScript
import React from 'react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { EventDataProvider } from '../context/EventDataContext';
|
|
|
|
vi.mock('react-router-dom', () => ({
|
|
useNavigate: () => vi.fn(),
|
|
useSearchParams: () => [new URLSearchParams('taskId=12')],
|
|
}));
|
|
|
|
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('../services/uploadApi', () => ({
|
|
uploadPhoto: vi.fn(),
|
|
useUploadQueue: () => ({ items: [], add: vi.fn() }),
|
|
}));
|
|
|
|
vi.mock('../services/tasksApi', () => ({
|
|
fetchTasks: vi.fn().mockResolvedValue([{ id: 12, title: 'Capture the dancefloor', description: 'Find the happiest crew.' }]),
|
|
}));
|
|
|
|
vi.mock('@/guest/services/pendingUploadsApi', () => ({
|
|
fetchPendingUploadsSummary: vi.fn().mockResolvedValue({ items: [], totalCount: 0 }),
|
|
}));
|
|
|
|
vi.mock('../context/GuestIdentityContext', () => ({
|
|
useOptionalGuestIdentity: () => ({ name: 'Alex' }),
|
|
}));
|
|
|
|
vi.mock('@/guest/hooks/useGuestTaskProgress', () => ({
|
|
useGuestTaskProgress: () => ({ markCompleted: vi.fn() }),
|
|
}));
|
|
|
|
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),
|
|
locale: 'en',
|
|
}),
|
|
}));
|
|
|
|
vi.mock('@/hooks/use-appearance', () => ({
|
|
useAppearance: () => ({ resolved: 'light' }),
|
|
}));
|
|
|
|
import UploadScreen from '../screens/UploadScreen';
|
|
|
|
describe('UploadScreen', () => {
|
|
it('renders queue entry point', () => {
|
|
render(
|
|
<EventDataProvider token="token">
|
|
<UploadScreen />
|
|
</EventDataProvider>
|
|
);
|
|
|
|
expect(screen.getByText('Queue')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders task summary when taskId is present', async () => {
|
|
render(
|
|
<EventDataProvider token="token">
|
|
<UploadScreen />
|
|
</EventDataProvider>
|
|
);
|
|
|
|
expect(await screen.findByText('Capture the dancefloor')).toBeInTheDocument();
|
|
});
|
|
});
|