diff --git a/FlowCrypt/Controllers/Inbox/InboxViewController.swift b/FlowCrypt/Controllers/Inbox/InboxViewController.swift index 8e38f2ce5..99ca57986 100644 --- a/FlowCrypt/Controllers/Inbox/InboxViewController.swift +++ b/FlowCrypt/Controllers/Inbox/InboxViewController.swift @@ -100,6 +100,7 @@ extension InboxViewController { $0.delegate = self $0.dataSource = self $0.leadingScreensForBatching = 1 + $0.accessibilityIdentifier = "aid-inbox-list" $0.view.refreshControl = refreshControl node.addSubnode($0) } diff --git a/appium/tests/helpers/MailFolderHelper.ts b/appium/tests/helpers/MailFolderHelper.ts new file mode 100644 index 000000000..40abee32f --- /dev/null +++ b/appium/tests/helpers/MailFolderHelper.ts @@ -0,0 +1,15 @@ +import MailFolderScreen from "../screenobjects/mail-folder.screen"; + + +class MailFolderHelper { + + static checkPagination = async (subject: string) => { + const emailsCountBeforeScroll = await MailFolderScreen.getEmailCount(); + await MailFolderScreen.scrollDownToEmail(subject); + expect(emailsCountBeforeScroll).toEqual(40); //Should be changed to 20 when https://github.com/FlowCrypt/flowcrypt-ios/issues/1366 is fixed + + const emailsCountAfterScroll = await MailFolderScreen.getEmailCount(); + expect(emailsCountBeforeScroll).toBeLessThan(emailsCountAfterScroll); + } +} +export default MailFolderHelper; diff --git a/appium/tests/helpers/TouchHelper.ts b/appium/tests/helpers/TouchHelper.ts index f74522070..00966d072 100644 --- a/appium/tests/helpers/TouchHelper.ts +++ b/appium/tests/helpers/TouchHelper.ts @@ -53,5 +53,28 @@ class TouchHelper { } throw new Error(`Element ${JSON.stringify(element.selector)} not displayed after scroll`); } + + static scrollUpToElement = async (element: WebdriverIO.Element) => { + const { width, height } = await driver.getWindowSize(); + const anchor = width / 2; + const startPoint = height * 0.15; + const endPoint = height * 0.75; + + // 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 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: {}}, + ]); + 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 ce7d20371..40e583676 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -9,7 +9,8 @@ const SELECTORS = { INBOX_HEADER: '~navigationItemInbox', SEARCH_ICON: '~search icn', HELP_ICON: '~help icn', - SEARCH_FIELD: '~searchAllEmailField' + SEARCH_FIELD: '~searchAllEmailField', + INBOX_LIST: '-ios class chain:**/XCUIElementTypeOther/XCUIElementTypeTable[2]/XCUIElementTypeCell', }; class MailFolderScreen extends BaseScreen { @@ -45,6 +46,10 @@ class MailFolderScreen extends BaseScreen { return $(SELECTORS.SEARCH_FIELD); } + get inboxList() { + return $$(SELECTORS.INBOX_LIST); + } + checkTrashScreen = async () => { await expect(await this.trashHeader).toBeDisplayed(); await expect(await this.searchIcon).toBeDisplayed(); @@ -88,6 +93,21 @@ class MailFolderScreen extends BaseScreen { await $(`~${email}`).click(); } + scrollDownToEmail = async (subject: string) => { + const elem = $(`~${subject}`); + await TouchHelper.scrollDownToElement(await elem); + }; + + getEmailCount = async () => { + await browser.pause(1000); + return await this.inboxList.length; + }; + + scrollUpToFirstEmail = async () => { + const elem = await this.inboxList[0]; + await TouchHelper.scrollUpToElement(elem); + } + checkInboxScreen = async () => { await expect(await this.inboxHeader).toBeDisplayed(); await expect(await this.searchIcon).toBeDisplayed(); diff --git a/appium/tests/specs/live/inbox/CheckinboxPaginationAfterLoadingAllEmails.spec.ts b/appium/tests/specs/live/inbox/CheckinboxPaginationAfterLoadingAllEmails.spec.ts new file mode 100644 index 000000000..358de3af1 --- /dev/null +++ b/appium/tests/specs/live/inbox/CheckinboxPaginationAfterLoadingAllEmails.spec.ts @@ -0,0 +1,27 @@ +import { + SplashScreen, + SetupKeyScreen, + MailFolderScreen, +} from '../../../screenobjects/all-screens'; + +import { CommonData } from '../../../data'; +import MailFolderHelper from "../../../helpers/MailFolderHelper"; + +describe('INBOX: ', () => { + + it('check inbox pagination after loading all messages', async () => { + + const firstEmailSubject = CommonData.simpleEmail.subject; + + await SplashScreen.login(); + await SetupKeyScreen.setPassPhrase(); + await MailFolderScreen.checkInboxScreen(); + + await MailFolderHelper.checkPagination(firstEmailSubject); + + await MailFolderScreen.scrollUpToFirstEmail(); + await MailFolderScreen.refreshMailList(); + + await MailFolderHelper.checkPagination(firstEmailSubject); + }); +});