Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FlowCrypt/Controllers/Inbox/InboxViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
15 changes: 15 additions & 0 deletions appium/tests/helpers/MailFolderHelper.ts
Original file line number Diff line number Diff line change
@@ -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;
23 changes: 23 additions & 0 deletions appium/tests/helpers/TouchHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
22 changes: 21 additions & 1 deletion appium/tests/screenobjects/mail-folder.screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
});