+56
-16
@@ -11,11 +11,13 @@ import {
|
||||
describe('ChicoryTV SPA scaffold', () => {
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
window.history.replaceState(null, '', '/');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
window.localStorage.clear();
|
||||
document.documentElement.removeAttribute('data-theme');
|
||||
window.history.replaceState(null, '', '/app');
|
||||
vi.restoreAllMocks();
|
||||
vi.spyOn(window, 'fetch').mockResolvedValue(
|
||||
new Response(JSON.stringify([]), {
|
||||
@@ -25,15 +27,62 @@ describe('ChicoryTV SPA scaffold', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('renders the placeholder shell and loads the design system stylesheet', () => {
|
||||
it('renders the admin shell chrome and loads the design system stylesheet', () => {
|
||||
render(<App />);
|
||||
|
||||
expect(screen.getByRole('heading', { name: 'ChicoryTV' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('img', { name: 'ChicoryTV' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('navigation', { name: 'Primary' })).toBeInTheDocument();
|
||||
expect(screen.getByText('SPA foundation ready')).toBeInTheDocument();
|
||||
expect(screen.getByRole('banner')).toBeInTheDocument();
|
||||
expect(screen.getByRole('searchbox', { name: 'Search' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Connect' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Add Channel' })).toBeInTheDocument();
|
||||
expect(screen.getByText('Healthy')).toBeInTheDocument();
|
||||
expect(designSystemStylesheet).toBe('../../design-system/styles.css');
|
||||
});
|
||||
|
||||
it('routes between shell screen slots without a page reload', () => {
|
||||
render(<App />);
|
||||
|
||||
fireEvent.click(screen.getByRole('link', { name: 'Channels' }));
|
||||
|
||||
expect(screen.getByRole('heading', { name: 'Channels' })).toBeInTheDocument();
|
||||
expect(screen.getByText('Channel list workspace')).toBeInTheDocument();
|
||||
expect(screen.getByRole('link', { name: 'Channels' })).toHaveAttribute(
|
||||
'aria-current',
|
||||
'page'
|
||||
);
|
||||
expect(window.location.pathname).toBe('/app/channels');
|
||||
|
||||
fireEvent.click(screen.getByRole('link', { name: 'Schedules' }));
|
||||
|
||||
expect(screen.getByRole('heading', { name: 'Schedules' })).toBeInTheDocument();
|
||||
expect(screen.getByText('Schedule editor workspace')).toBeInTheDocument();
|
||||
expect(window.location.pathname).toBe('/app/schedules');
|
||||
});
|
||||
|
||||
it('selects the active screen from the current location', () => {
|
||||
window.history.replaceState(null, '', '/app/guide');
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect(screen.getByRole('heading', { name: 'Guide' })).toBeInTheDocument();
|
||||
expect(screen.getByText('EPG grid workspace')).toBeInTheDocument();
|
||||
expect(screen.getByRole('link', { name: 'Guide' })).toHaveAttribute('aria-current', 'page');
|
||||
});
|
||||
|
||||
it('opens the Connect menu with player endpoints and enabled-only option', () => {
|
||||
render(<App />);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Connect' }));
|
||||
|
||||
expect(screen.getByRole('dialog', { name: 'Connect a player' })).toBeInTheDocument();
|
||||
expect(screen.getByText('M3U playlist')).toBeInTheDocument();
|
||||
expect(screen.getByText('XMLTV guide')).toBeInTheDocument();
|
||||
expect(screen.getByText('/iptv/channels.m3u?enabled=1')).toBeInTheDocument();
|
||||
expect(screen.getByText('/iptv/xmltv.xml?enabled=1')).toBeInTheDocument();
|
||||
expect(screen.getByRole('checkbox', { name: 'Only enabled channels' })).toBeChecked();
|
||||
});
|
||||
|
||||
it('applies the warm design-system default by removing the theme attribute', () => {
|
||||
document.documentElement.dataset.theme = 'cool';
|
||||
|
||||
@@ -69,21 +118,12 @@ describe('ChicoryTV SPA scaffold', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('renders the component gallery primitives', () => {
|
||||
it('renders routed placeholder cards for the downstream screen work', () => {
|
||||
render(<App />);
|
||||
|
||||
expect(screen.getByRole('heading', { name: 'Component gallery' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Forms' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Data display' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Feedback' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: 'Navigation' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Add Channel' })).toBeInTheDocument();
|
||||
expect(screen.getByText('HLS Segmenter')).toBeInTheDocument();
|
||||
expect(screen.getByText('Channel saved')).toBeInTheDocument();
|
||||
expect(screen.getByRole('tab', { name: 'Streaming' })).toHaveAttribute(
|
||||
'aria-selected',
|
||||
'true'
|
||||
);
|
||||
expect(screen.getByText('On air now')).toBeInTheDocument();
|
||||
expect(screen.getByText('Health checks')).toBeInTheDocument();
|
||||
expect(screen.getByText('Recent activity')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders live channel data from the typed API client', async () => {
|
||||
|
||||
Reference in New Issue
Block a user