|
| 1 | +// eslint-disable-next-line import/no-unresolved |
| 2 | +import { $, browser, driver, expect, describe, beforeEach, it } from '@wdio/globals'; |
| 3 | + |
| 4 | +const TESTING_EMAIL = process.env.TESTING_EMAIL; |
| 5 | +const TESTING_PASSWORD = process.env.TESTING_PASSWORD; |
| 6 | + |
| 7 | +describe('Logout Flow', () => { |
| 8 | + const Login = async (email = TESTING_EMAIL, password = TESTING_PASSWORD) => { |
| 9 | + const loginLink = await $('android=new UiSelector().text("Log in")'); |
| 10 | + await loginLink.waitForDisplayed(); |
| 11 | + await loginLink.click(); |
| 12 | + |
| 13 | + const emailTitle = await $( |
| 14 | + 'android=new UiSelector().text("To get started, first enter your email, or @username")' |
| 15 | + ); |
| 16 | + await emailTitle.waitForDisplayed({ timeout: 5000 }); |
| 17 | + const emailInput = await $('~email-username-input'); |
| 18 | + await emailInput.waitForDisplayed({ timeout: 5000 }); |
| 19 | + await emailInput.setValue(email); |
| 20 | + |
| 21 | + const nextButton = await $('~login-next-button'); |
| 22 | + await nextButton.waitForDisplayed({ timeout: 5000 }); |
| 23 | + await nextButton.click(); |
| 24 | + |
| 25 | + const passwordTitle = await $('android=new UiSelector().text("Enter your password")'); |
| 26 | + await passwordTitle.waitForDisplayed({ timeout: 10000 }); |
| 27 | + const passwordInput = await $('~password-input'); |
| 28 | + await passwordInput.waitForDisplayed({ timeout: 5000 }); |
| 29 | + await passwordInput.setValue(password); |
| 30 | + |
| 31 | + const loginButton = await $('~login-button'); |
| 32 | + await loginButton.waitForDisplayed(); |
| 33 | + await loginButton.click(); |
| 34 | + const homeScreen = await $('android=new UiSelector().text("For You")'); |
| 35 | + await homeScreen.waitForDisplayed({ timeout: 15000 }); |
| 36 | + }; |
| 37 | + |
| 38 | + const openSidebar = async () => { |
| 39 | + await driver.execute('mobile: clickGesture', { |
| 40 | + x: 46, |
| 41 | + y: 156, |
| 42 | + }); |
| 43 | + }; |
| 44 | + |
| 45 | + const openAccountSwitcherDrawer = async () => { |
| 46 | + await driver.execute('mobile: clickGesture', { |
| 47 | + x: 838, |
| 48 | + y: 211, |
| 49 | + }); |
| 50 | + }; |
| 51 | + |
| 52 | + beforeEach(async () => { |
| 53 | + await browser.pause(500); |
| 54 | + await Login(); |
| 55 | + await openSidebar(); |
| 56 | + }); |
| 57 | + |
| 58 | + it('should log out successfully from sidebar', async () => { |
| 59 | + const logoutButton = await $('android=new UiSelector().text("Log out")'); |
| 60 | + await logoutButton.waitForDisplayed(); |
| 61 | + await logoutButton.click(); |
| 62 | + |
| 63 | + const startScreenTitle = await $( |
| 64 | + 'android=new UiSelector().text("See what\'s happening in the world right now.")' |
| 65 | + ); |
| 66 | + await startScreenTitle.waitForDisplayed(); |
| 67 | + await expect(startScreenTitle).toBeDisplayed(); |
| 68 | + }); |
| 69 | + |
| 70 | + it('should log out successfully from account switcher drawer', async () => { |
| 71 | + await browser.pause(500); |
| 72 | + await openAccountSwitcherDrawer(); |
| 73 | + |
| 74 | + const logoutButton = await $('android=new UiSelector().text("Log out from current account")'); |
| 75 | + await logoutButton.waitForDisplayed(); |
| 76 | + await logoutButton.click(); |
| 77 | + |
| 78 | + const startScreenTitle = await $( |
| 79 | + 'android=new UiSelector().text("See what\'s happening in the world right now.")' |
| 80 | + ); |
| 81 | + await startScreenTitle.waitForDisplayed(); |
| 82 | + await expect(startScreenTitle).toBeDisplayed(); |
| 83 | + }); |
| 84 | + |
| 85 | + it('should log out successfully from account information settings', async () => { |
| 86 | + const settingsSidebarItem = await $('android=new UiSelector().text("Settings and Privacy")'); |
| 87 | + await settingsSidebarItem.waitForDisplayed(); |
| 88 | + await settingsSidebarItem.click(); |
| 89 | + |
| 90 | + const accountSettings = await $('android=new UiSelector().text("Your Account")'); |
| 91 | + await accountSettings.waitForDisplayed(); |
| 92 | + await accountSettings.click(); |
| 93 | + |
| 94 | + const accountInfo = await $('android=new UiSelector().text("Account information")'); |
| 95 | + await accountInfo.waitForDisplayed(); |
| 96 | + await accountInfo.click(); |
| 97 | + |
| 98 | + const logoutButton = await $('android=new UiSelector().text("Log out")'); |
| 99 | + await logoutButton.waitForDisplayed(); |
| 100 | + await logoutButton.click(); |
| 101 | + |
| 102 | + const startScreenTitle = await $( |
| 103 | + 'android=new UiSelector().text("See what\'s happening in the world right now.")' |
| 104 | + ); |
| 105 | + await startScreenTitle.waitForDisplayed(); |
| 106 | + await expect(startScreenTitle).toBeDisplayed(); |
| 107 | + }); |
| 108 | + |
| 109 | + it('should not show start screen when side swiping and logged in', async () => { |
| 110 | + await driver.back(); |
| 111 | + await driver.back(); |
| 112 | + await driver.activateApp('com.raven.app'); |
| 113 | + |
| 114 | + const homeScreen = await $('android=new UiSelector().text("For You")'); |
| 115 | + await homeScreen.waitForDisplayed({ timeout: 20000 }); |
| 116 | + await expect(homeScreen).toBeDisplayed(); |
| 117 | + }); |
| 118 | +}); |
0 commit comments