diff options
author | Gabe Kangas <gabek@real-ity.com> | 2022-02-02 21:41:56 -0800 |
---|---|---|
committer | Gabe Kangas <gabek@real-ity.com> | 2022-02-02 22:03:47 -0800 |
commit | 659bead2910e4ffff5a00e76594ace8284141151 (patch) | |
tree | 2cf961331e73840e11acf027c084c238015d948c | |
parent | 228c09b7e19def262d1053b308812838692c69ae (diff) |
Update testgek/chat-established-user-mode
-rw-r--r-- | test/automated/api/chat.test.js | 12 | ||||
-rw-r--r-- | test/automated/api/chatmoderation.test.js | 9 |
2 files changed, 16 insertions, 5 deletions
diff --git a/test/automated/api/chat.test.js b/test/automated/api/chat.test.js index 244d0ecea..fed2ffcdd 100644 --- a/test/automated/api/chat.test.js +++ b/test/automated/api/chat.test.js @@ -6,6 +6,7 @@ const registerChat = require('./lib/chat').registerChat; const sendChatMessage = require('./lib/chat').sendChatMessage; var userDisplayName; +var messageId; const message = Math.floor(Math.random() * 100) + ' test 123'; const testMessage = { @@ -19,6 +20,15 @@ test('can send a chat message', async (done) => { userDisplayName = registration.displayName; sendChatMessage(testMessage, accessToken, done); + await new Promise((r) => setTimeout(r, 2000)); + + const res = await request + .get('/api/admin/chat/messages') + .auth('admin', 'abc123') + .expect(200); + + const message = res.body[0]; + messageId = message.id; }); test('can fetch chat messages', async (done) => { @@ -29,7 +39,7 @@ test('can fetch chat messages', async (done) => { const expectedBody = testMessage.body; const message = res.body.filter(function (msg) { - return msg.body === expectedBody; + return msg.id === messageId; })[0]; expect(message.body).toBe(expectedBody); diff --git a/test/automated/api/chatmoderation.test.js b/test/automated/api/chatmoderation.test.js index 48585408c..953f03194 100644 --- a/test/automated/api/chatmoderation.test.js +++ b/test/automated/api/chatmoderation.test.js @@ -12,6 +12,8 @@ const testVisibilityMessage = { type: 'CHAT', }; +var messageId; + const establishedUserFailedChatMessage = { body: 'this message should fail to send ' + Math.floor(Math.random() * 100), type: 'CHAT', @@ -41,9 +43,8 @@ test('verify we can make API call to mark message as hidden', async (done) => { const event = JSON.parse(message); if (event.type === 'VISIBILITY-UPDATE') { - await new Promise((r) => setTimeout(r, 2000)); - done(); ws.close(); + done(); } }); }); @@ -54,7 +55,7 @@ test('verify we can make API call to mark message as hidden', async (done) => { .expect(200); const message = res.body[0]; - const messageId = message.id; + messageId = message.id; await request .post('/api/admin/chat/updatemessagevisibility') .auth('admin', 'abc123') @@ -71,7 +72,7 @@ test('verify message has become hidden', async (done) => { .auth('admin', 'abc123'); const message = res.body.filter((obj) => { - return obj.body === testVisibilityMessage.body; + return obj.id === messageId; }); expect(message.length).toBe(1); expect(message[0].hiddenAt).toBeTruthy(); |