Watch party: Prepared presentations queue for the host (add, name, reorder, remove, present when it is time)

This commit is contained in:
Jonathan Sykes
2026-10-15 19:31:53 +08:00
parent 1352ed9f29
commit 1383e89a25
4 changed files with 80 additions and 11 deletions

View File

@@ -146,6 +146,29 @@ describe('watch party presenting', () => {
});
});
describe('watch party presentation queue', () => {
test('host prepares, reorders and removes queued presentations; guests cannot; it survives a host reload', async () => {
const host = client({ role: 'host', pid: 'hostpid0030', name: 'H' });
const { code, secret } = await host.next('hello');
host.send({ type: 'pq', action: 'add', url: 'https://docs.google.com/presentation/d/a/edit', mode: 'embed', title: 'Sermon slides' });
host.send({ type: 'pq', action: 'add', url: 'https://example.com/notes', mode: 'reader', title: '' });
host.send({ type: 'pq', action: 'add', url: 'javascript:alert(1)' });
let items = (await host.next('pq')).items; items = (await host.next('pq')).items;
expect(items.map((x) => x.title || x.url)).toEqual(['Sermon slides', 'https://example.com/notes']);
host.send({ type: 'pq', action: 'move', id: items[1].id, by: -1 });
expect((await host.next('pq')).items[0].url).toBe('https://example.com/notes');
const g = client({ role: 'guest', pid: 'guestpid0031', key: 'q'.repeat(36), name: 'G', code });
expect((await g.next('hello')).pq).toBeUndefined();
g.send({ type: 'pq', action: 'add', url: 'https://evil.example/' });
host.ws.close(); await host.closed;
const again = client({ role: 'host', pid: 'hostpid0030', name: 'H', code, secret });
expect((await again.next('hello')).pq.length).toBe(2);
again.send({ type: 'pq', action: 'remove', id: items[0].id });
expect((await again.next('pq')).items.length).toBe(1);
again.send({ type: 'end' }); await again.closed;
});
});
describe('watch party invites', () => {
test('host invites a profile; it is listed for that profile until uninvited or the party ends', async () => {
const host = client({ role: 'host', pid: 'hostpid0020', name: 'Josh' });