fix tests

This commit is contained in:
Will Hunt 2024-09-19 16:17:37 +01:00
parent b9d4f21786
commit c77d57b842

View File

@ -35,7 +35,7 @@ describe("Test: Mention spam protection", function () {
await delay(500); await delay(500);
const fetchedEvent = await client.getEvent(room, testMessage); const fetchedEvent = await client.getEvent(room, testMessage);
assert.equal(Object.keys(fetchedEvent.content).length, 3, "This event should not have been redacted"); assert.equal(Object.keys(fetchedEvent.content).length, 2, "This event should not have been redacted");
}); });
it("does not redact a message with some mentions", async function() { it("does not redact a message with some mentions", async function() {
@ -46,7 +46,6 @@ describe("Test: Mention spam protection", function () {
// Also covers HTML mentions // Also covers HTML mentions
const messageWithTextMentions = await client.sendText(room, 'Hello world @foo:bar @beep:boop @test:here'); const messageWithTextMentions = await client.sendText(room, 'Hello world @foo:bar @beep:boop @test:here');
const messageWithMMentions = await client.sendMessage(room, { const messageWithMMentions = await client.sendMessage(room, {
content: {
msgtype: 'm.text', msgtype: 'm.text',
body: 'Hello world', body: 'Hello world',
['m.mentions']: { ['m.mentions']: {
@ -56,12 +55,11 @@ describe("Test: Mention spam protection", function () {
"@test:here" "@test:here"
] ]
} }
}
}); });
await delay(500); await delay(500);
const fetchedTextEvent = await client.getEvent(room, messageWithTextMentions); const fetchedTextEvent = await client.getEvent(room, messageWithTextMentions);
assert.equal(Object.keys(fetchedTextEvent.content).length, 3, "This event should not have been redacted"); assert.equal(Object.keys(fetchedTextEvent.content).length, 2, "This event should not have been redacted");
const fetchedMentionsEvent = await client.getEvent(room, messageWithMMentions); const fetchedMentionsEvent = await client.getEvent(room, messageWithMMentions);
assert.equal(Object.keys(fetchedMentionsEvent.content).length, 3, "This event should not have been redacted"); assert.equal(Object.keys(fetchedMentionsEvent.content).length, 3, "This event should not have been redacted");
}); });
@ -75,13 +73,11 @@ describe("Test: Mention spam protection", function () {
const mentionUsers = Array.from({length: DEFAULT_MAX_MENTIONS}, (_, i) => `@user${i}:example.org`); const mentionUsers = Array.from({length: DEFAULT_MAX_MENTIONS}, (_, i) => `@user${i}:example.org`);
const messageWithTextMentions = await client.sendText(room, 'Hello world ' + mentionUsers.join(' ')); const messageWithTextMentions = await client.sendText(room, 'Hello world ' + mentionUsers.join(' '));
const messageWithMMentions = await client.sendMessage(room, { const messageWithMMentions = await client.sendMessage(room, {
content: {
msgtype: 'm.text', msgtype: 'm.text',
body: 'Hello world', body: 'Hello world',
['m.mentions']: { ['m.mentions']: {
user_ids: mentionUsers user_ids: mentionUsers
} }
}
}); });
await delay(500); await delay(500);