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
4 changes: 3 additions & 1 deletion appium/config/wdio.ios.app.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ config.suites = {
'./tests/specs/inbox/ReadTextEmail.spec.ts',
'./tests/specs/composeEmail/CheckComposeEmailAfterReopening.spec.ts',
'./tests/specs/inbox/ReadEmailAfterRestartApp.spec.ts',
'./tests/specs/inbox/CheckEncryptedEmailAfterRestartApp.spec.ts',
'./tests/specs/settings/CheckSettingsForLoggedUser.spec.ts',
]
};

config.capabilities = [
{
platformName: 'iOS',
iosInstallPause: 5000,
deviceName: 'iPhone 11 Pro Max',
deviceName: 'iPhone 11',
platformVersion: '15.0',
automationName: 'XCUITest',
app: join(process.cwd(), './apps/FlowCrypt.app'),
Expand Down
10 changes: 8 additions & 2 deletions appium/tests/screenobjects/all-screens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import CreateKeyScreen from './create-key.screen';
import InboxScreen from './inbox.screen';
import MenuBarScreen from './menu-bar.screen';
import EmailScreen from './email.screen';
import NewMessageScreen from './new-message.screen'
import NewMessageScreen from './new-message.screen';
import SettingsScreen from './settings.screen';
import KeysScreen from './keys.screen';
import PublicKeyScreen from './public_key.screen';

export {
SplashScreen,
CreateKeyScreen,
InboxScreen,
MenuBarScreen,
EmailScreen,
NewMessageScreen
NewMessageScreen,
SettingsScreen,
KeysScreen,
PublicKeyScreen
};
39 changes: 38 additions & 1 deletion appium/tests/screenobjects/email.screen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import BaseScreen from './base.screen';
import {CommonData} from "../data";

const SELECTORS = {
BACK_BTN: '~arrow left c'
BACK_BTN: '~arrow left c',
ENTER_PASS_PHRASE_FIELD: '-ios class chain:**/XCUIElementTypeSecureTextField',
OK_BUTTON: '~Ok',
WRONG_PASS_PHRASE_MESSAGE: '-ios class chain:**/XCUIElementTypeStaticText[`label == "Wrong pass phrase, please try again"`]',
SAVE_BUTTON: '~Save',
};

const { join } = require('path');
Expand All @@ -15,6 +20,22 @@ class EmailScreen extends BaseScreen {
return $(SELECTORS.BACK_BTN)
}

get enterPassPhraseField() {
return $(SELECTORS.ENTER_PASS_PHRASE_FIELD)
}

get okButton () {
return $(SELECTORS.OK_BUTTON)
}

get wrongPassPhraseMessage () {
return $(SELECTORS.WRONG_PASS_PHRASE_MESSAGE)
}

get saveButton() {
return $(SELECTORS.SAVE_BUTTON)
}

checkEmailAddress (email) {
const selector = `~${email}`;
$(selector).waitForDisplayed();
Expand All @@ -40,6 +61,22 @@ class EmailScreen extends BaseScreen {
clickBackButton () {
this.backButton.click();
}

clickOkButton() {
this.okButton.click();
}

enterPassPhrase (text: string = CommonData.account.passPhrase) {
this.enterPassPhraseField.setValue(text);
};

checkErrorMessage() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name it checkWrongPassPhraseErrorMessage to be more specific

this.wrongPassPhraseMessage.waitForDisplayed();
}

clickSaveButton() {
this.saveButton.click();
}
}

export default new EmailScreen();
4 changes: 3 additions & 1 deletion appium/tests/screenobjects/inbox.screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const SELECTORS = {
ENTER_YOUR_PASS_PHRASE_FIELD: '-ios class chain:**/XCUIElementTypeSecureTextField[`value == "Enter your pass phrase"`]',
OK_BUTTON: '~Ok',
CONFIRM_PASS_PHRASE_FIELD: '~textField',
CREATE_EMAIL_BUTTON: '-ios class chain:**/XCUIElementTypeButton[`label == "+"`]'
CREATE_EMAIL_BUTTON: '-ios class chain:**/XCUIElementTypeButton[`label == "+"`]',
};

class InboxScreen extends BaseScreen {
Expand All @@ -17,11 +17,13 @@ class InboxScreen extends BaseScreen {
}

clickOnUserEmail (email) {
this.createEmailButton.waitForDisplayed();
const selector = `~${email}`;
$(selector).click();
}

clickOnEmailBySubject (subject) {
this.createEmailButton.waitForDisplayed();
const selector = `~${subject}`;
$(selector).click();
}
Expand Down
90 changes: 90 additions & 0 deletions appium/tests/screenobjects/keys.screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import BaseScreen from './base.screen';

const SELECTORS = {
KEYS_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "Keys"`]',
ADD_BUTTON: '~Add',
NAME_AND_EMAIL: '-ios class chain:**/XCUIElementTypeOther/XCUIElementTypeStaticText[1]',
DATE_CREATED: '-ios class chain:**/XCUIElementTypeOther/XCUIElementTypeStaticText[2]',
FINGERPRINT: '-ios class chain:**/XCUIElementTypeOther/XCUIElementTypeStaticText[3]',
SHOW_PUBLIC_KEY_BUTTON: '~Show public key',
SHOW_KEY_DETAILS_BUTTON: '~Show key details',
COPY_TO_CLIPBOARD_BUTTON: '~Copy to clipboard',
SHARE_BUTTON: '~Share',
SHOW_PRIVATE_KEY_BUTTON: '~Show private key'
};

class KeysScreen extends BaseScreen {
constructor () {
super(SELECTORS.KEYS_HEADER);
}

get keysHeader() {
return $(SELECTORS.KEYS_HEADER);
}

get addButton() {
return $(SELECTORS.ADD_BUTTON);
}

get nameAndEmail() {
return $(SELECTORS.NAME_AND_EMAIL);
}

get dateCreated() {
return $(SELECTORS.DATE_CREATED);
}

get fingerPrint() {
return $(SELECTORS.FINGERPRINT);
}

get showPublicKeyButton() {
return $(SELECTORS.SHOW_PUBLIC_KEY_BUTTON);
}

get showPrivateKeyButton() {
return $(SELECTORS.SHOW_PRIVATE_KEY_BUTTON);
}

get showKeyDetailsButton() {
return $(SELECTORS.SHOW_KEY_DETAILS_BUTTON);
}

get shareButton() {
return $(SELECTORS.SHARE_BUTTON);
}

get copyToClipboardButton() {
return $(SELECTORS.COPY_TO_CLIPBOARD_BUTTON);
}

checkKeysScreen() {
//will add value verification for key later, need to create Api request for get key value
this.keysHeader.waitForDisplayed();
//this.addButton.waitForDisplayed({reverse: true}); - disabled due to https://github.com/FlowCrypt/flowcrypt-ios/issues/715
this.nameAndEmail.waitForExist();
this.dateCreated.waitForExist();
this.fingerPrint.waitForExist();
expect(this.nameAndEmail.getAttribute('value')).not.toEqual(null);
expect(this.dateCreated.getAttribute('value')).not.toEqual(null);
expect(this.fingerPrint.getAttribute('value')).not.toEqual(null);
}

clickOnKey() {
this.nameAndEmail.click();
}

checkSelectedKeyScreen() {
this.showPublicKeyButton.waitForDisplayed();
this.showPrivateKeyButton.waitForDisplayed();
this.showKeyDetailsButton.waitForDisplayed();
this.shareButton.waitForDisplayed();
this.copyToClipboardButton.waitForDisplayed();
}

clickOnShowPublicKey() {
this.showPublicKeyButton.click();
}
}

export default new KeysScreen();
5 changes: 4 additions & 1 deletion appium/tests/screenobjects/menu-bar.screen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BaseScreen from './base.screen';
import {CommonData} from "../data";
import ElementHelper from "../helpers/ElementHelper";

const SELECTORS = {
MENU_ICON: '~menu icn',
Expand Down Expand Up @@ -42,6 +41,10 @@ class MenuBarScreen extends BaseScreen {
clickLogout () {
this.logoutButton.click();
}

clickSettingsButton () {
this.settingsButton.click();
}
}

export default new MenuBarScreen();
1 change: 0 additions & 1 deletion appium/tests/screenobjects/new-message.screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class NewMessageScreen extends BaseScreen {
expect(this.addedRecipientEmail).toHaveAttribute('value', ` ${recipient} `);

}

}

export default new NewMessageScreen();
28 changes: 28 additions & 0 deletions appium/tests/screenobjects/public_key.screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import BaseScreen from './base.screen';

const SELECTORS = {
BACK_BTN: '~arrow left c',
PUBLIC_KEY: '-ios class chain:**/XCUIElementTypeOther/XCUIElementTypeStaticText[1]',
};

class PublicKeyScreen extends BaseScreen {
constructor () {
super(SELECTORS.BACK_BTN);
}

get backButton() {
return $(SELECTORS.BACK_BTN);
}

get publicKey() {
return $(SELECTORS.PUBLIC_KEY);
}

checkPublicKey() {
this.backButton.waitForDisplayed();
this.publicKey.waitForExist();
expect(this.publicKey.getAttribute('value')).not.toEqual(null);
}
}

export default new PublicKeyScreen();
31 changes: 31 additions & 0 deletions appium/tests/screenobjects/settings.screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import BaseScreen from './base.screen';
const SELECTORS = {
MENU_ICON: '~menu icn',
};

class SettingsScreen extends BaseScreen {
constructor () {
super(SELECTORS.MENU_ICON);
}

settingsItem (setting) {
return $(`~${setting}`);
}

checkSettingsScreen() {
this.settingsItem('Security and Privacy').waitForDisplayed();
this.settingsItem('Contacts').waitForDisplayed();
this.settingsItem('Keys').waitForDisplayed();
this.settingsItem('Attester').waitForDisplayed();
this.settingsItem('Notifications').waitForDisplayed();
this.settingsItem('Legal').waitForDisplayed();
this.settingsItem('Experimental').waitForDisplayed();
this.settingsItem('Backups').waitForDisplayed({reverse: true});
}

clickOnSettingItem(item) {
this.settingsItem(item).click();
}
}

export default new SettingsScreen();
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {
SplashScreen,
CreateKeyScreen,
InboxScreen,
EmailScreen
} from '../../screenobjects/all-screens';

import {CommonData} from '../../data';

describe('INBOX: ', () => {

it('user is able to see encrypted email with pass phrase after restart app', () => {

const senderEmail = CommonData.sender.email;
const emailSubject = 'encrypted message';
const emailText = 'test test';
const wrongPassPhrase = 'user is not able to see email';

const correctPassPhrase = CommonData.account.passPhrase;

const bundleId = CommonData.bundleId.id;

SplashScreen.login();
CreateKeyScreen.setPassPhrase();

InboxScreen.clickOnEmailBySubject(senderEmail);
EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText);

driver.terminateApp(bundleId);

driver.activateApp(bundleId);

InboxScreen.clickOnEmailBySubject(emailSubject);

//try to see encrypted message with wrong pass phrase
EmailScreen.enterPassPhrase(wrongPassPhrase);
EmailScreen.clickOkButton();
EmailScreen.checkErrorMessage();

//check email after setting correct pass phrase
EmailScreen.enterPassPhrase(correctPassPhrase);
EmailScreen.clickSaveButton();
EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText);

//reopen email without pass phrase
EmailScreen.clickBackButton();
InboxScreen.clickOnEmailBySubject(emailSubject);
EmailScreen.checkOpenedEmail(senderEmail, emailSubject, emailText);
});
});
1 change: 0 additions & 1 deletion appium/tests/specs/login/GmailLogin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
MenuBarScreen
} from '../../screenobjects/all-screens';

import {CommonData} from '../../data';

describe('LOGIN: ', () => {

Expand Down
35 changes: 35 additions & 0 deletions appium/tests/specs/settings/CheckSettingsForLoggedUser.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
SplashScreen,
CreateKeyScreen,
MenuBarScreen,
SettingsScreen,
KeysScreen,
PublicKeyScreen
} from '../../screenobjects/all-screens';


describe('SETTINGS: ', () => {

it('user should see public key and should not see private key', () => {

SplashScreen.login();
CreateKeyScreen.setPassPhrase();

MenuBarScreen.clickMenuIcon();
MenuBarScreen.checkUserEmail();
MenuBarScreen.checkMenuBar();

MenuBarScreen.clickSettingsButton();
SettingsScreen.checkSettingsScreen();
SettingsScreen.clickOnSettingItem('Keys');

KeysScreen.checkKeysScreen();
KeysScreen.clickOnKey();

KeysScreen.checkSelectedKeyScreen();

KeysScreen.clickOnShowPublicKey();
PublicKeyScreen.checkPublicKey();

});
});