feat: configure overview camera per curriculum week
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { normalizeCameraUrl, readWeekCamera } from './week-camera';
|
||||
|
||||
describe('week camera settings', () => {
|
||||
it('keeps only viewing parameters', () => {
|
||||
const url = new URL(normalizeCameraUrl('https://vdo.ninja/?room=track&view=camera&push=bad&director=bad&password=secret'));
|
||||
expect(url.searchParams.get('room')).toBe('track');
|
||||
expect(url.searchParams.get('view')).toBe('camera');
|
||||
expect(url.searchParams.has('scene')).toBe(true);
|
||||
expect(url.searchParams.has('push')).toBe(false);
|
||||
expect(url.searchParams.has('director')).toBe(false);
|
||||
expect(url.searchParams.has('password')).toBe(false);
|
||||
});
|
||||
|
||||
it.each(['http://vdo.ninja/?room=x&view=y', 'https://example.com/?room=x&view=y', 'https://vdo.ninja/?room=x', 'javascript:alert(1)', 'https://vdo.ninja:8443/?room=x&view=y'])('rejects unsafe or incomplete URL %s', (url) => {
|
||||
expect(() => normalizeCameraUrl(url)).toThrow();
|
||||
});
|
||||
|
||||
it('supports unset camera settings and preserves password whitespace', () => {
|
||||
expect(normalizeCameraUrl(' ')).toBe('');
|
||||
expect(readWeekCamera(null)).toEqual({ url: '', password: '' });
|
||||
expect(readWeekCamera({ cameraViewUrl: 'url', cameraPassword: ' a&b ' })).toEqual({ url: 'url', password: ' a&b ' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user