From 715cc1eab73dd65c97cb7ca5311f6ac792f576ce Mon Sep 17 00:00:00 2001 From: Gung Wah <41157464+kresnaputra@users.noreply.github.com> Date: Fri, 19 Mar 2021 01:02:58 +0800 Subject: [PATCH] [TESTS] Add E2E tests to delete server (#2954) * [E2E TEST] Delete server * fixed test for delete server * fix tests * minor changes * Rename file Co-authored-by: Diego Mello --- e2e/tests/assorted/10-deleteserver.spec.js | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 e2e/tests/assorted/10-deleteserver.spec.js diff --git a/e2e/tests/assorted/10-deleteserver.spec.js b/e2e/tests/assorted/10-deleteserver.spec.js new file mode 100644 index 000000000..7d5d53e74 --- /dev/null +++ b/e2e/tests/assorted/10-deleteserver.spec.js @@ -0,0 +1,59 @@ +const { + device, element, by, waitFor +} = require('detox'); +const data = require('../../data'); +const { sleep, navigateToLogin, login } = require('../../helpers/app'); + +const checkServer = async(server) => { + const label = `Connected to ${ server }`; + await element(by.id('rooms-list-view-sidebar')).tap(); + await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000); + await waitFor(element(by.label(label))).toBeVisible().withTimeout(10000); + await element(by.id('sidebar-close-drawer')).tap(); +} + +describe('Delete server', () => { + before(async() => { + await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); + await navigateToLogin(); + await login(data.users.regular.username, data.users.regular.password); + }); + + it('should be logged in main server', async() => { + await checkServer(data.server); + }) + + it('should add server', async() => { + await sleep(5000); + await element(by.id('rooms-list-header-server-dropdown-button')).tap(); + await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000); + await element(by.id('rooms-list-header-server-add')).tap(); + + await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(10000); + await element(by.id('new-server-view-input')).replaceText(data.alternateServer); + await element(by.id('new-server-view-button')).tap(); + await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000); + await element(by.id('workspace-view-register')).tap(); + await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000); + + // Register new user + await element(by.id('register-view-name')).replaceText(data.registeringUser.username); + await element(by.id('register-view-username')).replaceText(data.registeringUser.username); + await element(by.id('register-view-email')).replaceText(data.registeringUser.email); + await element(by.id('register-view-password')).replaceText(data.registeringUser.password); + await element(by.id('register-view-submit')).tap(); + await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000); + + await checkServer(data.alternateServer); + }); + + it('should delete server', async() => { + await element(by.id('rooms-list-header-server-dropdown-button')).tap(); + await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000); + await element(by.id(`rooms-list-header-server-${ data.server }`)).longPress(1500); + await element(by.label('Delete').and(by.type('_UIAlertControllerActionView'))).tap(); + await element(by.id('rooms-list-header-server-dropdown-button')).tap(); + await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000); + await waitFor(element(by.id(`rooms-list-header-server-${ data.server }`))).toBeNotVisible().withTimeout(10000); + }); +});