mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
- 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.
62 lines
1.5 KiB
JavaScript
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();
|
|
});
|
|
});
|
|
});
|