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..c9cf34d7d --- /dev/null +++ b/appium/tests/helpers/DataHelper.ts @@ -0,0 +1,7 @@ +class DataHelper { + static uniqueValue() { + return Math.random().toString(36).substring(2); + } +} + +export default DataHelper; diff --git a/appium/tests/screenobjects/email.screen.ts b/appium/tests/screenobjects/email.screen.ts index d166b0eae..34f25cb9c 100644 --- a/appium/tests/screenobjects/email.screen.ts +++ b/appium/tests/screenobjects/email.screen.ts @@ -103,7 +103,7 @@ class EmailScreen extends BaseScreen { await ElementHelper.waitAndClick(await this.downloadAttachmentButton); } - clickReplyButton = async () =>{ + clickReplyButton = async () => { await ElementHelper.waitAndClick(await this.replyButton); } } diff --git a/appium/tests/screenobjects/inbox.screen.ts b/appium/tests/screenobjects/inbox.screen.ts index 029795902..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,19 +18,27 @@ 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(); } clickOnEmailBySubject = async (subject: string) => { - await (await this.createEmailButton).waitForDisplayed(); await ElementHelper.waitAndClick(await $(`~${subject}`), 500); } 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/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/SendEncryptedEmailAfterWrongPassPhrase.spec.ts b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts new file mode 100644 index 000000000..fae0e74fb --- /dev/null +++ b/appium/tests/specs/composeEmail/SendEncryptedEmailAfterWrongPassPhrase.spec.ts @@ -0,0 +1,49 @@ +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 send encrypted email after resetting 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 InboxScreen.checkInboxScreen(); + + await MenuBarScreen.clickMenuIcon(); + await MenuBarScreen.clickSentButton(); + //Check sent email + await InboxScreen.clickOnEmailBySubject(emailSubject); + await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); + }); +});