Skip to content

Commit

Permalink
Chore help test addition (#407)
Browse files Browse the repository at this point in the history
* WIP: add cucumber tests (visit help centre, send logs) for help page

* chore: prettier

* WIP: add test code for scenarios visit help centre, send logs, on mobile help page

* WIP: add scenarios to mobile help page tests

* WIP: minor changes (code refactor) in help.feature

* WIP: updated test for visit helpcenter to check for correct url in browser on Android

* chore: introduce android specific test for help

* WIP: refactored code for Android-specific checkIfWebsiteHasOpened()

* chore: uncommented scenarios in help.feature
  • Loading branch information
Mona authored and seavan committed Dec 26, 2018
1 parent e7ab6c9 commit 14f942a
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 15 deletions.
8 changes: 8 additions & 0 deletions test/code/helpers/AndroidFactory.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
const { android } = require('../platforms');
const ChatActionSheetPage = require('../pages/popups/actionSheetPage/AndroidChatActionSheetPage');
const FileUploadPage = require('../pages/files/fileUploadPage/AndroidFileUploadPage');
const AndroidSettingsPage = require('../pages/settings/AndroidSettingsPage');

class AndroidFactory {
get bundleId() {
return 'com.peerio.app';
}

get platform() {
return android;
}

chatActionSheetPage(app) {
return new ChatActionSheetPage(app);
}

fileUploadPage(app) {
return new FileUploadPage(app);
}

settingsPage(app) {
return new AndroidSettingsPage(app);
}
}

module.exports = new AndroidFactory();
7 changes: 6 additions & 1 deletion test/code/helpers/androidHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ function selectorWithPartialResourceId(query) {
return `android=new UiSelector().resourceIdMatches("${query}")`;
}

function selectorWithPartialText(query) {
return `android=new UiSelector().textContains("${query}")`;
}

module.exports = {
selectorWithText,
selectorWithPartialResourceId
selectorWithPartialResourceId,
selectorWithPartialText
};
8 changes: 8 additions & 0 deletions test/code/helpers/iOSFactory.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
const { iOS } = require('../platforms');
const ChatActionSheetPage = require('../pages/popups/actionSheetPage/iOSChatActionSheetPage');
const FileUploadPage = require('../pages/files/fileUploadPage/iOSFileUploadPage');
const IosSettingsPage = require('../pages/settings/IosSettingsPage');

class iOSFactory {
get bundleId() {
return 'com.peerio';
}

get platform() {
return iOS;
}

chatActionSheetPage(app) {
return new ChatActionSheetPage(app);
}

fileUploadPage(app) {
return new FileUploadPage(app);
}

settingsPage(app) {
return new IosSettingsPage(app);
}
}

module.exports = new iOSFactory();
12 changes: 12 additions & 0 deletions test/code/pages/settings/AndroidSettingsPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const SettingsPage = require('./settingsPage');

const { selectorWithPartialText } = require('../../helpers/androidHelper');

class AndroidSettingsPage extends SettingsPage {
checkIfWebsiteHasOpened() {
const myUrl = selectorWithPartialText('support.peerio.com');
return this.getWhenVisible(myUrl);
}
}

module.exports = AndroidSettingsPage;
10 changes: 10 additions & 0 deletions test/code/pages/settings/IosSettingsPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const SettingsPage = require('./settingsPage');

class IosSettingsPage extends SettingsPage {
checkIfWebsiteHasOpened() {
console.log('Stub');
return true;
}
}

module.exports = IosSettingsPage;
12 changes: 12 additions & 0 deletions test/code/pages/settings/settingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ class SettingsPage extends Page {
get chatButton() {
return this.getWhenVisible('~title_contactPeerioSupport');
}

get visitButton() {
return this.getWhenPresent('~title_helpCenter');
}

get sendButton() {
return this.getWhenPresent('~title_sendLogsToSupport');
}

checkIfWebsiteHasOpened() {
throw new Error('Not implemented');
}
}

module.exports = SettingsPage;
29 changes: 29 additions & 0 deletions test/code/steps/helpSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { When, Then } = require('cucumber');

When('I go to help settings', async function() {
await this.homePage.settingsTab.click();
await this.settingsPage.helpButton.click();
});

When('I tap Chat button in help settings', async function() {
await this.settingsPage.chatButton.click();
});

When('I tap Send button in help settings', async function() {
await this.settingsPage.sendButton.click();
});

When('an e-mail opens in the native e-mail app', async function() {
// TODO: native e-mail check
return 'pending';
});

When('I tap Visit button in help settings', async function() {
await this.settingsPage.visitButton.click();
});

Then('the Peerio Zendesk opens in browser', async function() {
// should throw if not found for android
// should just continue on iOS
await this.settingsPage.checkIfWebsiteHasOpened();
});
9 changes: 0 additions & 9 deletions test/code/steps/profileSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,3 @@ When('I can see my account key', async function() {

await this.settingsPage.copyButton.click();
});

When('I go to help settings', async function() {
await this.homePage.settingsTab.click();
await this.settingsPage.helpButton.click();
});

When('I tap Chat button in help settings', async function() {
await this.settingsPage.chatButton.click();
});
2 changes: 1 addition & 1 deletion test/code/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class World {

this.contactsPage = new ContactsPage(this.app);

this.settingsPage = new SettingsPage(this.app);
this.settingsPage = this.context.settingsPage(this.app);
this.twoStepVerificationPage = new TwoStepVerificationPage(this.app);
this.twoFactorAuthPrompt = new TwoFactorAuthPrompt(this.app);
this.profileSettingsPage = new ProfileSettingsPage(this.app);
Expand Down
25 changes: 21 additions & 4 deletions test/spec/settings/help.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@ Feature: Mobile Help page
and view a help page that simply contains contact information for support and
support guides, so that I can find an answer to my problem.

Scenario: I want to chat with support
Given I log in as new user
Then I go to help settings
Background: I am on the help settings page
Given I log in as new user
And I go to help settings

Scenario: I want to visit the Peerio Help Center
When I tap Visit button in help settings
Then the Peerio Zendesk opens in browser

Scenario: I want to chat with support
When I tap Chat button in help settings
Then A chat opens with the support user
Then A chat opens with the support user

Scenario: I want to send logs to Peerio Support
When I tap Send button in help settings

#Then an e-mail opens in the native e-mail app

# NATIVE E-MAIL CHECK TO BE DONE:
# And all the logs are copied into the e-mail
# And the "to" field contains "support@peerio.com"
# When I tap send in the e-mail app
# Then I return to the "Help" screen

0 comments on commit 14f942a

Please sign in to comment.