diff --git a/FlowCrypt/Controllers/Search/SearchViewController.swift b/FlowCrypt/Controllers/Search/SearchViewController.swift index b9330753c..5f05f88e7 100644 --- a/FlowCrypt/Controllers/Search/SearchViewController.swift +++ b/FlowCrypt/Controllers/Search/SearchViewController.swift @@ -244,6 +244,8 @@ extension SearchViewController: UISearchControllerDelegate, UISearchBarDelegate alignment: .left ) searchController.searchBar.searchTextField.textColor = .white + searchController.searchBar.searchTextField.accessibilityIdentifier = "searchAllEmailField" + } } diff --git a/appium/tests/helpers/TouchHelper.ts b/appium/tests/helpers/TouchHelper.ts index a52725f4d..33ab74a58 100644 --- a/appium/tests/helpers/TouchHelper.ts +++ b/appium/tests/helpers/TouchHelper.ts @@ -34,23 +34,24 @@ class TouchHelper { static scrollDownToElement = async (element: WebdriverIO.Element) => { const { width, height } = await driver.getWindowSize(); const anchor = width / 2; - const startPoint = height * 0.25; + const startPoint = height * 0.75; const endPoint = height * 0.15; - let index = 0; - do { - await browser.pause(1000); // due to scroll action which takes about second + // this wait can be later replaced by waiting for loader to go away before scrolling + await browser.pause(1000); // make sure contents are loaded first, so we don't scroll too early + for(let i = 0; i < 15; i++) { + if (await (await element).isDisplayed()) { + return; + } await driver.touchPerform([ {action: 'press', options: {x: anchor, y: startPoint}}, {action: 'wait', options: {ms: 100}}, {action: 'moveTo', options: {x: anchor, y: endPoint}}, {action: 'release', options: {}}, ]); - } while (await (await element).isDisplayed() !== true && index++ < 14); - - if(index === 15) throw new Error(`Element ${JSON.stringify(element.selector)} doesn't displayed after scroll`); + await browser.pause(1000); // due to scroll action which takes about second + } + throw new Error(`Element ${JSON.stringify(element.selector)} not displayed after scroll`); } - } - export default TouchHelper; diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index 2fb464f8e..8798b49ce 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -8,7 +8,8 @@ const SELECTORS = { CREATE_EMAIL_BUTTON: '-ios class chain:**/XCUIElementTypeButton[`label == "+"`]', INBOX_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "INBOX"`]', SEARCH_ICON: '~search icn', - HELP_ICON: '~help icn' + HELP_ICON: '~help icn', + SEARCH_FIELD: '~searchAllEmailField' }; class MailFolderScreen extends BaseScreen { @@ -40,6 +41,10 @@ class MailFolderScreen extends BaseScreen { return $(SELECTORS.CREATE_EMAIL_BUTTON); } + get searchField() { + return $(SELECTORS.SEARCH_FIELD); + } + checkTrashScreen = async () => { await expect(await this.trashHeader).toBeDisplayed(); await expect(await this.searchIcon).toBeDisplayed(); @@ -61,7 +66,6 @@ class MailFolderScreen extends BaseScreen { } clickOnEmailBySubject = async (subject: string) => { - await expect(await this.helpIcon).toBeDisplayed(); const selector = `~${subject}`; if (await (await $(selector)).isDisplayed() !== true) { await TouchHelper.scrollDownToElement(await $(selector)); @@ -88,6 +92,17 @@ class MailFolderScreen extends BaseScreen { await expect(await this.searchIcon).toBeDisplayed(); await expect(await this.helpIcon).toBeDisplayed() } + + clickSearchButton = async () => { + await ElementHelper.waitAndClick(await this.searchIcon, 1000); // delay needed on M1 + } + + searchEmailBySubject = async (subject: string) => { + await this.clickSearchButton(); + await (await this.searchField).setValue(`subject: '${subject}'`); + const selector = `~${subject}`; + await expect(await $(selector)).toBeDisplayed(); + } } export default new MailFolderScreen(); diff --git a/appium/tests/screenobjects/new-message.screen.ts b/appium/tests/screenobjects/new-message.screen.ts index 29750ca24..5c1504aa1 100644 --- a/appium/tests/screenobjects/new-message.screen.ts +++ b/appium/tests/screenobjects/new-message.screen.ts @@ -104,8 +104,8 @@ class NewMessageScreen extends BaseScreen { }; checkFilledComposeEmailInfo = async (recipient: string, subject: string, message: string, attachmentName?: string) => { - expect(this.composeSecurityMessage).toHaveText(message); - + expect(this.composeSecurityMessage).toHaveTextContaining(message); + const element = await this.filledSubject(subject); await element.waitForDisplayed(); diff --git a/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts b/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts index bcb9e9ee2..d24ef829c 100644 --- a/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts +++ b/appium/tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts @@ -24,6 +24,7 @@ describe('INBOX: ', () => { await SetupKeyScreen.setPassPhrase(); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); @@ -31,6 +32,7 @@ describe('INBOX: ', () => { await driver.activateApp(bundleId); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); //try to see encrypted message with wrong pass phrase diff --git a/appium/tests/specs/inbox/CheckReplyAndForwardForEncryptedEmail.spec.ts b/appium/tests/specs/inbox/CheckReplyAndForwardForEncryptedEmail.spec.ts index 8b9e0e31c..ecc188d92 100644 --- a/appium/tests/specs/inbox/CheckReplyAndForwardForEncryptedEmail.spec.ts +++ b/appium/tests/specs/inbox/CheckReplyAndForwardForEncryptedEmail.spec.ts @@ -19,12 +19,13 @@ describe('INBOX: ', () => { const replySubject = `Re: ${emailSubject}`; const forwardSubject = `Fwd: ${emailSubject}`; - const quoteText = `On 11/5/21 at 4:15 AM ${senderEmail} wrote:\n > ${emailText}`; + const quoteText = `${senderEmail} wrote:\n > ${emailText}`; await SplashScreen.login(); await SetupKeyScreen.setPassPhrase(); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); diff --git a/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts b/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts index 544914b5a..b2e18c721 100644 --- a/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts +++ b/appium/tests/specs/inbox/ReadAttachmentEmail.spec.ts @@ -25,6 +25,7 @@ describe('INBOX: ', () => { await SetupKeyScreen.setPassPhrase(); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); await EmailScreen.checkAttachment(attachmentName); //disabled due to @@ -33,6 +34,7 @@ describe('INBOX: ', () => { await driver.activateApp(bundleId); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); //try to see encrypted message with wrong pass phrase diff --git a/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts b/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts index a60266264..01dfe103e 100644 --- a/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts +++ b/appium/tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts @@ -19,6 +19,7 @@ describe('INBOX: ', () => { await SetupKeyScreen.setPassPhrase(); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); @@ -26,6 +27,8 @@ describe('INBOX: ', () => { await driver.activateApp(CommonData.bundleId.id); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); + await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); }); diff --git a/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts b/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts index 5acab837b..366d9f7d4 100644 --- a/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts +++ b/appium/tests/specs/inbox/ReadKeyMismatchEmail.spec.ts @@ -19,6 +19,7 @@ describe('INBOX: ', () => { await SetupKeyScreen.setPassPhrase(); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); }); diff --git a/appium/tests/specs/inbox/ReadTextEmail.spec.ts b/appium/tests/specs/inbox/ReadTextEmail.spec.ts index 39499532d..1e78570e4 100644 --- a/appium/tests/specs/inbox/ReadTextEmail.spec.ts +++ b/appium/tests/specs/inbox/ReadTextEmail.spec.ts @@ -19,6 +19,7 @@ describe('INBOX: ', () => { await SetupKeyScreen.setPassPhrase(); await MailFolderScreen.checkInboxScreen(); + await MailFolderScreen.searchEmailBySubject(emailSubject); await MailFolderScreen.clickOnEmailBySubject(emailSubject); await EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText); });