diff options
author | Gabe Kangas <gabek@real-ity.com> | 2022-01-18 19:56:35 -0800 |
---|---|---|
committer | Gabe Kangas <gabek@real-ity.com> | 2022-01-18 19:56:35 -0800 |
commit | 2e1fbe28af9d252b3b4c6c26ec7e2c898a5e29ac (patch) | |
tree | 025ab6cb4d8a3735a0bdc1a0c9c17cb891d65994 | |
parent | 627169fc73319481b60872830d120954e0a28896 (diff) |
Tweak tests
-rw-r--r-- | test/automated/api/chat.test.js | 4 | ||||
-rw-r--r-- | test/automated/api/chatmoderation.test.js | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/test/automated/api/chat.test.js b/test/automated/api/chat.test.js index 3484bed0d..244d0ecea 100644 --- a/test/automated/api/chat.test.js +++ b/test/automated/api/chat.test.js @@ -27,7 +27,7 @@ test('can fetch chat messages', async (done) => { .auth('admin', 'abc123') .expect(200); - const expectedBody = `${testMessage.body}`; + const expectedBody = testMessage.body; const message = res.body.filter(function (msg) { return msg.body === expectedBody; })[0]; @@ -52,7 +52,7 @@ test('can derive display name from user header', async (done) => { test('can overwrite user header derived display name with body', async (done) => { const res = await request .post('/api/chat/register') - .send({displayName: 'TestUserChat'}) + .send({ displayName: 'TestUserChat' }) .set('X-Forwarded-User', 'test-user') .expect(200); diff --git a/test/automated/api/chatmoderation.test.js b/test/automated/api/chatmoderation.test.js index b8f19f9f4..84fc83a71 100644 --- a/test/automated/api/chatmoderation.test.js +++ b/test/automated/api/chatmoderation.test.js @@ -35,12 +35,13 @@ test('verify we can make API call to mark message as hidden', async (done) => { ); // Verify the visibility change comes through the websocket - ws.on('message', function incoming(message) { + ws.on('message', async function incoming(message) { const messages = message.split('\n'); - messages.forEach(function (message) { + messages.forEach(async function (message) { const event = JSON.parse(message); if (event.type === 'VISIBILITY-UPDATE') { + await new Promise((r) => setTimeout(r, 2000)); done(); ws.close(); } @@ -91,7 +92,7 @@ test('can send a message after established user mode is enabled', async (done) = sendChatMessage(establishedUserFailedChatMessage, accessToken, done); }); -test('verify message is not in the chat feed', async (done) => { +test('verify rejected message is not in the chat feed', async (done) => { const res = await request .get('/api/admin/chat/messages') .expect(200) |