1 parent
639362fbf5
commit
bdd69f0aad
101 files changed
+22691
-531
No files matched your search
@@ -0,0 +1,24 @@
|
||||
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"');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user