Dispatcharr/frontend/src/components/tables/__tests__/ServerGroupsTable.test.jsx
SergeantPanda bc046b3c92 refactor(m3u, channels): streamline stream assignment and server group management
- Renamed `_clear_stream_assignment_keys` to `_release_stale_stream_assignment` for clarity and updated its logic to release pool counters.
- Introduced new functions for managing credential slots during profile switches, enhancing the handling of shared connection limits across server groups.
- Removed the `max_streams` field from the `ServerGroup` model and updated related components to reflect this change, simplifying the server group management.
- Updated frontend components to integrate server group management, allowing for dynamic creation and editing of server groups.
- Enhanced error handling in stream URL generation to provide more informative feedback on connection issues.
- Added tests for stale assignment release and credential management during profile switches.
2026-06-09 13:40:16 -05:00

62 lines
1.5 KiB
JavaScript

import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import { MantineProvider } from '@mantine/core';
import ServerGroupsTable from '../ServerGroupsTable';
const renderTable = () =>
render(
<MantineProvider>
<ServerGroupsTable />
</MantineProvider>
);
vi.mock('../../../api', () => ({
default: {
deleteServerGroup: vi.fn(),
},
}));
vi.mock('../../../store/serverGroups', () => ({
default: (selector) =>
selector({
serverGroups: [
{ id: 1, name: 'Pool A' },
{ id: 2, name: 'Pool B' },
],
fetchServerGroups: vi.fn().mockResolvedValue(undefined),
}),
}));
vi.mock('../../../store/playlists', () => ({
default: (selector) =>
selector({
playlists: [
{ id: 10, server_group: 2 },
{ id: 11, server_group: 1 },
],
}),
}));
vi.mock('../../forms/ServerGroup', () => ({
default: () => null,
}));
vi.mock('../../../hooks/useLocalStorage', () => ({
default: () => ['default', vi.fn()],
}));
describe('ServerGroupsTable', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('renders server groups without tooltip errors', async () => {
expect(() => renderTable()).not.toThrow();
await waitFor(() => {
expect(screen.getByText('Pool A')).toBeInTheDocument();
expect(screen.getByText('Pool B')).toBeInTheDocument();
expect(screen.getByText('Accounts')).toBeInTheDocument();
});
});
});