diff --git a/appium/tests/data/index.ts b/appium/tests/data/index.ts index 886677e8f..484de3692 100644 --- a/appium/tests/data/index.ts +++ b/appium/tests/data/index.ts @@ -79,13 +79,24 @@ export const CommonData = { email: 'revoked@flowcrypt.com' }, 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.', - wrongPassPhrase: 'Could not compose message This pass phrase did not match your signing private key', - expiredPublicKey: 'Could not compose message One or more of your recipients have expired public keys (marked in orange).' + - ' Please ask them to send you updated public key. If this is an enterprise installation, please ask your systems admin.', - revokedPublicKey: 'Could not compose message One or more of your recipients have revoked public keys (marked in red).' + - ' Please ask them to send you a new public key. If this is an enterprise installation, please ask your systems admin.' + noPublicKey: 'Could not compose message\n' + + '\n' + + 'One or more of your recipients are missing a public key (marked in gray).\n' + + '\n' + + 'Please ask them to share it with you, or ask them to also set up FlowCrypt.', + wrongPassPhrase: 'Could not compose message\n' + + '\n' + + 'This pass phrase did not match your signing private key', + expiredPublicKey: 'Could not compose message\n' + + '\n' + + 'One or more of your recipients have expired public keys (marked in orange).\n' + + '\n' + + 'Please ask them to send you updated public key. If this is an enterprise installation, please ask your systems admin.', + revokedPublicKey: 'Could not compose message\n' + + '\n' + + 'One or more of your recipients have revoked public keys (marked in red).\n' + + '\n' + + 'Please ask them to send you a new public key. If this is an enterprise installation, please ask your systems admin.' }, decryptErrorBadge: { badgeText: 'decrypt error' diff --git a/appium/tests/screenobjects/all-screens.ts b/appium/tests/screenobjects/all-screens.ts index 778084ee8..fc624ddad 100644 --- a/appium/tests/screenobjects/all-screens.ts +++ b/appium/tests/screenobjects/all-screens.ts @@ -9,8 +9,8 @@ import ContactScreen from './contacts.screen'; import ContactPublicKeyScreen from './contact-public-key.screen'; import PublicKeyScreen from './public-key.screen'; import AttachmentScreen from './attachment.screen'; -import MailFolderScreen from './mail-folder.screen' -import SearchScreen from './search.screen' +import MailFolderScreen from './mail-folder.screen'; +import SearchScreen from './search.screen'; export { SplashScreen, diff --git a/appium/tests/screenobjects/base.screen.ts b/appium/tests/screenobjects/base.screen.ts index 619eb2d5e..f6bb23316 100644 --- a/appium/tests/screenobjects/base.screen.ts +++ b/appium/tests/screenobjects/base.screen.ts @@ -1,4 +1,13 @@ import { DEFAULT_TIMEOUT } from '../constants'; +import ElementHelper from "../helpers/ElementHelper"; + + +const SELECTORS = { + ERROR_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "Error"`]', + OK_BUTTON: '~OK', + ERROR_FES_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "Startup Error"`]', + RETRY_BUTTON: '~Retry' +}; export default class BaseScreen { @@ -7,10 +16,47 @@ export default class BaseScreen { this.locator = selector; } + static get errorHeader() { + return $(SELECTORS.ERROR_HEADER) + } + + static get errorFESHeader() { + return $(SELECTORS.ERROR_FES_HEADER) + } + + static get okButton() { + return $(SELECTORS.OK_BUTTON); + } + + static get retryButton() { + return $(SELECTORS.RETRY_BUTTON) + } + waitForScreen = async (isShown = true) => { await (await $(this.locator)).waitForDisplayed({ timeout: DEFAULT_TIMEOUT, reverse: !isShown, }); } + + static checkErrorModal = async (errorText: string) => { + const message = '-ios class chain:**/XCUIElementTypeAlert/XCUIElementTypeOther/XCUIElementTypeOther/' + + 'XCUIElementTypeOther[2]/XCUIElementTypeScrollView[1]/XCUIElementTypeOther[1]/XCUIElementTypeStaticText[2]';//it works only with this selector + await expect(await this.errorHeader).toBeDisplayed(); + expect(await (await $(message)).getAttribute('value')).toContain(errorText); + await expect(await this.okButton).toBeDisplayed(); + } + + static checkErrorModalForFES = async (errorText: string) => { + const message = '-ios class chain:**/XCUIElementTypeAlert/XCUIElementTypeOther/XCUIElementTypeOther/' + + 'XCUIElementTypeOther[2]/XCUIElementTypeScrollView[1]/XCUIElementTypeOther[1]/XCUIElementTypeStaticText[2]';//it works only with this selector + await expect(await this.errorFESHeader).toBeDisplayed(); + expect(await (await $(message)).getAttribute('value')).toContain(errorText); + await expect(await this.retryButton).toBeDisplayed(); + } + + static clickOkButtonOnError = async () => { + await ElementHelper.waitAndClick(await this.okButton) + } + } diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index b5d8220a5..6b151ead5 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -3,10 +3,10 @@ import TouchHelper from "../helpers/TouchHelper"; import ElementHelper from "../helpers/ElementHelper"; const SELECTORS = { - TRASH_HEADER: '-ios class chain:**/XCUIElementTypeNavigationBar[`name == "TRASH"`]', - SENT_HEADER: '-ios class chain:**/XCUIElementTypeNavigationBar[`name == "SENT"`]', + TRASH_HEADER: '~Navigationitemtrash', + SENT_HEADER: '~Navigationitemsent', CREATE_EMAIL_BUTTON: '-ios class chain:**/XCUIElementTypeButton[`label == "+"`]', - INBOX_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "INBOX"`]', + INBOX_HEADER: '~Navigationiteminbox', SEARCH_ICON: '~search icn', HELP_ICON: '~help icn', SEARCH_FIELD: '~searchAllEmailField' diff --git a/appium/tests/screenobjects/new-message.screen.ts b/appium/tests/screenobjects/new-message.screen.ts index b58a4eba5..c68051c90 100644 --- a/appium/tests/screenobjects/new-message.screen.ts +++ b/appium/tests/screenobjects/new-message.screen.ts @@ -16,8 +16,6 @@ const SELECTORS = { RETURN_BUTTON: '~Return', BACK_BUTTON: '~arrow left c', SEND_BUTTON: '~android send', - ERROR_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "Error"`]', - OK_BUTTON: '~OK' }; class NewMessageScreen extends BaseScreen { @@ -65,14 +63,6 @@ class NewMessageScreen extends BaseScreen { return $(SELECTORS.SEND_BUTTON); } - get errorHeader() { - return $(SELECTORS.ERROR_HEADER) - } - - get okButton() { - return $(SELECTORS.OK_BUTTON); - } - setAddRecipient = async (recipient: string) => { await (await this.addRecipientField).setValue(recipient); await browser.pause(2000); @@ -151,18 +141,6 @@ class NewMessageScreen extends BaseScreen { clickSendButton = async () => { await ElementHelper.waitAndClick(await this.sendButton); } - - checkError = async (errorText: string) => { - const message = '-ios class chain:**/XCUIElementTypeAlert/XCUIElementTypeOther/XCUIElementTypeOther/' + - 'XCUIElementTypeOther[2]/XCUIElementTypeScrollView[1]/XCUIElementTypeOther[1]/XCUIElementTypeStaticText[2]';//it works only with this selector - await expect(await this.errorHeader).toBeDisplayed(); - 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/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts index f56db44f6..29d522260 100644 --- a/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts +++ b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts @@ -6,6 +6,7 @@ import { } from '../../../screenobjects/all-screens'; import { CommonData } from '../../../data'; +import BaseScreen from "../../../screenobjects/base.screen"; describe('COMPOSE EMAIL: ', () => { @@ -28,9 +29,9 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.checkFilledComposeEmailInfo(expiredPublicKey, emailSubject, emailText); await NewMessageScreen.clickSendButton(); - await NewMessageScreen.checkError(expiredPublicKeyError); + await BaseScreen.checkErrorModal(expiredPublicKeyError); - await NewMessageScreen.clickOkButtonOnError(); + await BaseScreen.clickOkButtonOnError(); await NewMessageScreen.clickBackButton(); await MailFolderScreen.checkInboxScreen(); @@ -39,6 +40,6 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.checkFilledComposeEmailInfo(revokedpublicKey, emailSubject, emailText); await NewMessageScreen.clickSendButton(); - await NewMessageScreen.checkError(revokedPublicKeyError); + await BaseScreen.checkErrorModal(revokedPublicKeyError); }); }); diff --git a/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts index 57f51fa86..3c660b21f 100644 --- a/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts +++ b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts @@ -6,6 +6,7 @@ import { } from '../../../screenobjects/all-screens'; import { CommonData } from '../../../data'; +import BaseScreen from "../../../screenobjects/base.screen"; describe('COMPOSE EMAIL: ', () => { @@ -25,6 +26,6 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.checkFilledComposeEmailInfo(noPublicKeyRecipient, emailSubject, emailText); await NewMessageScreen.clickSendButton(); - await NewMessageScreen.checkError(noPublicKeyError); + await BaseScreen.checkErrorModal(noPublicKeyError); }); }); diff --git a/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts b/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts index 8d4143276..a175da53c 100644 --- a/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts +++ b/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts @@ -9,6 +9,7 @@ import { import { CommonData } from '../../../data'; import DataHelper from "../../../helpers/DataHelper"; +import BaseScreen from "../../../screenobjects/base.screen"; describe('COMPOSE EMAIL: ', () => { @@ -39,8 +40,8 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.clickSendButton(); await EmailScreen.enterPassPhrase(wrongPassPhrase); await EmailScreen.clickOkButton(); - await NewMessageScreen.checkError(wrongPassPhraseError); - await NewMessageScreen.clickOkButtonOnError(); + await BaseScreen.checkErrorModal(wrongPassPhraseError); + await BaseScreen.clickOkButtonOnError(); //Set correct pass phrase await NewMessageScreen.clickSendButton(); await EmailScreen.enterPassPhrase(passPhrase); diff --git a/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts b/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts index 516e2f06f..7d8b8863e 100644 --- a/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts +++ b/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts @@ -2,6 +2,7 @@ import { MockApi } from 'api-mocks/mock'; import { SplashScreen, } from '../../../screenobjects/all-screens'; +import BaseScreen from "../../../screenobjects/base.screen"; describe('SETUP: ', () => { @@ -11,9 +12,7 @@ describe('SETUP: ', () => { mockApi.fesConfig = { clientConfiguration: { key_manager_url: 'INTENTIONAL BAD URL' } }; await mockApi.withMockedApis(async () => { await SplashScreen.login(); - // todo - replace the following pause with wait for modal error - // that says "Please check if key manager url set correctly" - await browser.pause(5000); + await BaseScreen.checkErrorModal('Please check if key manager url set correctly'); }); }); diff --git a/appium/tests/specs/mock/setup/SetupShowsMeaningfulErrorFromFES.spec.ts b/appium/tests/specs/mock/setup/SetupShowsMeaningfulErrorFromFES.spec.ts index daff6c0ed..a1f351239 100644 --- a/appium/tests/specs/mock/setup/SetupShowsMeaningfulErrorFromFES.spec.ts +++ b/appium/tests/specs/mock/setup/SetupShowsMeaningfulErrorFromFES.spec.ts @@ -2,6 +2,7 @@ import { MockApi } from 'api-mocks/mock'; import { SplashScreen, } from '../../../screenobjects/all-screens'; +import BaseScreen from "../../../screenobjects/base.screen"; describe('SETUP: ', () => { @@ -11,9 +12,7 @@ describe('SETUP: ', () => { mockApi.fesConfig = { returnError: { code: 400, message: "some client err" } }; await mockApi.withMockedApis(async () => { await SplashScreen.login(); - // todo - replace the following pause with wait for modal error - await browser.pause(5000); + await BaseScreen.checkErrorModalForFES('EnterpriseServerApi 400 message:some client err get http://127.0.0.1:8001/fes/api/'); }); }); - });