From 2558715069f69f1076c2eab8074abb64c1d25f3c Mon Sep 17 00:00:00 2001 From: acladima <76042001+acladima@users.noreply.github.com> Date: Thu, 7 Oct 2021 23:50:52 +0300 Subject: [PATCH 1/4] first commit for appium --- .gitignore | 5 + appium/README.md | 12 ++ appium/babel.config.js | 9 ++ appium/config/wdio.ios.app.conf.js | 30 ++++ appium/config/wdio.shared.conf.js | 45 ++++++ appium/package.json | 39 +++++ appium/tests/constants.ts | 2 + appium/tests/data/index.ts | 10 ++ appium/tests/helpers/ElementHelper.ts | 49 ++++++ appium/tests/screenobjects/all-screens.ts | 13 ++ appium/tests/screenobjects/base.screen.ts | 22 +++ .../tests/screenobjects/create-key.screen.ts | 53 +++++++ appium/tests/screenobjects/email.screen.ts | 45 ++++++ appium/tests/screenobjects/inbox.screen.ts | 22 +++ appium/tests/screenobjects/menu-bar.screen.ts | 45 ++++++ appium/tests/screenobjects/splash.screen.ts | 139 ++++++++++++++++++ appium/tests/specs/inbox/inbox.spec.ts | 29 ++++ appium/tests/specs/login/login.spec.ts | 28 ++++ appium/tsconfig.json | 12 ++ 19 files changed, 609 insertions(+) create mode 100644 appium/README.md create mode 100644 appium/babel.config.js create mode 100644 appium/config/wdio.ios.app.conf.js create mode 100644 appium/config/wdio.shared.conf.js create mode 100644 appium/package.json create mode 100644 appium/tests/constants.ts create mode 100644 appium/tests/data/index.ts create mode 100644 appium/tests/helpers/ElementHelper.ts create mode 100644 appium/tests/screenobjects/all-screens.ts create mode 100644 appium/tests/screenobjects/base.screen.ts create mode 100644 appium/tests/screenobjects/create-key.screen.ts create mode 100644 appium/tests/screenobjects/email.screen.ts create mode 100644 appium/tests/screenobjects/inbox.screen.ts create mode 100644 appium/tests/screenobjects/menu-bar.screen.ts create mode 100644 appium/tests/screenobjects/splash.screen.ts create mode 100644 appium/tests/specs/inbox/inbox.spec.ts create mode 100644 appium/tests/specs/login/login.spec.ts create mode 100644 appium/tsconfig.json diff --git a/.gitignore b/.gitignore index 678fbe434..24f4d656b 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,8 @@ fastlane/test_output fastlane/README.md test-ci-secrets.json + +# appium +appium/node_modules +appium/package-lock.json +appium/tmp diff --git a/appium/README.md b/appium/README.md new file mode 100644 index 000000000..d29fc63ed --- /dev/null +++ b/appium/README.md @@ -0,0 +1,12 @@ +# appium project + +Project to run Appium tests together with WebdriverIO for: + +- iOS/Android Native Apps + +## Before running tests, please create a `./apps` directory, download the app and move the app file into that directory + +## Install dependencies with `npm i` + +## Run smoke tests for iOS with `npm run ios.smoke`, all tests with tag #smoke will be included + diff --git a/appium/babel.config.js b/appium/babel.config.js new file mode 100644 index 000000000..b1ece97bd --- /dev/null +++ b/appium/babel.config.js @@ -0,0 +1,9 @@ +module.exports = { + presets: [ + [ '@babel/preset-env', { + targets: { + node: 'current', + }, + } ], + ] +}; diff --git a/appium/config/wdio.ios.app.conf.js b/appium/config/wdio.ios.app.conf.js new file mode 100644 index 000000000..bb83f41ec --- /dev/null +++ b/appium/config/wdio.ios.app.conf.js @@ -0,0 +1,30 @@ +const { join } = require('path'); +const { config } = require('./wdio.shared.conf'); + +config.suites = { + all: [ + './tests/specs/**/*.spec.ts' + ], + smoke: [ + './tests/specs/inbox/inbox.spec.ts', + ] +}; + +config.capabilities = [ + { + platformName: 'iOS', + iosInstallPause: 5000, + deviceName: process.env.DEVICE_MODEL || 'iPhone 11 Pro Max', + platformVersion: '14.5', + automationName: 'XCUITest', + app: join(process.cwd(), './apps/FlowCrypt.app'), + newCommandTimeout: 10000, + wdaLaunchTimeout: 300000, + wdaConnectionTimeout: 600000, + wdaStartupRetries: 4, + wdaStartupRetryInterval: 120000, + resetOnSessionStartOnly: true + }, +]; + +exports.config = config; diff --git a/appium/config/wdio.shared.conf.js b/appium/config/wdio.shared.conf.js new file mode 100644 index 000000000..011296b3e --- /dev/null +++ b/appium/config/wdio.shared.conf.js @@ -0,0 +1,45 @@ +const { join } = require('path'); + +exports.config = { + + runner: 'local', + framework: 'jasmine', + jasmineNodeOpts: { + defaultTimeoutInterval: 300000, + requires: ['ts-node/register', 'tsconfig-paths/register'] + }, + sync: true, + logLevel: 'silent', + deprecationWarnings: true, + bail: 0, + waitforTimeout: 15000, + connectionRetryTimeout: 90000, + connectionRetryCount: 3, + maxInstancesPerCapability: 1, + reporters: ['spec', + ['allure', { + outputDir: './tmp', + disableWebdriverStepsReporting: true, + disableWebdriverScreenshotsReporting: false, + }] + ], + services: [ + ['appium', { + command : 'appium', + logPath : join(process.cwd(), './tmp') + }] + ], + port: 4723, + path: '/wd/hub', + specFileRetries: 1, + specFileRetriesDeferred: false, + + afterTest: function (test, context, { error, result, duration, passed, retries }) { + if (error) { + const timestampNow = new Date().getTime().toString(); + const path = process.env.BITRISE_DEPLOY_DIR || join(process.cwd(), './tmp'); + driver.saveScreenshot(`${path}/${timestampNow}.png`); + console.log("Screenshot of failed test was saved to " + path) + } + } +}; diff --git a/appium/package.json b/appium/package.json new file mode 100644 index 000000000..fb6b85d07 --- /dev/null +++ b/appium/package.json @@ -0,0 +1,39 @@ +{ + "name": "flowcrypt-appium", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "ios.smoke": "./node_modules/.bin/wdio ./config/wdio.ios.app.conf.js --suite smoke" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "@babel/cli": "^7.10.4", + "@babel/core": "^7.10.4", + "@babel/preset-env": "^7.10.4", + "@babel/register": "^7.10.4", + "@babel/traverse": "^7.10.4", + "@babel/types": "^7.10.4", + "@wdio/allure-reporter": "6.10.6", + "@wdio/appium-service": "6.10.11", + "@wdio/cli": "6.10.11", + "@wdio/jasmine-framework": "6.10.11", + "@wdio/local-runner": "6.10.13", + "@wdio/spec-reporter": "6.10.6", + "@wdio/sync": "^6.1.14", + "babel-eslint": "^10.1.0", + "downloads-folder": "^3.0.1", + "eslint-config-standard": "^16.0.1", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-wdio": "^6.6.0", + "moment": "^2.29.1", + "node-fetch": "^2.6.1", + "request": "^2.88.2", + "ts-node": "^9.1.1", + "typescript": "^4.1.3", + "webdriverio": "6.10.11" + } +} diff --git a/appium/tests/constants.ts b/appium/tests/constants.ts new file mode 100644 index 000000000..0a622d78c --- /dev/null +++ b/appium/tests/constants.ts @@ -0,0 +1,2 @@ +export const DEFAULT_TIMEOUT = 15000; + diff --git a/appium/tests/data/index.ts b/appium/tests/data/index.ts new file mode 100644 index 000000000..36d2ea242 --- /dev/null +++ b/appium/tests/data/index.ts @@ -0,0 +1,10 @@ +export const CommonData = { + account: { + email: 'e2e.enterprise.test@flowcrypt.com', + password: 'd874k3bd74', + passPhrase: 'London is the capital of Great Britain' + }, + sender: { + email: 'dmitry@flowcrypt.com' + } +}; diff --git a/appium/tests/helpers/ElementHelper.ts b/appium/tests/helpers/ElementHelper.ts new file mode 100644 index 000000000..405e4b478 --- /dev/null +++ b/appium/tests/helpers/ElementHelper.ts @@ -0,0 +1,49 @@ +import {DEFAULT_TIMEOUT} from "../constants"; + +class ElementHelper { + + /** + * returns true or false for element visibility + */ + static elementDisplayed(element): boolean { + return element.isExisting(); + } + + static waitElementVisible(element, timeout: number = DEFAULT_TIMEOUT) { + try { + element.waitForDisplayed({timeout: timeout}); + } catch (error) { + throw new Error(`Element isn't visible after ${timeout} seconds. Error: ${error}`); + } + } + + static waitElementInvisible(element, timeout: number = DEFAULT_TIMEOUT) { + try { + element.waitForDisplayed({timeout: timeout, reverse: true}); + } catch (error) { + throw new Error(`Element still visible after ${timeout} seconds. Error: ${error}`); + } + } + + static staticText(label: string) { + const selector = `**/XCUIElementTypeStaticText[\`label == "${label}"\`]`; + return $(`-ios class chain:${selector}`); + } + + static staticTextContains(label: string) { + const selector = `**/XCUIElementTypeStaticText[\`label CONTAINS "${label}"\`]`; + return $(`-ios class chain:${selector}`); + } + + static clickStaticText (label: string) { + this.waitElementVisible(this.staticText(label)); + this.staticText(label).click(); + } + + static doubleClick(element) { + this.waitElementVisible(element); + element.doubleClick(); + } +} + +export default ElementHelper; diff --git a/appium/tests/screenobjects/all-screens.ts b/appium/tests/screenobjects/all-screens.ts new file mode 100644 index 000000000..c7f6b4550 --- /dev/null +++ b/appium/tests/screenobjects/all-screens.ts @@ -0,0 +1,13 @@ +import SplashScreen from './splash.screen'; +import CreateKeyScreen from './create-key.screen'; +import InboxScreen from './inbox.screen'; +import MenuBarScreen from './menu-bar.screen'; +import EmailScreen from './email.screen' + +export { + SplashScreen, + CreateKeyScreen, + InboxScreen, + MenuBarScreen, + EmailScreen +}; diff --git a/appium/tests/screenobjects/base.screen.ts b/appium/tests/screenobjects/base.screen.ts new file mode 100644 index 000000000..d2a178bff --- /dev/null +++ b/appium/tests/screenobjects/base.screen.ts @@ -0,0 +1,22 @@ +import { DEFAULT_TIMEOUT } from '../constants'; + +export default class BaseScreen { + + locator: string; + constructor (selector: string) { + this.locator = selector; + } + + /** + * Wait for screen to be visible + * + * @param {boolean} isShown + * @return {boolean} + */ + waitForScreen (isShown: boolean = true) { + return $(this.locator).waitForDisplayed({ + timeout: DEFAULT_TIMEOUT, + reverse: !isShown, + }); + } +} diff --git a/appium/tests/screenobjects/create-key.screen.ts b/appium/tests/screenobjects/create-key.screen.ts new file mode 100644 index 000000000..e7c41e576 --- /dev/null +++ b/appium/tests/screenobjects/create-key.screen.ts @@ -0,0 +1,53 @@ +import BaseScreen from './base.screen'; +import commonData from '../data/index'; + +const SELECTORS = { + SET_PASS_PHRASE_BUTTON: '~Set pass phrase', + ENTER_YOUR_PASS_PHRASE_FIELD: '-ios class chain:**/XCUIElementTypeSecureTextField[`value == "Enter your pass phrase"`]', + OK_BUTTON: '~Ok', + CONFIRM_PASS_PHRASE_FIELD: '~textField', +}; + +class CreateKeyScreen extends BaseScreen { + constructor () { + super(SELECTORS.SET_PASS_PHRASE_BUTTON); + } + + get setPassPhraseButton () { + return $(SELECTORS.SET_PASS_PHRASE_BUTTON); + } + + get enterPassPhraseField () { + return $(SELECTORS.ENTER_YOUR_PASS_PHRASE_FIELD); + } + + get okButton () { + return $(SELECTORS.OK_BUTTON) + } + + get confirmPassPhraseField () { + return $(SELECTORS.CONFIRM_PASS_PHRASE_FIELD) + } + + fillPassPhrase (passPhrase: string) { + this.enterPassPhraseField.setValue(passPhrase); + } + + clickSetPassPhraseBtn () { + this.setPassPhraseButton.click(); + } + + confirmPassPhrase (passPhrase: string) { + this.confirmPassPhraseField.click(); + this.confirmPassPhraseField.setValue(passPhrase); + this.okButton.click(); + } + + setPassPhrase(text: string = commonData.account.passPhrase) { + this.fillPassPhrase(text); + this.clickSetPassPhraseBtn(); + this.confirmPassPhrase(text); + } +} + +export default new CreateKeyScreen(); diff --git a/appium/tests/screenobjects/email.screen.ts b/appium/tests/screenobjects/email.screen.ts new file mode 100644 index 000000000..b79102b7a --- /dev/null +++ b/appium/tests/screenobjects/email.screen.ts @@ -0,0 +1,45 @@ +import BaseScreen from './base.screen'; + +const SELECTORS = { + BACK_BTN: '~arrow left c' +}; + +const { join } = require('path'); + +class EmailScreen extends BaseScreen { + constructor () { + super(SELECTORS.BACK_BTN); + } + + get backButton() { + return $(SELECTORS.BACK_BTN) + } + + checkEmailAddress (email) { + const selector = `~${email}`; + $(selector).waitForDisplayed(); + } + + checkEmailSubject (subject) { + const selector = `~${subject}`; + $(selector).waitForDisplayed(); + } + + checkEmailText (text) { + const selector = `~${text}`; + $(selector).waitForDisplayed(); + } + + checkOpenedEmail (email, subject, text) { + this.backButton.waitForDisplayed(); + this.checkEmailAddress(email); + this.checkEmailSubject(subject); + this.checkEmailText(text); + } + + clickBackButton () { + this.backButton.click(); + } +} + +export default new EmailScreen(); diff --git a/appium/tests/screenobjects/inbox.screen.ts b/appium/tests/screenobjects/inbox.screen.ts new file mode 100644 index 000000000..cf71c829d --- /dev/null +++ b/appium/tests/screenobjects/inbox.screen.ts @@ -0,0 +1,22 @@ +import BaseScreen from './base.screen'; + +const SELECTORS = { + ENTER_YOUR_PASS_PHRASE_FIELD: '-ios class chain:**/XCUIElementTypeSecureTextField[`value == "Enter your pass phrase"`]', + OK_BUTTON: '~Ok', + CONFIRM_PASS_PHRASE_FIELD: '~textField', + +}; + +class InboxScreen extends BaseScreen { + constructor () { + super(SELECTORS.CONFIRM_PASS_PHRASE_FIELD); + } + clickOnUserEmail (email) { + const selector = `~${email}`; + $(selector).click(); + } + + +} + +export default new InboxScreen(); diff --git a/appium/tests/screenobjects/menu-bar.screen.ts b/appium/tests/screenobjects/menu-bar.screen.ts new file mode 100644 index 000000000..11f524845 --- /dev/null +++ b/appium/tests/screenobjects/menu-bar.screen.ts @@ -0,0 +1,45 @@ +import BaseScreen from './base.screen'; + +const SELECTORS = { + MENU_ICON: '~menu icn', + LOGOUT_BTN: '~Log out', + SETTINGS_BTN: '~Settings' +}; + +class MenuBarScreen extends BaseScreen { + constructor () { + super(SELECTORS.MENU_ICON); + } + + get menuIcon () { + return $(SELECTORS.MENU_ICON); + } + + get logoutButton () { + return $(SELECTORS.LOGOUT_BTN); + } + + get settingsButton () { + return $(SELECTORS.SETTINGS_BTN) + } + + clickMenuIcon () { + this.menuIcon.click() + } + + checkUserEmail (email) { + const selector = `~${email}`; + $(selector).waitForDisplayed(); + } + + checkMenuBar () { + expect(this.logoutButton).toBeDisplayed(); + expect(this.settingsButton).toBeDisplayed(); + } + + clickLogout () { + this.logoutButton.click(); + } +} + +export default new MenuBarScreen(); diff --git a/appium/tests/screenobjects/splash.screen.ts b/appium/tests/screenobjects/splash.screen.ts new file mode 100644 index 000000000..48b0c113d --- /dev/null +++ b/appium/tests/screenobjects/splash.screen.ts @@ -0,0 +1,139 @@ +import BaseScreen from './base.screen'; + +const SELECTORS = { + PRIVACY_TAB: '~privacy', + TERMS_TAB: '~terms', + SECURITY_TAB: '~security', + CONTINUE_WITH_GOOGLE_BTN: '~Continue with Gmail', + CONTINUE_WITH_OUTLOOK_BTN: '~Continue with Outlook', + OTHER_EMAIL_PROVIDER_BTN: '~Other email provider', + CONTINUE_BTN: '~Continue', + CANCEL_BTN: '~Cancel', + LOGIN_FIELD: '~Email or phone', + NEXT_BTN: '-ios class chain:**/XCUIElementTypeButton[`label == "Next"`][1]', + PASSWORD_FIELD: '~Enter your password', + DONE_BTN: '~Done', + LANGUAGE_DROPDOWN: '-ios class chain:**/XCUIElementTypeOther[`label == "content information"`]/XCUIElementTypeOther[1]', +}; + +class SplashScreen extends BaseScreen { + constructor () { + super(SELECTORS.PRIVACY_TAB); + } + + get privacyTab () { + return $(SELECTORS.PRIVACY_TAB); + } + + get termsTab () { + return $(SELECTORS.TERMS_TAB); + } + + get securityTab () { + return $(SELECTORS.SECURITY_TAB); + } + + get continueWithGmailBtn () { + return $(SELECTORS.CONTINUE_WITH_GOOGLE_BTN); + } + + get continueWithOutlookBtn () { + return $(SELECTORS.CONTINUE_WITH_OUTLOOK_BTN); + } + + get otherEmailProviderButton () { + return $(SELECTORS.OTHER_EMAIL_PROVIDER_BTN); + } + + get continueButton () { + return $(SELECTORS.CONTINUE_BTN); + } + + get cancelButton () { + return $(SELECTORS.CANCEL_BTN); + } + + get loginField () { + return $(SELECTORS.LOGIN_FIELD); + } + + get passwordField () { + return $(SELECTORS.PASSWORD_FIELD); + } + + get nextButton () { + return $(SELECTORS.NEXT_BTN); + } + + get doneButton () { + return $(SELECTORS.DONE_BTN) + } + + get languageDropdown () { + return $(SELECTORS.LANGUAGE_DROPDOWN) + } + + checkLoginPage () { + expect(this.privacyTab).toBeDisplayed(); + expect(this.termsTab).toBeDisplayed(); + expect(this.securityTab).toBeDisplayed(); + expect(this.continueWithGmailBtn).toBeDisplayed(); + expect(this.continueWithOutlookBtn).toBeDisplayed(); + expect(this.otherEmailProviderButton).toBeDisplayed(); + } + + clickContinueWithGmail () { + this.continueWithGmailBtn.click(); + } + + clickContinueBtn () { + expect(this.continueButton).toBeDisplayed(); + expect(this.cancelButton).toBeDisplayed(); + this.continueButton.click(); + } + + changeLanguage (language: string = '‪English (United States)‬') { + this.languageDropdown.click(); + const selector = `~${language}`; + $(selector).waitForDisplayed(); + $(selector).click(); + } + + fillEmail (email: string) { + this.loginField.click(); + this.loginField.setValue(email); + this.doneButton.click(); + } + + clickNextBtn () { + this.nextButton.click(); + } + + fillPassword(password: string) { + this.passwordField.click(); + this.passwordField.setValue(password); + this.doneButton.click(); + } + + gmailLogin (email: string, password: string) { + const emailSelector = `-ios class chain:**/XCUIElementTypeStaticText[\`label == "${email}"\`]`; + if($(emailSelector).isDisplayed()) { + $(emailSelector).click(); + } else { + this.fillEmail(email); + this.clickNextBtn(); + this.fillPassword(password); + this.clickNextBtn(); + } + } + + login(email: string, password: string) { + driver.launchApp(); + this.clickContinueWithGmail(); + this.clickContinueBtn(); + this.changeLanguage(); + this.gmailLogin(email, password); + } +} + +export default new SplashScreen(); diff --git a/appium/tests/specs/inbox/inbox.spec.ts b/appium/tests/specs/inbox/inbox.spec.ts new file mode 100644 index 000000000..57dbe3492 --- /dev/null +++ b/appium/tests/specs/inbox/inbox.spec.ts @@ -0,0 +1,29 @@ + +import { + SplashScreen, + CreateKeyScreen, + InboxScreen, + EmailScreen +} from '../../screenobjects/all-screens'; + +import commonData from '../../data/index'; + +describe('INBOX: ', () => { + + const email = commonData.account.email; + const pass = commonData.account.password; + const passPhrase = commonData.account.passPhrase; + + it('user is able to view text email', () => { + + const senderEmail = commonData.sender; + const emailSubject = 'Test 1'; + const emailText = 'Test email'; + + SplashScreen.login(email, pass); + CreateKeyScreen.setPassPhrase(passPhrase); + + InboxScreen.clickOnUserEmail(senderEmail); + EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); + }); +}); diff --git a/appium/tests/specs/login/login.spec.ts b/appium/tests/specs/login/login.spec.ts new file mode 100644 index 000000000..67d66a2df --- /dev/null +++ b/appium/tests/specs/login/login.spec.ts @@ -0,0 +1,28 @@ + +import { + SplashScreen, + CreateKeyScreen, + MenuBarScreen +} from '../../screenobjects/all-screens'; + +import commonData from '../../data/index'; + +describe('LOGIN: ', () => { + + it('user is able to login via gmail', () => { + + const email = commonData.account.email; + const pass = commonData.account.password; + const passPhrase = commonData.account.passPhrase; + + SplashScreen.login(email, pass); + CreateKeyScreen.setPassPhrase(passPhrase); + + MenuBarScreen.clickMenuIcon(); + MenuBarScreen.checkUserEmail(email); + MenuBarScreen.checkMenuBar(); + + MenuBarScreen.clickLogout(); + SplashScreen.checkLoginPage(); + }); +}); diff --git a/appium/tsconfig.json b/appium/tsconfig.json new file mode 100644 index 000000000..b7ecf8797 --- /dev/null +++ b/appium/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "outDir": "./.tsbuild/", + "target": "es2016", + "module": "commonjs", + "types": ["node", "@wdio/sync", "@wdio/jasmine-framework"], + "esModuleInterop": true + }, + "include": [ + "./tests/**/*.ts" + ] +} From 035fd9a4e030dcf77e9b3903e861f87a8a70623d Mon Sep 17 00:00:00 2001 From: Dmitry Sotnikov Date: Fri, 8 Oct 2021 13:27:55 +0300 Subject: [PATCH 2/4] additional changes for appium suite --- .gitignore | 1 + appium/README.md | 6 +++++- appium/config/wdio.ios.app.conf.js | 7 +++++-- appium/config/wdio.shared.conf.js | 2 +- appium/package.json | 4 +--- appium/tests/data/index.ts | 6 +++--- appium/tests/screenobjects/create-key.screen.ts | 4 ++-- appium/tests/screenobjects/menu-bar.screen.ts | 6 ++++-- appium/tests/screenobjects/splash.screen.ts | 3 ++- appium/tests/specs/inbox/inbox.spec.ts | 13 ++++--------- appium/tests/specs/login/login.spec.ts | 13 ++++--------- 11 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 24f4d656b..3ab758b97 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ test-ci-secrets.json appium/node_modules appium/package-lock.json appium/tmp +appium/.env diff --git a/appium/README.md b/appium/README.md index d29fc63ed..799cb9abd 100644 --- a/appium/README.md +++ b/appium/README.md @@ -6,7 +6,11 @@ Project to run Appium tests together with WebdriverIO for: ## Before running tests, please create a `./apps` directory, download the app and move the app file into that directory +##Create .env file in appium root and set next variables in that file: +ACCOUNT_EMAIL= +ACCOUNT_PASSWORD= +PASS_PHRASE= + ## Install dependencies with `npm i` ## Run smoke tests for iOS with `npm run ios.smoke`, all tests with tag #smoke will be included - diff --git a/appium/config/wdio.ios.app.conf.js b/appium/config/wdio.ios.app.conf.js index bb83f41ec..2a85d4c25 100644 --- a/appium/config/wdio.ios.app.conf.js +++ b/appium/config/wdio.ios.app.conf.js @@ -1,12 +1,15 @@ const { join } = require('path'); const { config } = require('./wdio.shared.conf'); +const pathWdioConfig = require('path'); +require('dotenv').config({ path: pathWdioConfig.resolve(__dirname, '../.env') }); config.suites = { all: [ './tests/specs/**/*.spec.ts' ], smoke: [ - './tests/specs/inbox/inbox.spec.ts', + './tests/specs/login/login.spec.ts', + './tests/specs/inbox/inbox.spec.ts' ] }; @@ -14,7 +17,7 @@ config.capabilities = [ { platformName: 'iOS', iosInstallPause: 5000, - deviceName: process.env.DEVICE_MODEL || 'iPhone 11 Pro Max', + deviceName: 'iPhone 11 Pro Max', platformVersion: '14.5', automationName: 'XCUITest', app: join(process.cwd(), './apps/FlowCrypt.app'), diff --git a/appium/config/wdio.shared.conf.js b/appium/config/wdio.shared.conf.js index 011296b3e..a7b0730b3 100644 --- a/appium/config/wdio.shared.conf.js +++ b/appium/config/wdio.shared.conf.js @@ -37,7 +37,7 @@ exports.config = { afterTest: function (test, context, { error, result, duration, passed, retries }) { if (error) { const timestampNow = new Date().getTime().toString(); - const path = process.env.BITRISE_DEPLOY_DIR || join(process.cwd(), './tmp'); + const path = join(process.cwd(), './tmp'); driver.saveScreenshot(`${path}/${timestampNow}.png`); console.log("Screenshot of failed test was saved to " + path) } diff --git a/appium/package.json b/appium/package.json index fb6b85d07..1e4bf1400 100644 --- a/appium/package.json +++ b/appium/package.json @@ -23,15 +23,13 @@ "@wdio/spec-reporter": "6.10.6", "@wdio/sync": "^6.1.14", "babel-eslint": "^10.1.0", - "downloads-folder": "^3.0.1", + "dotenv": "^10.0.0", "eslint-config-standard": "^16.0.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-wdio": "^6.6.0", - "moment": "^2.29.1", "node-fetch": "^2.6.1", - "request": "^2.88.2", "ts-node": "^9.1.1", "typescript": "^4.1.3", "webdriverio": "6.10.11" diff --git a/appium/tests/data/index.ts b/appium/tests/data/index.ts index 36d2ea242..1f4396609 100644 --- a/appium/tests/data/index.ts +++ b/appium/tests/data/index.ts @@ -1,8 +1,8 @@ export const CommonData = { account: { - email: 'e2e.enterprise.test@flowcrypt.com', - password: 'd874k3bd74', - passPhrase: 'London is the capital of Great Britain' + email: process.env.ACCOUNT_EMAIL, + password: process.env.ACCOUNT_PASSWORD, + passPhrase: process.env.PASS_PHRASE }, sender: { email: 'dmitry@flowcrypt.com' diff --git a/appium/tests/screenobjects/create-key.screen.ts b/appium/tests/screenobjects/create-key.screen.ts index e7c41e576..baebc04ab 100644 --- a/appium/tests/screenobjects/create-key.screen.ts +++ b/appium/tests/screenobjects/create-key.screen.ts @@ -1,5 +1,5 @@ import BaseScreen from './base.screen'; -import commonData from '../data/index'; +import {CommonData} from '../data'; const SELECTORS = { SET_PASS_PHRASE_BUTTON: '~Set pass phrase', @@ -43,7 +43,7 @@ class CreateKeyScreen extends BaseScreen { this.okButton.click(); } - setPassPhrase(text: string = commonData.account.passPhrase) { + setPassPhrase(text: string = CommonData.account.passPhrase) { this.fillPassPhrase(text); this.clickSetPassPhraseBtn(); this.confirmPassPhrase(text); diff --git a/appium/tests/screenobjects/menu-bar.screen.ts b/appium/tests/screenobjects/menu-bar.screen.ts index 11f524845..b09840d21 100644 --- a/appium/tests/screenobjects/menu-bar.screen.ts +++ b/appium/tests/screenobjects/menu-bar.screen.ts @@ -1,4 +1,6 @@ import BaseScreen from './base.screen'; +import {CommonData} from "../data"; +import ElementHelper from "../helpers/ElementHelper"; const SELECTORS = { MENU_ICON: '~menu icn', @@ -24,10 +26,10 @@ class MenuBarScreen extends BaseScreen { } clickMenuIcon () { - this.menuIcon.click() + this.menuIcon.click(); } - checkUserEmail (email) { + checkUserEmail (email: string = CommonData.account.email) { const selector = `~${email}`; $(selector).waitForDisplayed(); } diff --git a/appium/tests/screenobjects/splash.screen.ts b/appium/tests/screenobjects/splash.screen.ts index 48b0c113d..c0a79186b 100644 --- a/appium/tests/screenobjects/splash.screen.ts +++ b/appium/tests/screenobjects/splash.screen.ts @@ -1,4 +1,5 @@ import BaseScreen from './base.screen'; +import {CommonData} from "../data"; const SELECTORS = { PRIVACY_TAB: '~privacy', @@ -127,7 +128,7 @@ class SplashScreen extends BaseScreen { } } - login(email: string, password: string) { + login(email: string = CommonData.account.email, password: string = CommonData.account.password) { driver.launchApp(); this.clickContinueWithGmail(); this.clickContinueBtn(); diff --git a/appium/tests/specs/inbox/inbox.spec.ts b/appium/tests/specs/inbox/inbox.spec.ts index 57dbe3492..8ca0386de 100644 --- a/appium/tests/specs/inbox/inbox.spec.ts +++ b/appium/tests/specs/inbox/inbox.spec.ts @@ -1,4 +1,3 @@ - import { SplashScreen, CreateKeyScreen, @@ -6,22 +5,18 @@ import { EmailScreen } from '../../screenobjects/all-screens'; -import commonData from '../../data/index'; +import {CommonData} from '../../data'; describe('INBOX: ', () => { - const email = commonData.account.email; - const pass = commonData.account.password; - const passPhrase = commonData.account.passPhrase; - it('user is able to view text email', () => { - const senderEmail = commonData.sender; + const senderEmail = CommonData.sender.email; const emailSubject = 'Test 1'; const emailText = 'Test email'; - SplashScreen.login(email, pass); - CreateKeyScreen.setPassPhrase(passPhrase); + SplashScreen.login(); + CreateKeyScreen.setPassPhrase(); InboxScreen.clickOnUserEmail(senderEmail); EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); diff --git a/appium/tests/specs/login/login.spec.ts b/appium/tests/specs/login/login.spec.ts index 67d66a2df..cb60c6b4a 100644 --- a/appium/tests/specs/login/login.spec.ts +++ b/appium/tests/specs/login/login.spec.ts @@ -1,25 +1,20 @@ - import { SplashScreen, CreateKeyScreen, MenuBarScreen } from '../../screenobjects/all-screens'; -import commonData from '../../data/index'; +import {CommonData} from '../../data'; describe('LOGIN: ', () => { it('user is able to login via gmail', () => { - const email = commonData.account.email; - const pass = commonData.account.password; - const passPhrase = commonData.account.passPhrase; - - SplashScreen.login(email, pass); - CreateKeyScreen.setPassPhrase(passPhrase); + SplashScreen.login(); + CreateKeyScreen.setPassPhrase(); MenuBarScreen.clickMenuIcon(); - MenuBarScreen.checkUserEmail(email); + MenuBarScreen.checkUserEmail(); MenuBarScreen.checkMenuBar(); MenuBarScreen.clickLogout(); From 7f261379961e765ff75b34f8e95de0c70acff5d4 Mon Sep 17 00:00:00 2001 From: acladima <76042001+acladima@users.noreply.github.com> Date: Fri, 8 Oct 2021 21:57:06 +0300 Subject: [PATCH 3/4] rename specs --- appium/config/wdio.ios.app.conf.js | 4 ++-- .../specs/inbox/{inbox.spec.ts => ReadTextEmail.spec.ts} | 0 appium/tests/specs/login/{login.spec.ts => UserLogin.spec.ts} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename appium/tests/specs/inbox/{inbox.spec.ts => ReadTextEmail.spec.ts} (100%) rename appium/tests/specs/login/{login.spec.ts => UserLogin.spec.ts} (100%) diff --git a/appium/config/wdio.ios.app.conf.js b/appium/config/wdio.ios.app.conf.js index 2a85d4c25..13695a595 100644 --- a/appium/config/wdio.ios.app.conf.js +++ b/appium/config/wdio.ios.app.conf.js @@ -8,8 +8,8 @@ config.suites = { './tests/specs/**/*.spec.ts' ], smoke: [ - './tests/specs/login/login.spec.ts', - './tests/specs/inbox/inbox.spec.ts' + './tests/specs/login/UserLogin.spec.ts', + './tests/specs/inbox/ReadTextEmail.spec.ts' ] }; diff --git a/appium/tests/specs/inbox/inbox.spec.ts b/appium/tests/specs/inbox/ReadTextEmail.spec.ts similarity index 100% rename from appium/tests/specs/inbox/inbox.spec.ts rename to appium/tests/specs/inbox/ReadTextEmail.spec.ts diff --git a/appium/tests/specs/login/login.spec.ts b/appium/tests/specs/login/UserLogin.spec.ts similarity index 100% rename from appium/tests/specs/login/login.spec.ts rename to appium/tests/specs/login/UserLogin.spec.ts From 62989ad1820a009b11d9f3abdc9569e32813e4be Mon Sep 17 00:00:00 2001 From: acladima <76042001+acladima@users.noreply.github.com> Date: Fri, 8 Oct 2021 21:58:17 +0300 Subject: [PATCH 4/4] rename specs --- appium/config/wdio.ios.app.conf.js | 2 +- .../tests/specs/login/{UserLogin.spec.ts => GmailLogin.spec.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename appium/tests/specs/login/{UserLogin.spec.ts => GmailLogin.spec.ts} (100%) diff --git a/appium/config/wdio.ios.app.conf.js b/appium/config/wdio.ios.app.conf.js index 13695a595..ee0a8c1a4 100644 --- a/appium/config/wdio.ios.app.conf.js +++ b/appium/config/wdio.ios.app.conf.js @@ -8,7 +8,7 @@ config.suites = { './tests/specs/**/*.spec.ts' ], smoke: [ - './tests/specs/login/UserLogin.spec.ts', + './tests/specs/login/GmailLogin.spec.ts', './tests/specs/inbox/ReadTextEmail.spec.ts' ] }; diff --git a/appium/tests/specs/login/UserLogin.spec.ts b/appium/tests/specs/login/GmailLogin.spec.ts similarity index 100% rename from appium/tests/specs/login/UserLogin.spec.ts rename to appium/tests/specs/login/GmailLogin.spec.ts