diff --git a/appium/tests/data/index.ts b/appium/tests/data/index.ts index 13f665808..7671308b4 100644 --- a/appium/tests/data/index.ts +++ b/appium/tests/data/index.ts @@ -84,24 +84,28 @@ export const CommonData = { email: 'revoked@flowcrypt.com' }, errors: { - 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.' + noPublicKey: 'Error\n' + + '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: 'Error\n' + + 'Could not compose message\n' + + '\n' + + 'This pass phrase did not match your signing private key', + expiredPublicKey: 'Error\n' + + '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: 'Error\n' + + '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/base.screen.ts b/appium/tests/screenobjects/base.screen.ts index f6bb23316..708b49ee1 100644 --- a/appium/tests/screenobjects/base.screen.ts +++ b/appium/tests/screenobjects/base.screen.ts @@ -6,7 +6,8 @@ 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' + RETRY_BUTTON: '~Retry', + CURRENT_MODAL: '-ios predicate string:type == "XCUIElementTypeAlert"' }; export default class BaseScreen { @@ -16,20 +17,12 @@ 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) + static get currentModal() { + return $(SELECTORS.CURRENT_MODAL); } waitForScreen = async (isShown = true) => { @@ -39,20 +32,10 @@ export default class BaseScreen { }); } - 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 checkModalMessage = async (message: string) => { + await expect(await this.currentModal).toBeDisplayed(); + const alertText = await driver.getAlertText(); + await expect(alertText).toEqual(message); } static clickOkButtonOnError = async () => { diff --git a/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts index 29d522260..d1a869753 100644 --- a/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts +++ b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithExpiredAndRevokedPublicKeys.spec.ts @@ -29,7 +29,7 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.checkFilledComposeEmailInfo(expiredPublicKey, emailSubject, emailText); await NewMessageScreen.clickSendButton(); - await BaseScreen.checkErrorModal(expiredPublicKeyError); + await BaseScreen.checkModalMessage(expiredPublicKeyError); await BaseScreen.clickOkButtonOnError(); await NewMessageScreen.clickBackButton(); @@ -40,6 +40,6 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.checkFilledComposeEmailInfo(revokedpublicKey, emailSubject, emailText); await NewMessageScreen.clickSendButton(); - await BaseScreen.checkErrorModal(revokedPublicKeyError); + await BaseScreen.checkModalMessage(revokedPublicKeyError); }); }); diff --git a/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts index 3c660b21f..4b3356bc1 100644 --- a/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts +++ b/appium/tests/specs/live/composeEmail/SendEmailToRecipientWithoutPublicKey.spec.ts @@ -26,6 +26,6 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.checkFilledComposeEmailInfo(noPublicKeyRecipient, emailSubject, emailText); await NewMessageScreen.clickSendButton(); - await BaseScreen.checkErrorModal(noPublicKeyError); + await BaseScreen.checkModalMessage(noPublicKeyError); }); }); diff --git a/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts b/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts index a175da53c..eda7bd8a6 100644 --- a/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts +++ b/appium/tests/specs/live/composeEmail/SendEncryptedEmailAfterPassPhraseSessionEndedAndTrashIt.spec.ts @@ -40,7 +40,7 @@ describe('COMPOSE EMAIL: ', () => { await NewMessageScreen.clickSendButton(); await EmailScreen.enterPassPhrase(wrongPassPhrase); await EmailScreen.clickOkButton(); - await BaseScreen.checkErrorModal(wrongPassPhraseError); + await BaseScreen.checkModalMessage(wrongPassPhraseError); await BaseScreen.clickOkButtonOnError(); //Set correct pass phrase await NewMessageScreen.clickSendButton(); diff --git a/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts b/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts index b523d5ab7..948dab26b 100644 --- a/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts +++ b/appium/tests/specs/mock/setup/SetupFailsWithInconsistentClientConfiguration.spec.ts @@ -16,7 +16,7 @@ describe('SETUP: ', () => { }; await mockApi.withMockedApis(async () => { await SplashScreen.login(); - await BaseScreen.checkErrorModal('Please check if key manager url set correctly'); + await BaseScreen.checkModalMessage('Error\n' + '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 d9a8a8317..f8fec687b 100644 --- a/appium/tests/specs/mock/setup/SetupShowsMeaningfulErrorFromFES.spec.ts +++ b/appium/tests/specs/mock/setup/SetupShowsMeaningfulErrorFromFES.spec.ts @@ -17,7 +17,8 @@ describe('SETUP: ', () => { }; await mockApi.withMockedApis(async () => { await SplashScreen.login(); - await BaseScreen.checkErrorModalForFES('EnterpriseServerApi 400 message:some client err get http://127.0.0.1:8001/fes/api/'); + await BaseScreen.checkModalMessage('Startup Error\n' + + 'EnterpriseServerApi 400 message:some client err get http://127.0.0.1:8001/fes/api/'); }); }); });