Files
Echoion/EchoionWeb/frontend/src/views/UpdatesView.test.tsx
T
faumaray bdd69f0aad update
Signed-off-by: faumaray <faumaray@gmail.com>
2026-07-25 23:44:48 +03:00

25 lines
1011 B
TypeScript

import { afterEach, describe, expect, it } from 'vitest';
import { renderToStaticMarkup } from 'react-dom/server';
import { appStore } from '../lib/app';
import { UpdatesView } from './UpdatesView';
afterEach(() => appStore.set({ identity: null }));
describe('UpdatesView authorization', () => {
it('shows an authorization guard to non-administrators', () => {
appStore.set({ identity: { nickname: 'listener', isAdmin: false } });
const html = renderToStaticMarkup(<UpdatesView />);
expect(html).toContain('Administrator authentication required');
expect(html).not.toContain('Check now');
});
it('renders the update controls only for an administrator', () => {
appStore.set({ identity: { nickname: 'operator', isAdmin: true } });
const html = renderToStaticMarkup(<UpdatesView />);
expect(html).toContain('Check now');
expect(html).toContain('Update history');
expect(html).not.toContain('Administrator authentication required');
expect(html).toContain('aria-live="polite"');
});
});