Watch party invites by profile: host invites online profiles, invited users see running parties on open and can join one or dismiss
This commit is contained in:
@@ -146,6 +146,28 @@ describe('watch party presenting', () => {
|
||||
});
|
||||
});
|
||||
|
||||
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' });
|
||||
const { code } = await host.next('hello');
|
||||
const p = hub._parties.get(code);
|
||||
host.send({ type: 'invite', profile: 'Psalm-Team' });
|
||||
expect((await host.next('invites')).invites).toEqual(['psalm-team']);
|
||||
expect(hub.invitesFor('PSALM-TEAM')).toMatchObject([{ code, host: 'Josh', members: 1 }]);
|
||||
host.send({ type: 'invite', profile: 'x' });
|
||||
expect((await host.next('invites')).error).toMatch(/3–40/);
|
||||
const g = client({ role: 'guest', pid: 'guestpid0021', key: 'g'.repeat(36), name: 'G', code });
|
||||
await g.next('hello');
|
||||
g.send({ type: 'invite', profile: 'someone' });
|
||||
await Bun.sleep(150);
|
||||
expect([...p.invites.keys()]).toEqual(['psalm-team']);
|
||||
host.send({ type: 'uninvite', profile: 'psalm-team' });
|
||||
expect((await host.next('invites')).invites).toEqual([]);
|
||||
expect(hub.invitesFor('psalm-team')).toEqual([]);
|
||||
host.send({ type: 'end' }); await host.closed;
|
||||
});
|
||||
});
|
||||
|
||||
describe('watch party seat rules', () => {
|
||||
test('unknown code closes with 4004 (no reconnect loop)', async () => {
|
||||
const bad = client({ role: 'guest', pid: 'guestpid7777', name: 'X', code: 'YYYYYY' });
|
||||
|
||||
Reference in New Issue
Block a user