From 2bfabe135c483557a91f216384835269b9f2318e Mon Sep 17 00:00:00 2001 From: Dmitry Sotnikov Date: Wed, 17 Nov 2021 17:01:44 +0200 Subject: [PATCH 1/3] added new spec for checking sent message after setting incorrect pass phrase --- appium/package.json | 1 + appium/tests/data/index.ts | 3 +- appium/tests/helpers/DataHelper.ts | 10 ++++ appium/tests/screenobjects/email.screen.ts | 7 ++- appium/tests/screenobjects/inbox.screen.ts | 1 - appium/tests/screenobjects/menu-bar.screen.ts | 13 ++++- .../tests/screenobjects/new-message.screen.ts | 4 ++ ...EncryptedEmailAfterWrongPassPhrase.spec.ts | 51 +++++++++++++++++++ 8 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 appium/tests/helpers/DataHelper.ts create mode 100644 appium/tests/specs/composeEmail/SentEncryptedEmailAfterWrongPassPhrase.spec.ts diff --git a/appium/package.json b/appium/package.json index 7a9a52289..1a80921f4 100644 --- a/appium/package.json +++ b/appium/package.json @@ -46,6 +46,7 @@ "node-fetch": "^3.1.0", "node-forge": "0.10.0", "node-gyp": "^8.3.0", + "faker": "^5.5.3", "openpgp": "4.10.10", "request": "^2.88.2", "ts-node": "^10.4.0", diff --git a/appium/tests/data/index.ts b/appium/tests/data/index.ts index f53c627a1..ea8ef3168 100644 --- a/appium/tests/data/index.ts +++ b/appium/tests/data/index.ts @@ -36,6 +36,7 @@ export const CommonData = { }, errors: { noPublicKey: 'Could not compose message One or more of your recipients are missing a public key (marked in gray). ' + - 'Please ask them to share it with you, or ask them to also set up FlowCrypt.' + 'Please ask them to share it with you, or ask them to also set up FlowCrypt.', + wrongPassPhrase: 'Could not compose message This pass phrase did not match your signing private key' } }; diff --git a/appium/tests/helpers/DataHelper.ts b/appium/tests/helpers/DataHelper.ts new file mode 100644 index 000000000..85b5d9083 --- /dev/null +++ b/appium/tests/helpers/DataHelper.ts @@ -0,0 +1,10 @@ +let faker = require('faker'); + +class DataHelper { + + static uniqueValue() { + return faker.random.uuid().split('-')[0]; + } +} + +export default DataHelper; diff --git a/appium/tests/screenobjects/email.screen.ts b/appium/tests/screenobjects/email.screen.ts index d166b0eae..630279299 100644 --- a/appium/tests/screenobjects/email.screen.ts +++ b/appium/tests/screenobjects/email.screen.ts @@ -103,9 +103,14 @@ class EmailScreen extends BaseScreen { await ElementHelper.waitAndClick(await this.downloadAttachmentButton); } - clickReplyButton = async () =>{ + clickReplyButton = async () => { await ElementHelper.waitAndClick(await this.replyButton); } + + checkSentEmailMessage = async () => { + const selector = `~Sent`; + await (await $(selector)).waitForDisplayed(); + } } export default new EmailScreen(); diff --git a/appium/tests/screenobjects/inbox.screen.ts b/appium/tests/screenobjects/inbox.screen.ts index 029795902..9939820c8 100644 --- a/appium/tests/screenobjects/inbox.screen.ts +++ b/appium/tests/screenobjects/inbox.screen.ts @@ -23,7 +23,6 @@ class InboxScreen extends BaseScreen { } clickOnEmailBySubject = async (subject: string) => { - await (await this.createEmailButton).waitForDisplayed(); await ElementHelper.waitAndClick(await $(`~${subject}`), 500); } diff --git a/appium/tests/screenobjects/menu-bar.screen.ts b/appium/tests/screenobjects/menu-bar.screen.ts index 8ecd3e7cb..0127ca3df 100644 --- a/appium/tests/screenobjects/menu-bar.screen.ts +++ b/appium/tests/screenobjects/menu-bar.screen.ts @@ -6,7 +6,8 @@ const SELECTORS = { MENU_ICON: '~menu icn', LOGOUT_BTN: '~Log out', SETTINGS_BTN: '~Settings', - INBOX_BTN: '~INBOX' + INBOX_BTN: '~INBOX', + SENT_BTN: '~SENT' }; class MenuBarScreen extends BaseScreen { @@ -30,8 +31,12 @@ class MenuBarScreen extends BaseScreen { return $(SELECTORS.INBOX_BTN); } + get sentButton() { + return $(SELECTORS.SENT_BTN); + } + clickMenuIcon = async () => { - await ElementHelper.waitAndClick(await this.menuIcon, 500); + await ElementHelper.waitAndClick(await this.menuIcon, 1000); } checkUserEmail = async (email: string = CommonData.account.email) => { @@ -55,6 +60,10 @@ class MenuBarScreen extends BaseScreen { clickInboxButton = async () => { await ElementHelper.waitAndClick(await this.inboxButton); } + + clickSentButton = async () => { + await ElementHelper.waitAndClick(await this.sentButton); + } } export default new MenuBarScreen(); diff --git a/appium/tests/screenobjects/new-message.screen.ts b/appium/tests/screenobjects/new-message.screen.ts index 7c700d871..1e4d15a00 100644 --- a/appium/tests/screenobjects/new-message.screen.ts +++ b/appium/tests/screenobjects/new-message.screen.ts @@ -112,6 +112,10 @@ class NewMessageScreen extends BaseScreen { await expect(await $(message)).toHaveAttribute('value', `${errorText}`); await expect(await this.okButton).toBeDisplayed(); } + + clickOkButtonOnError = async () => { + await ElementHelper.waitAndClick(await this.okButton) + } } export default new NewMessageScreen(); diff --git a/appium/tests/specs/composeEmail/SentEncryptedEmailAfterWrongPassPhrase.spec.ts b/appium/tests/specs/composeEmail/SentEncryptedEmailAfterWrongPassPhrase.spec.ts new file mode 100644 index 000000000..83687af69 --- /dev/null +++ b/appium/tests/specs/composeEmail/SentEncryptedEmailAfterWrongPassPhrase.spec.ts @@ -0,0 +1,51 @@ +import { + SplashScreen, + CreateKeyScreen, + InboxScreen, + NewMessageScreen, + EmailScreen, + MenuBarScreen +} from '../../screenobjects/all-screens'; + +import { CommonData } from '../../data'; +import DataHelper from "../../helpers/DataHelper"; + +describe('COMPOSE EMAIL: ', () => { + + it('user is able to sent encrypted email after reseting pass phrase', async () => { + + const contactEmail = CommonData.secondContact.email; + const emailSubject = CommonData.simpleEmail.subject + DataHelper.uniqueValue(); + const emailText = CommonData.simpleEmail.message; + const passPhrase = CommonData.account.passPhrase; + const wrongPassPhraseError = CommonData.errors.wrongPassPhrase; + const wrongPassPhrase = "wrong"; + const senderEmail = CommonData.account.email; + + + await SplashScreen.login(); + await CreateKeyScreen.setPassPhrase(); + + await InboxScreen.clickCreateEmail(); + await NewMessageScreen.composeEmail(contactEmail, emailSubject, emailText); + await NewMessageScreen.checkFilledComposeEmailInfo(contactEmail, emailSubject, emailText); + //Set wrong pass phrase and check error + await NewMessageScreen.clickSentButton(); + await EmailScreen.enterPassPhrase(wrongPassPhrase); + await EmailScreen.clickOkButton(); + await NewMessageScreen.checkError(wrongPassPhraseError); + await NewMessageScreen.clickOkButtonOnError(); + //Set correct pass phrase + await NewMessageScreen.clickSentButton(); + await EmailScreen.enterPassPhrase(passPhrase); + await EmailScreen.clickOkButton(); + await EmailScreen.checkSentEmailMessage(); + + await MenuBarScreen.clickMenuIcon(); + await MenuBarScreen.clickSentButton(); + //Check sent email + await InboxScreen.clickOnEmailBySubject(emailSubject); + await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); + + }); +}); From d0930fa3a3677b8856833cb07084567af3726b79 Mon Sep 17 00:00:00 2001 From: Dmitry Sotnikov Date: Thu, 18 Nov 2021 09:03:47 +0200 Subject: [PATCH 2/3] added fixes after review --- appium/package.json | 1 - appium/tests/helpers/DataHelper.ts | 9 +++------ ...ts => SendEncryptedEmailAfterWrongPassPhrase.spec.ts} | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) rename appium/tests/specs/composeEmail/{SentEncryptedEmailAfterWrongPassPhrase.spec.ts => SendEncryptedEmailAfterWrongPassPhrase.spec.ts} (95%) diff --git a/appium/package.json b/appium/package.json index 1a80921f4..7a9a52289 100644 --- a/appium/package.json +++ b/appium/package.json @@ -46,7 +46,6 @@ "node-fetch": "^3.1.0", "node-forge": "0.10.0", "node-gyp": "^8.3.0", - "faker": "^5.5.3", "openpgp": "4.10.10", "request": "^2.88.2", "ts-node": "^10.4.0", diff --git a/appium/tests/helpers/DataHelper.ts b/appium/tests/helpers/DataHelper.ts index 85b5d9083..c9cf34d7d 100644 --- a/appium/tests/helpers/DataHelper.ts +++ b/appium/tests/helpers/DataHelper.ts @@ -1,10 +1,7 @@ -let faker = require('faker'); - class DataHelper { - - static uniqueValue() { - return faker.random.uuid().split('-')[0]; - } + static uniqueValue() { + return Math.random().toString(36).substring(2); + } } export default DataHelper; diff --git a/appium/tests/specs/composeEmail/SentEncryptedEmailAfterWrongPassPhrase.spec.ts b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts similarity index 95% rename from appium/tests/specs/composeEmail/SentEncryptedEmailAfterWrongPassPhrase.spec.ts rename to appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts index 83687af69..84407cc33 100644 --- a/appium/tests/specs/composeEmail/SentEncryptedEmailAfterWrongPassPhrase.spec.ts +++ b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts @@ -12,7 +12,7 @@ import DataHelper from "../../helpers/DataHelper"; describe('COMPOSE EMAIL: ', () => { - it('user is able to sent encrypted email after reseting pass phrase', async () => { + it('user is able to send encrypted email after resetting pass phrase', async () => { const contactEmail = CommonData.secondContact.email; const emailSubject = CommonData.simpleEmail.subject + DataHelper.uniqueValue(); @@ -22,7 +22,6 @@ describe('COMPOSE EMAIL: ', () => { const wrongPassPhrase = "wrong"; const senderEmail = CommonData.account.email; - await SplashScreen.login(); await CreateKeyScreen.setPassPhrase(); @@ -46,6 +45,5 @@ describe('COMPOSE EMAIL: ', () => { //Check sent email await InboxScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); - }); }); From 9b1e58c65c31d2e0df2da6498ced8b6f6f435c4d Mon Sep 17 00:00:00 2001 From: Dmitry Sotnikov Date: Thu, 18 Nov 2021 10:13:20 +0200 Subject: [PATCH 3/3] added fixes for Send Encrypted Email spec --- appium/tests/screenobjects/email.screen.ts | 5 ----- appium/tests/screenobjects/inbox.screen.ts | 10 ++++++++++ .../SendEncryptedEmailAfterWrongPassPhrase.spec.ts | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/appium/tests/screenobjects/email.screen.ts b/appium/tests/screenobjects/email.screen.ts index 630279299..34f25cb9c 100644 --- a/appium/tests/screenobjects/email.screen.ts +++ b/appium/tests/screenobjects/email.screen.ts @@ -106,11 +106,6 @@ class EmailScreen extends BaseScreen { clickReplyButton = async () => { await ElementHelper.waitAndClick(await this.replyButton); } - - checkSentEmailMessage = async () => { - const selector = `~Sent`; - await (await $(selector)).waitForDisplayed(); - } } export default new EmailScreen(); diff --git a/appium/tests/screenobjects/inbox.screen.ts b/appium/tests/screenobjects/inbox.screen.ts index 9939820c8..30df19907 100644 --- a/appium/tests/screenobjects/inbox.screen.ts +++ b/appium/tests/screenobjects/inbox.screen.ts @@ -6,6 +6,7 @@ const SELECTORS = { OK_BUTTON: '~Ok', CONFIRM_PASS_PHRASE_FIELD: '~textField', CREATE_EMAIL_BUTTON: '-ios class chain:**/XCUIElementTypeButton[`label == "+"`]', + INBOX_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "INBOX"`]' }; class InboxScreen extends BaseScreen { @@ -17,6 +18,10 @@ class InboxScreen extends BaseScreen { return $(SELECTORS.CREATE_EMAIL_BUTTON); } + get inboxHeader() { + return $(SELECTORS.INBOX_HEADER) + } + clickOnUserEmail = async (email: string) => { await (await this.createEmailButton).waitForDisplayed(); await $(`~${email}`).click(); @@ -29,6 +34,11 @@ class InboxScreen extends BaseScreen { clickCreateEmail = async () => { await ElementHelper.waitAndClick(await this.createEmailButton); } + + checkInboxScreen = async () => { + await (await this.inboxHeader).waitForDisplayed(); + await (await this.createEmailButton).waitForDisplayed(); + } } export default new InboxScreen(); diff --git a/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts index 84407cc33..fae0e74fb 100644 --- a/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts +++ b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts @@ -38,7 +38,7 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.clickSentButton(); await EmailScreen.enterPassPhrase(passPhrase); await EmailScreen.clickOkButton(); - await EmailScreen.checkSentEmailMessage(); + await InboxScreen.checkInboxScreen(); await MenuBarScreen.clickMenuIcon(); await MenuBarScreen.clickSentButton();