Chat im Match: Match-Chat und Team-Chat in Tabs, Zuschauer ausgeschlossen, nach Matchende nur lesbar
This commit is contained in:
1 parent
e26c736f2e
commit
c820ba9f12
8 files changed
+267
No files matched your search
@@ -648,3 +648,45 @@ test('Ohne Messerrunde bleibt firstTeam wirkungslos', async () => {
|
||||
await close();
|
||||
}
|
||||
});
|
||||
test('Chat: Match-Chat für beide Teams und Organisator, Team-Chat nur fürs eigene Team, Zuschauer sehen nichts', async () => {
|
||||
const { call, close } = await setup();
|
||||
try {
|
||||
const { id, org, codes, tokens } = await readyWingmanMatch(call, 'bo1');
|
||||
const spectator = codes.spectator;
|
||||
const post = (token, channel, text) => call('POST', `/matches/${id}/chat`, { token, body: { channel, text } });
|
||||
|
||||
assert.equal((await post(tokens.a1, 'match', 'Hallo zusammen')).status, 200);
|
||||
assert.equal((await post(tokens.a1, 'A', 'Wir bannen Nuke')).status, 200);
|
||||
assert.equal((await post(org, 'match', 'Veto startet gleich')).status, 200);
|
||||
// Fremder Team-Chat und Zuschauer: verboten
|
||||
assert.equal((await post(tokens.b1, 'A', 'Spioniere')).status, 403);
|
||||
assert.equal((await post(org, 'A', 'Organisator im Team-Chat')).status, 403);
|
||||
assert.equal((await post(spectator, 'match', 'Zuschauer')).status, 403);
|
||||
assert.equal((await post(tokens.a1, 'match', ' ')).status, 400);
|
||||
assert.equal((await post(tokens.a1, 'match', 'x'.repeat(301))).status, 400);
|
||||
|
||||
const a = (await call('GET', `/matches/${id}`, { token: tokens.a2 })).body.chat;
|
||||
assert.deepEqual(a.channels.map((c) => c.key), ['match', 'A']);
|
||||
assert.deepEqual(a.messages.match.map((m) => m.text), ['Hallo zusammen', 'Veto startet gleich']);
|
||||
assert.equal(a.messages.match[1].organizer, true);
|
||||
assert.deepEqual(a.messages.A.map((m) => m.text), ['Wir bannen Nuke']);
|
||||
|
||||
const b = (await call('GET', `/matches/${id}`, { token: tokens.b1 })).body.chat;
|
||||
assert.deepEqual(b.channels.map((c) => c.key), ['match', 'B']);
|
||||
assert.ok(!JSON.stringify(b).includes('Wir bannen Nuke'), 'Team B sieht den Team-Chat von A nicht');
|
||||
assert.deepEqual((await call('GET', `/matches/${id}`, { token: org })).body.chat.channels.map((c) => c.key), ['match']);
|
||||
assert.equal((await call('GET', `/matches/${id}`, { token: spectator })).body.chat, null);
|
||||
assert.equal((await call('GET', `/matches/${id}`)).body.chat, null);
|
||||
|
||||
// Spam-Schutz und nach Matchende nur lesbar
|
||||
for (let i = 0; i < 5; i++) await post(tokens.b1, 'match', `Nachricht ${i}`);
|
||||
assert.equal((await post(tokens.b1, 'match', 'eine zu viel')).status, 429);
|
||||
await call('POST', `/matches/${id}/finish`, { token: org });
|
||||
assert.equal((await post(tokens.a1, 'match', 'Nach dem Ende')).status, 409);
|
||||
const closed = (await call('GET', `/matches/${id}`, { token: tokens.a1 })).body.chat;
|
||||
assert.equal(closed.canWrite, false);
|
||||
assert.equal(closed.messages.match.length, 7);
|
||||
} finally {
|
||||
await close();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user