mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
tests: More failed test fixes...
Some checks failed
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
Some checks failed
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
This commit is contained in:
parent
fa143aac41
commit
f75a3134fa
3 changed files with 66 additions and 23 deletions
|
|
@ -16,7 +16,9 @@ vi.mock('../../utils', () => ({
|
|||
}));
|
||||
|
||||
vi.mock('../../utils/components/SeriesModalUtils.js', () => ({
|
||||
formatStreamLabel: vi.fn((provider) => `${provider.m3u_account.name} - Stream ${provider.stream_id}`),
|
||||
formatStreamLabel: vi.fn(
|
||||
(provider) => `${provider.m3u_account.name} - Stream ${provider.stream_id}`
|
||||
),
|
||||
imdbUrl: vi.fn((id) => `https://www.imdb.com/title/${id}`),
|
||||
tmdbUrl: vi.fn((id, type) => `https://www.themoviedb.org/${type}/${id}`),
|
||||
formatDuration: vi.fn((secs) => `${Math.floor(secs / 60)} min`),
|
||||
|
|
@ -30,7 +32,9 @@ vi.mock('@mantine/core', async () => {
|
|||
opened ? (
|
||||
<div data-testid="modal">
|
||||
<div data-testid="modal-title">{title}</div>
|
||||
<button data-testid="modal-close" onClick={onClose}>Close</button>
|
||||
<button data-testid="modal-close" onClick={onClose}>
|
||||
Close
|
||||
</button>
|
||||
{children}
|
||||
</div>
|
||||
) : null,
|
||||
|
|
@ -56,8 +60,12 @@ vi.mock('@mantine/core', async () => {
|
|||
<span {...props}>{children}</span>
|
||||
),
|
||||
Select: ({ data, value, onChange, placeholder, disabled }) => (
|
||||
<select data-testid="provider-select" value={value}
|
||||
onChange={(e) => onChange(e.target.value)} disabled={disabled}>
|
||||
<select
|
||||
data-testid="provider-select"
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<option value="">{placeholder}</option>
|
||||
{data.map((item) => (
|
||||
<option key={item.value} value={item.value}>
|
||||
|
|
@ -71,10 +79,14 @@ vi.mock('@mantine/core', async () => {
|
|||
});
|
||||
|
||||
// Mock lucide-react icons
|
||||
vi.mock('lucide-react', () => ({
|
||||
Play: () => <span>Play Icon</span>,
|
||||
Copy: () => <span>Copy Icon</span>,
|
||||
}));
|
||||
vi.mock('lucide-react', async (importOriginal) => {
|
||||
const actual = await importOriginal();
|
||||
return {
|
||||
...actual,
|
||||
Play: () => <span>Play Icon</span>,
|
||||
Copy: () => <span>Copy Icon</span>,
|
||||
};
|
||||
});
|
||||
|
||||
describe('VODModal', () => {
|
||||
const mockShowVideo = vi.fn();
|
||||
|
|
@ -158,7 +170,9 @@ describe('VODModal', () => {
|
|||
render(<VODModal vod={mockVOD} opened={true} onClose={mockOnClose} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Original: Original Test Movie')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText('Original: Original Test Movie')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
expect(screen.getByText('2023')).toBeInTheDocument();
|
||||
|
|
@ -174,7 +188,9 @@ describe('VODModal', () => {
|
|||
render(<VODModal vod={mockVOD} opened={true} onClose={mockOnClose} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockFetchMovieDetailsFromProvider).toHaveBeenCalledWith(mockVOD.id);
|
||||
expect(mockFetchMovieDetailsFromProvider).toHaveBeenCalledWith(
|
||||
mockVOD.id
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -193,7 +209,9 @@ describe('VODModal', () => {
|
|||
|
||||
render(<VODModal vod={mockVOD} opened={true} onClose={mockOnClose} />);
|
||||
|
||||
expect(screen.getByText('Loading additional details...')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText('Loading additional details...')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should handle play button click', async () => {
|
||||
|
|
@ -210,7 +228,10 @@ describe('VODModal', () => {
|
|||
});
|
||||
|
||||
it('should disable play button when multiple providers and none selected', async () => {
|
||||
mockFetchMovieProviders.mockResolvedValue([mockProvider, { ...mockProvider, id: 2 }]);
|
||||
mockFetchMovieProviders.mockResolvedValue([
|
||||
mockProvider,
|
||||
{ ...mockProvider, id: 2 },
|
||||
]);
|
||||
|
||||
render(<VODModal vod={mockVOD} opened={true} onClose={mockOnClose} />);
|
||||
|
||||
|
|
@ -255,7 +276,9 @@ describe('VODModal', () => {
|
|||
});
|
||||
|
||||
it('should handle fetch details error gracefully', async () => {
|
||||
mockFetchMovieDetailsFromProvider.mockRejectedValue(new Error('Fetch failed'));
|
||||
mockFetchMovieDetailsFromProvider.mockRejectedValue(
|
||||
new Error('Fetch failed')
|
||||
);
|
||||
|
||||
render(<VODModal vod={mockVOD} opened={true} onClose={mockOnClose} />);
|
||||
|
||||
|
|
@ -310,8 +333,14 @@ describe('VODModal', () => {
|
|||
const imdbLink = screen.getByText('IMDb');
|
||||
const tmdbLink = screen.getByText('TMDb');
|
||||
|
||||
expect(imdbLink).toHaveAttribute('href', 'https://www.imdb.com/title/tt1234567');
|
||||
expect(tmdbLink).toHaveAttribute('href', 'https://www.themoviedb.org/movie/12345');
|
||||
expect(imdbLink).toHaveAttribute(
|
||||
'href',
|
||||
'https://www.imdb.com/title/tt1234567'
|
||||
);
|
||||
expect(tmdbLink).toHaveAttribute(
|
||||
'href',
|
||||
'https://www.themoviedb.org/movie/12345'
|
||||
);
|
||||
});
|
||||
|
||||
describe('Copy Link Functionality', () => {
|
||||
|
|
@ -350,7 +379,7 @@ describe('VODModal', () => {
|
|||
});
|
||||
|
||||
await waitFor(() => {
|
||||
const copyButton = screen.getByText('Copy Link')
|
||||
const copyButton = screen.getByText('Copy Link');
|
||||
fireEvent.click(copyButton);
|
||||
});
|
||||
|
||||
|
|
@ -432,7 +461,9 @@ describe('VODModal', () => {
|
|||
render(<VODModal vod={minimalVOD} opened={true} onClose={mockOnClose} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('modal-title')).toHaveTextContent('Test Movie');
|
||||
expect(screen.getByTestId('modal-title')).toHaveTextContent(
|
||||
'Test Movie'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,7 +72,11 @@ vi.mock('../../components/forms/settings/SystemSettingsForm', () => ({
|
|||
),
|
||||
}));
|
||||
vi.mock('../../components/forms/settings/NavOrderForm', () => ({
|
||||
default: ({ active }) => <div data-testid="nav-order-form">NavOrderForm {active ? 'active' : 'inactive'}</div>,
|
||||
default: ({ active }) => (
|
||||
<div data-testid="nav-order-form">
|
||||
NavOrderForm {active ? 'active' : 'inactive'}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
vi.mock('../../components/ErrorBoundary', () => ({
|
||||
default: ({ children }) => <div data-testid="error-boundary">{children}</div>,
|
||||
|
|
@ -99,6 +103,7 @@ vi.mock('@mantine/core', async () => {
|
|||
AccordionPanel: accordionComponent.Panel,
|
||||
Box: ({ children }) => <div>{children}</div>,
|
||||
Center: ({ children }) => <div>{children}</div>,
|
||||
Divider: () => <hr />,
|
||||
Loader: () => <div data-testid="loader">Loading...</div>,
|
||||
Text: ({ children }) => <span>{children}</span>,
|
||||
};
|
||||
|
|
@ -130,7 +135,7 @@ describe('SettingsPage', () => {
|
|||
it('renders the settings page', () => {
|
||||
renderWithRouter(<SettingsPage />);
|
||||
|
||||
expect(screen.getByTestId('accordion')).toBeInTheDocument();
|
||||
expect(screen.getAllByTestId('accordion').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('renders UI Settings accordion item', () => {
|
||||
|
|
@ -162,9 +167,11 @@ describe('SettingsPage', () => {
|
|||
});
|
||||
|
||||
it('renders Navigation accordion item for regular users', () => {
|
||||
render(<SettingsPage />);
|
||||
renderWithRouter(<SettingsPage />);
|
||||
|
||||
expect(screen.getByTestId('accordion-item-nav-order')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByTestId('accordion-item-nav-order')
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText('Navigation')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
@ -258,9 +265,11 @@ describe('SettingsPage', () => {
|
|||
});
|
||||
|
||||
it('renders Navigation accordion item', () => {
|
||||
render(<SettingsPage />);
|
||||
renderWithRouter(<SettingsPage />);
|
||||
|
||||
expect(screen.getByTestId('accordion-item-nav-order')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByTestId('accordion-item-nav-order')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -107,11 +107,13 @@ describe('useAuthStore', () => {
|
|||
setState({
|
||||
isAuthenticated: false,
|
||||
isInitialized: false,
|
||||
isInitializing: false,
|
||||
needsSuperuser: false,
|
||||
user: {
|
||||
username: '',
|
||||
email: '',
|
||||
user_level: '',
|
||||
custom_properties: {},
|
||||
},
|
||||
isLoading: false,
|
||||
error: null,
|
||||
|
|
@ -134,6 +136,7 @@ describe('useAuthStore', () => {
|
|||
username: '',
|
||||
email: '',
|
||||
user_level: '',
|
||||
custom_properties: {},
|
||||
});
|
||||
expect(result.current.isLoading).toBe(false);
|
||||
expect(result.current.error).toBeNull();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue