From 7115c9e43528e8faeaed2ed4cad12e600264bea9 Mon Sep 17 00:00:00 2001 From: Gung Wah Date: Fri, 5 Mar 2021 14:26:32 +0800 Subject: [PATCH 1/3] [E2E TEST] Move threads test to another file --- e2e/tests/room/02-room.spec.js | 94 ----------------- e2e/tests/room/05-threads.spec.js | 170 ++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+), 94 deletions(-) create mode 100644 e2e/tests/room/05-threads.spec.js diff --git a/e2e/tests/room/02-room.spec.js b/e2e/tests/room/02-room.spec.js index a4720ba7a34..7e598a35a72 100644 --- a/e2e/tests/room/02-room.spec.js +++ b/e2e/tests/room/02-room.spec.js @@ -260,100 +260,6 @@ describe('Room screen', () => { }); }); - describe('Thread', async() => { - const thread = `${ data.random }thread`; - it('should create thread', async() => { - await mockMessage('thread'); - await element(by.label(thread)).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('Reply in Thread')).tap(); - await element(by.id('messagebox-input')).typeText('replied'); - await element(by.id('messagebox-send-message')).tap(); - await waitFor(element(by.id(`message-thread-button-${ thread }`))).toExist().withTimeout(5000); - await expect(element(by.id(`message-thread-button-${ thread }`))).toExist(); - }); - - it('should navigate to thread from button', async() => { - await element(by.id(`message-thread-button-${ thread }`)).tap(); - await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); - await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); - await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); - await tapBack(); - }); - - it('should toggle follow thread', async() => { - await element(by.id(`message-thread-button-${ thread }`)).tap(); - await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); - await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); - await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); - await element(by.id('room-view-header-unfollow')).tap(); - await waitFor(element(by.id('room-view-header-follow'))).toExist().withTimeout(60000); - await expect(element(by.id('room-view-header-follow'))).toExist(); - await element(by.id('room-view-header-follow')).tap(); - await waitFor(element(by.id('room-view-header-unfollow'))).toExist().withTimeout(60000); - await expect(element(by.id('room-view-header-unfollow'))).toExist(); - }); - - it('should send message in thread only', async() => { - const messageText = 'threadonly'; - await mockMessage(messageText); - await tapBack(); - await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); - await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); - await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( - await waitFor(element(by.label(`${ data.random }${ messageText }`)).atIndex(0)).toNotExist().withTimeout(2000); - }); - - it('should mark send to channel and show on main channel', async() => { - const messageText = 'sendToChannel'; - await element(by.id(`message-thread-button-${ thread }`)).tap(); - await element(by.id('messagebox-input')).atIndex(0).typeText(messageText); - await element(by.id('messagebox-send-to-channel')).tap(); - await element(by.id('messagebox-send-message')).tap(); - await tapBack(); - await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); - await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); - await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( - await waitFor(element(by.label(messageText)).atIndex(0)).toExist().withTimeout(2000); - }); - - it('should navigate to thread from thread name', async() => { - const messageText = 'navthreadname'; - await mockMessage('dummymessagebetweenthethread'); - await element(by.id(`message-thread-button-${ thread }`)).tap(); - await element(by.id('messagebox-input')).atIndex(0).typeText(messageText); - await element(by.id('messagebox-send-to-channel')).tap(); - await element(by.id('messagebox-send-message')).tap(); - await tapBack(); - await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); - await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); - await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( - - await element(by.id(`message-thread-replied-on-${ thread }`)).tap(); - await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); - await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); - await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); - await tapBack(); - }); - - it('should navigate to thread from threads view', async() => { - await waitFor(element(by.id('room-view-header-threads'))).toExist().withTimeout(1000); - await element(by.id('room-view-header-threads')).tap(); - await waitFor(element(by.id('thread-messages-view'))).toExist().withTimeout(5000); - await expect(element(by.id('thread-messages-view'))).toExist(); - await element(by.id(`thread-messages-view-${ thread }`)).atIndex(0).tap(); - await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); - await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); - await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); - await tapBack(); - await waitFor(element(by.id('thread-messages-view'))).toExist().withTimeout(5000); - await expect(element(by.id('thread-messages-view'))).toExist(); - await tapBack(); - }); - }); - // after(async() => { // await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); // await tapBack(); diff --git a/e2e/tests/room/05-threads.spec.js b/e2e/tests/room/05-threads.spec.js new file mode 100644 index 00000000000..44c5df4f8f9 --- /dev/null +++ b/e2e/tests/room/05-threads.spec.js @@ -0,0 +1,170 @@ +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'); + +async function navigateToRoom(roomName) { + await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); + await navigateToLogin(); + await login(data.users.regular.username, data.users.regular.password); + await searchRoom(`${ roomName }`); + await waitFor(element(by.id(`rooms-list-view-item-${ roomName }`))).toExist().withTimeout(60000); + await element(by.id(`rooms-list-view-item-${ roomName }`)).tap(); + await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); +} + +describe('Room screen', () => { + const mainRoom = data.groups.private.name; + + before(async() => { + await navigateToRoom(mainRoom); + }); + + describe('Render', async() => { + it('should have room screen', async() => { + await expect(element(by.id('room-view'))).toExist(); + await waitFor(element(by.id(`room-view-title-${ mainRoom }`))).toExist().withTimeout(5000); + }); + + // Render - Header + describe('Header', async() => { + it('should have actions button ', async() => { + await expect(element(by.id('room-view-header-actions'))).toExist(); + }); + + it('should have threads button ', async() => { + await expect(element(by.id('room-view-header-threads'))).toExist(); + }); + }); + + // Render - Messagebox + describe('Messagebox', async() => { + it('should have messagebox', async() => { + await expect(element(by.id('messagebox'))).toExist(); + }); + + it('should have open emoji button', async() => { + if (device.getPlatform() === 'android') { + await expect(element(by.id('messagebox-open-emoji'))).toExist(); + } + }); + + it('should have message input', async() => { + await expect(element(by.id('messagebox-input'))).toExist(); + }); + + it('should have audio button', async() => { + await expect(element(by.id('messagebox-send-audio'))).toExist(); + }); + + it('should have actions button', async() => { + await expect(element(by.id('messagebox-actions'))).toExist(); + }); + }); + }); + + describe('Usage', async() => { + describe('Thread', async() => { + const thread = `${ data.random }thread`; + it('should create thread', async() => { + await mockMessage('thread'); + await element(by.label(thread)).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('Reply in Thread')).tap(); + await element(by.id('messagebox-input')).typeText('replied'); + await element(by.id('messagebox-send-message')).tap(); + await waitFor(element(by.id(`message-thread-button-${ thread }`))).toExist().withTimeout(5000); + await expect(element(by.id(`message-thread-button-${ thread }`))).toExist(); + }); + + it('should navigate to thread from button', async() => { + await element(by.id(`message-thread-button-${ thread }`)).tap(); + await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); + await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); + await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); + await tapBack(); + }); + + it('should toggle follow thread', async() => { + await element(by.id(`message-thread-button-${ thread }`)).tap(); + await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); + await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); + await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); + await element(by.id('room-view-header-unfollow')).tap(); + await waitFor(element(by.id('room-view-header-follow'))).toExist().withTimeout(60000); + await expect(element(by.id('room-view-header-follow'))).toExist(); + await element(by.id('room-view-header-follow')).tap(); + await waitFor(element(by.id('room-view-header-unfollow'))).toExist().withTimeout(60000); + await expect(element(by.id('room-view-header-unfollow'))).toExist(); + }); + + it('should send message in thread only', async() => { + const messageText = 'threadonly'; + await mockMessage(messageText); + await tapBack(); + await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); + await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); + await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( + await waitFor(element(by.label(`${ data.random }${ messageText }`)).atIndex(0)).toNotExist().withTimeout(2000); + }); + + it('should mark send to channel and show on main channel', async() => { + const messageText = 'sendToChannel'; + await element(by.id(`message-thread-button-${ thread }`)).tap(); + await element(by.id('messagebox-input')).atIndex(0).typeText(messageText); + await element(by.id('messagebox-send-to-channel')).tap(); + await element(by.id('messagebox-send-message')).tap(); + await tapBack(); + await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); + await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); + await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( + await waitFor(element(by.label(messageText)).atIndex(0)).toExist().withTimeout(2000); + }); + + it('should navigate to thread from thread name', async() => { + const messageText = 'navthreadname'; + await mockMessage('dummymessagebetweenthethread'); + await dismissReviewNag() //TODO: Create a proper test for this elsewhere. + await element(by.id(`message-thread-button-${ thread }`)).tap(); + await element(by.id('messagebox-input')).atIndex(0).typeText(messageText); + await element(by.id('messagebox-send-to-channel')).tap(); + await element(by.id('messagebox-send-message')).tap(); + await tapBack(); + await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); + await waitFor(element(by.id('room-view-header-actions').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); + await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( + + await element(by.id(`message-thread-replied-on-${ thread }`)).tap(); + await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); + await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); + await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); + await tapBack(); + }); + + it('should navigate to thread from threads view', async() => { + await waitFor(element(by.id('room-view-header-threads'))).toExist().withTimeout(1000); + await element(by.id('room-view-header-threads')).tap(); + await waitFor(element(by.id('thread-messages-view'))).toExist().withTimeout(5000); + await expect(element(by.id('thread-messages-view'))).toExist(); + await element(by.id(`thread-messages-view-${ thread }`)).atIndex(0).tap(); + await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); + await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); + await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); + await tapBack(); + await waitFor(element(by.id('thread-messages-view'))).toExist().withTimeout(5000); + await expect(element(by.id('thread-messages-view'))).toExist(); + await tapBack(); + }); + }); + + // after(async() => { + // await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); + // await tapBack(); + // await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000); + // await expect(element(by.id('rooms-list-view'))).toExist(); + // }); + }); +}); From 98a7c77b33b8d07abb42e4f9d2cc5536d9fb02fb Mon Sep 17 00:00:00 2001 From: Gung Wah Date: Fri, 5 Mar 2021 14:31:46 +0800 Subject: [PATCH 2/3] changed descirbe title --- e2e/tests/room/05-threads.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/room/05-threads.spec.js b/e2e/tests/room/05-threads.spec.js index 44c5df4f8f9..fa9ee81dd8d 100644 --- a/e2e/tests/room/05-threads.spec.js +++ b/e2e/tests/room/05-threads.spec.js @@ -14,7 +14,7 @@ async function navigateToRoom(roomName) { await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); } -describe('Room screen', () => { +describe('Threads', () => { const mainRoom = data.groups.private.name; before(async() => { From c7a355c931df0e076c52bbb141acd4d1567d5081 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 1 Apr 2021 17:05:47 -0300 Subject: [PATCH 3/3] Rearrange files --- .../room/{05-createdmgroup.spec.js => 06-createdmgroup.spec.js} | 0 .../room/{06-markasunread.spec.js => 07-markasunread.spec.js} | 0 e2e/tests/room/{05-roominfo.spec.js => 08-roominfo.spec.js} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename e2e/tests/room/{05-createdmgroup.spec.js => 06-createdmgroup.spec.js} (100%) rename e2e/tests/room/{06-markasunread.spec.js => 07-markasunread.spec.js} (100%) rename e2e/tests/room/{05-roominfo.spec.js => 08-roominfo.spec.js} (100%) diff --git a/e2e/tests/room/05-createdmgroup.spec.js b/e2e/tests/room/06-createdmgroup.spec.js similarity index 100% rename from e2e/tests/room/05-createdmgroup.spec.js rename to e2e/tests/room/06-createdmgroup.spec.js diff --git a/e2e/tests/room/06-markasunread.spec.js b/e2e/tests/room/07-markasunread.spec.js similarity index 100% rename from e2e/tests/room/06-markasunread.spec.js rename to e2e/tests/room/07-markasunread.spec.js diff --git a/e2e/tests/room/05-roominfo.spec.js b/e2e/tests/room/08-roominfo.spec.js similarity index 100% rename from e2e/tests/room/05-roominfo.spec.js rename to e2e/tests/room/08-roominfo.spec.js