From 1eaf4b802bfd251de2c086498227d400e8dde159 Mon Sep 17 00:00:00 2001 From: Gung Wah <41157464+kresnaputra@users.noreply.github.com> Date: Fri, 19 Mar 2021 00:52:47 +0800 Subject: [PATCH] [TESTS] Add e2e tests for mark message as unread (#2953) * [E2E TEST] Add e2e tests for mark message as unread * fixed test for draft message * change test name * move test to other file * Remove unnecessary tests * Rename file * Update jest tests Co-authored-by: Diego Mello --- .../__snapshots__/Storyshots.test.js.snap | 186 ++++++++++++++++-- e2e/helpers/data_setup.js | 1 - e2e/tests/room/02-room.spec.js | 2 +- e2e/tests/room/06-markasunread.spec.js | 44 +++++ 4 files changed, 219 insertions(+), 14 deletions(-) create mode 100644 e2e/tests/room/06-markasunread.spec.js diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 84c23537a..12a5b2600 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -40818,17 +40818,44 @@ exports[`Storyshots Message list message 1`] = ` Object { "backgroundColor": "transparent", "fontFamily": "System", - "fontSize": 14, + "fontSize": 16, "fontWeight": "400", "textAlign": "left", }, + undefined, Object { "color": "#2f343d", }, ] } > - Value 1 + + Value 1 + - Value 2 + + Value 2 + @@ -40965,17 +41019,44 @@ exports[`Storyshots Message list message 1`] = ` Object { "backgroundColor": "transparent", "fontFamily": "System", - "fontSize": 14, + "fontSize": 16, "fontWeight": "400", "textAlign": "left", }, + undefined, Object { "color": "#2f343d", }, ] } > - Value 1 + + Value 1 + - Value 2 + + Value 2 + @@ -41112,17 +41220,44 @@ exports[`Storyshots Message list message 1`] = ` Object { "backgroundColor": "transparent", "fontFamily": "System", - "fontSize": 14, + "fontSize": 16, "fontWeight": "400", "textAlign": "left", }, + undefined, Object { "color": "#2f343d", }, ] } > - Value 1 + + Value 1 + - Value 2 + + Value 2 + diff --git a/e2e/helpers/data_setup.js b/e2e/helpers/data_setup.js index 13f1e73d2..8f95f0b78 100644 --- a/e2e/helpers/data_setup.js +++ b/e2e/helpers/data_setup.js @@ -97,7 +97,6 @@ const sendMessage = async (user, groupname, msg) => { await login(user.username, user.password); await rocketchat.post('chat.postMessage', { channel: `#${groupname}`, msg }); } catch (infoError) { - console.log(JSON.stringify(createError)) console.log(JSON.stringify(infoError)) throw "Failed to find or create private group" } diff --git a/e2e/tests/room/02-room.spec.js b/e2e/tests/room/02-room.spec.js index d4090d6c9..8c39e9bc2 100644 --- a/e2e/tests/room/02-room.spec.js +++ b/e2e/tests/room/02-room.spec.js @@ -2,7 +2,7 @@ const { device, expect, element, by, waitFor } = require('detox'); const data = require('../../data'); -const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom, starMessage, pinMessage, dismissReviewNag, tryTapping } = require('../../helpers/app'); +const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom, starMessage, pinMessage, dismissReviewNag, tryTapping, logout } = require('../../helpers/app'); async function navigateToRoom(roomName) { await searchRoom(`${ roomName }`); diff --git a/e2e/tests/room/06-markasunread.spec.js b/e2e/tests/room/06-markasunread.spec.js new file mode 100644 index 000000000..0247e039d --- /dev/null +++ b/e2e/tests/room/06-markasunread.spec.js @@ -0,0 +1,44 @@ +const { + device, expect, element, by, waitFor +} = require('detox'); +const data = require('../../data'); +const { navigateToLogin, login, mockMessage, tapBack, searchRoom, logout } = require('../../helpers/app'); + +async function navigateToRoom(user) { + await searchRoom(`${ user }`); + await waitFor(element(by.id(`rooms-list-view-item-${ user }`))).toExist().withTimeout(60000); + await element(by.id(`rooms-list-view-item-${ user }`)).tap(); + await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); +} + +describe('Mark as unread', () => { + const user = data.users.alternate.username + + before(async() => { + await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); + await navigateToLogin(); + await login(data.users.regular.username, data.users.regular.password); + await navigateToRoom(user); + }); + + describe('Usage', async() => { + describe('Mark message as unread', async() => { + it('should mark message as unread', async() => { + await mockMessage('message') + await expect(element(by.label(`${ data.random }message`)).atIndex(0)).toExist(); + await tapBack(); + await logout(); + await navigateToLogin(); + await login(data.users.alternate.username, data.users.alternate.password); + await navigateToRoom(data.users.regular.username); + await element(by.label(`${ data.random }message`)).atIndex(0).longPress(); + await expect(element(by.id('action-sheet'))).toExist(); + await expect(element(by.id('action-sheet-handle'))).toBeVisible(); + await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5); + await element(by.label('Mark Unread')).tap(); + await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(5000); + await expect(element(by.id(`rooms-list-view-item-${data.users.regular.username}`))).toExist(); + }); + }); + }); +});