platform dependent component types
This commit is contained in:
parent
af1de5711b
commit
ec22d9446a
|
@ -2,6 +2,7 @@ const {
|
||||||
device, expect, element, by, waitFor
|
device, expect, element, by, waitFor
|
||||||
} = require('detox');
|
} = require('detox');
|
||||||
const data = require('../data');
|
const data = require('../data');
|
||||||
|
const platformTypes = require('./platformTypes');
|
||||||
|
|
||||||
async function navigateToWorkspace(server = data.server) {
|
async function navigateToWorkspace(server = data.server) {
|
||||||
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
|
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
|
||||||
|
@ -36,12 +37,14 @@ async function login(username, password) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout() {
|
async function logout() {
|
||||||
|
const deviceType = device.getPlatform();
|
||||||
|
const scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||||
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
|
||||||
await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);
|
||||||
await element(by.id('sidebar-settings')).tap();
|
await element(by.id('sidebar-settings')).tap();
|
||||||
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
|
||||||
await element(by.type('android.widget.ScrollView')).atIndex(1).scrollTo('bottom');
|
await element(by.type(scrollViewType)).atIndex(1).scrollTo('bottom');
|
||||||
await element(by.id('settings-logout')).tap();
|
await element(by.id('settings-logout')).tap();
|
||||||
const logoutAlertMessage = 'You will be logged out of this application.';
|
const logoutAlertMessage = 'You will be logged out of this application.';
|
||||||
await waitFor(element(by.text(logoutAlertMessage)).atIndex(0)).toExist().withTimeout(10000);
|
await waitFor(element(by.text(logoutAlertMessage)).atIndex(0)).toExist().withTimeout(10000);
|
||||||
|
@ -83,8 +86,10 @@ async function pinMessage(message){
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dismissReviewNag(){
|
async function dismissReviewNag(){
|
||||||
|
const deviceType = device.getPlatform();
|
||||||
|
const alertButtonType = platformTypes[deviceType].alertButtonType;
|
||||||
await waitFor(element(by.text('Are you enjoying this app?'))).toExist().withTimeout(60000);
|
await waitFor(element(by.text('Are you enjoying this app?'))).toExist().withTimeout(60000);
|
||||||
await element(by.text('No').and(by.type('android.widget.Button'))).tap(); // Tap `no` on ask for review alert
|
await element(by.text('No').and(by.type(alertButtonType))).tap(); // Tap `no` on ask for review alert
|
||||||
}
|
}
|
||||||
|
|
||||||
async function tapBack() {
|
async function tapBack() {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
const { device } = require('detox');
|
exports.android = {
|
||||||
|
|
||||||
export default device.getPlatform() === 'android' ? {
|
|
||||||
//Android types
|
//Android types
|
||||||
alertButtonType: 'android.widget.Button',
|
alertButtonType: 'android.widget.Button',
|
||||||
scrollViewType: 'android.widget.ScrollView',
|
scrollViewType: 'android.widget.ScrollView',
|
||||||
textInputType: 'android.widget.EditText',
|
textInputType: 'android.widget.EditText',
|
||||||
} : {
|
};
|
||||||
|
|
||||||
|
exports.ios = {
|
||||||
//iOS types
|
//iOS types
|
||||||
alertButtonType: '_UIAlertControllerActionView',
|
alertButtonType: '_UIAlertControllerActionView',
|
||||||
scrollViewType: 'UIScrollView',
|
scrollViewType: 'UIScrollView',
|
||||||
|
|
|
@ -3,6 +3,8 @@ const {
|
||||||
} = require('detox');
|
} = require('detox');
|
||||||
const { navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout } = require('../../helpers/app');
|
const { navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout } = require('../../helpers/app');
|
||||||
|
|
||||||
|
const platformTypes = require('../../helpers/platformTypes');
|
||||||
|
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
|
|
||||||
const testuser = data.users.regular
|
const testuser = data.users.regular
|
||||||
|
@ -44,9 +46,13 @@ async function navigateSecurityPrivacy() {
|
||||||
describe('E2E Encryption', () => {
|
describe('E2E Encryption', () => {
|
||||||
const room = `encrypted${ data.random }`;
|
const room = `encrypted${ data.random }`;
|
||||||
const newPassword = 'abc';
|
const newPassword = 'abc';
|
||||||
|
let alertButtonType, scrollViewType;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
|
const deviceType = device.getPlatform();
|
||||||
|
alertButtonType = platformTypes[deviceType].alertButtonType;
|
||||||
|
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||||
await navigateToLogin();
|
await navigateToLogin();
|
||||||
await login(testuser.username, testuser.password);
|
await login(testuser.username, testuser.password);
|
||||||
});
|
});
|
||||||
|
@ -141,7 +147,7 @@ describe('E2E Encryption', () => {
|
||||||
await element(by.id('e2e-encryption-security-view-change-password')).tap();
|
await element(by.id('e2e-encryption-security-view-change-password')).tap();
|
||||||
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);
|
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);
|
||||||
await expect(element(by.text('Make sure you\'ve saved it carefully somewhere else.'))).toExist();
|
await expect(element(by.text('Make sure you\'ve saved it carefully somewhere else.'))).toExist();
|
||||||
await element(by.text('Yes, change it').and(by.type('android.widget.Button'))).tap();
|
await element(by.text('Yes, change it').and(by.type(alertButtonType))).tap();
|
||||||
await waitForToast();
|
await waitForToast();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -194,10 +200,10 @@ describe('E2E Encryption', () => {
|
||||||
await element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key'))).tap();
|
await element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key'))).tap();
|
||||||
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);
|
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);
|
||||||
await expect(element(by.text('You\'re going to be logged out.'))).toExist();
|
await expect(element(by.text('You\'re going to be logged out.'))).toExist();
|
||||||
await element(by.text('Yes, reset it').and(by.type('android.widget.Button'))).tap();
|
await element(by.text('Yes, reset it').and(by.type(alertButtonType))).tap();
|
||||||
await sleep(2000)
|
await sleep(2000)
|
||||||
await waitFor(element(by.text('OK').and(by.type('android.widget.Button')))).toExist().withTimeout(2000);
|
await waitFor(element(by.text('OK').and(by.type(alertButtonType)))).toExist().withTimeout(2000);
|
||||||
await element(by.text('OK').and(by.type('android.widget.Button'))).tap();
|
await element(by.text('OK').and(by.type(alertButtonType))).tap();
|
||||||
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);
|
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);
|
||||||
await element(by.id('workspace-view-login')).tap();
|
await element(by.id('workspace-view-login')).tap();
|
||||||
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
|
||||||
|
@ -231,7 +237,7 @@ describe('E2E Encryption', () => {
|
||||||
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
|
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
|
||||||
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
|
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
|
||||||
await element(by.id('register-view-password')).typeText(data.registeringUser.password);
|
await element(by.id('register-view-password')).typeText(data.registeringUser.password);
|
||||||
element(by.type('android.widget.ScrollView')).atIndex(1).scrollTo('bottom');
|
element(by.type(scrollViewType)).atIndex(1).scrollTo('bottom');
|
||||||
await element(by.id('register-view-submit')).tap();
|
await element(by.id('register-view-submit')).tap();
|
||||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,13 @@ async function waitForToast() {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Profile screen', () => {
|
describe('Profile screen', () => {
|
||||||
|
let textInputType, scrollViewType;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
|
const deviceType = device.getPlatform();
|
||||||
|
textInputType = platformTypes[deviceType].textInputType;
|
||||||
|
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||||
await navigateToLogin();
|
await navigateToLogin();
|
||||||
await login(profileChangeUser.username, profileChangeUser.password);
|
await login(profileChangeUser.username, profileChangeUser.password);
|
||||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||||
|
@ -79,7 +84,7 @@ describe('Profile screen', () => {
|
||||||
await element(by.id('profile-view-name')).replaceText(`${ profileChangeUser.username }new`);
|
await element(by.id('profile-view-name')).replaceText(`${ profileChangeUser.username }new`);
|
||||||
await element(by.id('profile-view-username')).typeText(`${ profileChangeUser.username }new`);
|
await element(by.id('profile-view-username')).typeText(`${ profileChangeUser.username }new`);
|
||||||
await device.pressBack();
|
await device.pressBack();
|
||||||
await element(by.type('android.widget.ScrollView')).atIndex(1).swipe('up');
|
await element(by.type(scrollViewType)).atIndex(1).swipe('up');
|
||||||
await element(by.id('profile-view-submit')).tap();
|
await element(by.id('profile-view-submit')).tap();
|
||||||
await waitForToast();
|
await waitForToast();
|
||||||
});
|
});
|
||||||
|
@ -88,13 +93,13 @@ describe('Profile screen', () => {
|
||||||
await element(by.id('profile-view-email')).replaceText(`mobile+profileChangesNew${ data.random }@rocket.chat`);
|
await element(by.id('profile-view-email')).replaceText(`mobile+profileChangesNew${ data.random }@rocket.chat`);
|
||||||
await element(by.id('profile-view-new-password')).replaceText(`${ profileChangeUser.password }new`);
|
await element(by.id('profile-view-new-password')).replaceText(`${ profileChangeUser.password }new`);
|
||||||
await element(by.id('profile-view-submit')).tap();
|
await element(by.id('profile-view-submit')).tap();
|
||||||
await element(by.type('android.widget.EditText')).typeText(`${ profileChangeUser.password }\n`);
|
await element(by.type(textInputType)).typeText(`${ profileChangeUser.password }\n`);
|
||||||
await element(by.text('SAVE')).tap();
|
await element(by.text('SAVE')).tap();
|
||||||
await waitForToast();
|
await waitForToast();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset avatar', async() => {
|
it('should reset avatar', async() => {
|
||||||
await element(by.type('android.widget.ScrollView')).atIndex(1).swipe('up');
|
await element(by.type(scrollViewType)).atIndex(1).swipe('up');
|
||||||
await element(by.id('profile-view-reset-avatar')).tap();
|
await element(by.id('profile-view-reset-avatar')).tap();
|
||||||
await waitForToast();
|
await waitForToast();
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,8 +8,11 @@ const data = require('../../data');
|
||||||
const testuser = data.users.regular
|
const testuser = data.users.regular
|
||||||
|
|
||||||
describe('Settings screen', () => {
|
describe('Settings screen', () => {
|
||||||
|
let alertButtonType;
|
||||||
before(async() => {
|
before(async() => {
|
||||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
|
const deviceType = device.getPlatform();
|
||||||
|
alertButtonType = platformTypes[deviceType].alertButtonType;
|
||||||
await navigateToLogin();
|
await navigateToLogin();
|
||||||
await login(testuser.username, testuser.password);
|
await login(testuser.username, testuser.password);
|
||||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
|
||||||
|
@ -67,7 +70,7 @@ describe('Settings screen', () => {
|
||||||
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
|
||||||
await element(by.id('settings-view-clear-cache')).tap();
|
await element(by.id('settings-view-clear-cache')).tap();
|
||||||
await waitFor(element(by.text('This will clear all your offline data.'))).toExist().withTimeout(2000);
|
await waitFor(element(by.text('This will clear all your offline data.'))).toExist().withTimeout(2000);
|
||||||
await element(by.text('Clear').and(by.type('android.widget.Button'))).tap();
|
await element(by.text('Clear').and(by.type(alertButtonType))).tap();
|
||||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(5000);
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(5000);
|
||||||
await waitFor(element(by.id(`rooms-list-view-item-${ data.groups.private.name }`))).toExist().withTimeout(10000);
|
await waitFor(element(by.id(`rooms-list-view-item-${ data.groups.private.name }`))).toExist().withTimeout(10000);
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,8 +19,11 @@ async function navigateToRoomActions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Join public room', () => {
|
describe('Join public room', () => {
|
||||||
|
let scrollViewType;
|
||||||
before(async() => {
|
before(async() => {
|
||||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
|
const deviceType = device.getPlatform();
|
||||||
|
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||||
await navigateToLogin();
|
await navigateToLogin();
|
||||||
await login(testuser.username, testuser.password);
|
await login(testuser.username, testuser.password);
|
||||||
await navigateToRoom();
|
await navigateToRoom();
|
||||||
|
@ -151,11 +154,11 @@ describe('Join public room', () => {
|
||||||
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
|
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
|
||||||
await expect(element(by.id('room-actions-starred'))).toBeVisible();
|
await expect(element(by.id('room-actions-starred'))).toBeVisible();
|
||||||
// await expect(element(by.id('room-actions-search'))).toBeVisible();
|
// await expect(element(by.id('room-actions-search'))).toBeVisible();
|
||||||
await element(by.type('android.widget.ScrollView')).atIndex(1).swipe('down');
|
await element(by.type(scrollViewType)).atIndex(1).swipe('down');
|
||||||
await expect(element(by.id('room-actions-share'))).toBeVisible();
|
await expect(element(by.id('room-actions-share'))).toBeVisible();
|
||||||
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
|
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
|
||||||
await expect(element(by.id('room-actions-notifications'))).toBeVisible();
|
await expect(element(by.id('room-actions-notifications'))).toBeVisible();
|
||||||
await element(by.type('android.widget.ScrollView')).atIndex(0).swipe('up');
|
await element(by.type(scrollViewType)).atIndex(0).swipe('up');
|
||||||
await expect(element(by.id('room-actions-leave-channel'))).toBeVisible();
|
await expect(element(by.id('room-actions-leave-channel'))).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,12 @@ const data = require('../../data');
|
||||||
const { sleep, navigateToLogin, login, checkServer } = require('../../helpers/app');
|
const { sleep, navigateToLogin, login, checkServer } = require('../../helpers/app');
|
||||||
|
|
||||||
describe('Delete server', () => {
|
describe('Delete server', () => {
|
||||||
|
let scrollViewType, alertButtonType;
|
||||||
before(async() => {
|
before(async() => {
|
||||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
|
const deviceType = device.getPlatform();
|
||||||
|
alertButtonType = platformTypes[deviceType].alertButtonType;
|
||||||
|
scrollViewType = platformTypes[deviceType].scrollViewType;
|
||||||
await navigateToLogin();
|
await navigateToLogin();
|
||||||
await login(data.users.regular.username, data.users.regular.password);
|
await login(data.users.regular.username, data.users.regular.password);
|
||||||
});
|
});
|
||||||
|
@ -32,7 +36,7 @@ describe('Delete server', () => {
|
||||||
await element(by.id('register-view-username')).replaceText(data.registeringUser3.username);
|
await element(by.id('register-view-username')).replaceText(data.registeringUser3.username);
|
||||||
await element(by.id('register-view-email')).replaceText(data.registeringUser3.email);
|
await element(by.id('register-view-email')).replaceText(data.registeringUser3.email);
|
||||||
await element(by.id('register-view-password')).typeText(data.registeringUser3.password);
|
await element(by.id('register-view-password')).typeText(data.registeringUser3.password);
|
||||||
await element(by.type('android.widget.ScrollView')).atIndex(0).swipe('up');
|
await element(by.type(scrollViewType)).atIndex(0).swipe('up');
|
||||||
await element(by.id('register-view-submit')).tap();
|
await element(by.id('register-view-submit')).tap();
|
||||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
|
||||||
|
|
||||||
|
@ -43,7 +47,7 @@ describe('Delete server', () => {
|
||||||
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
||||||
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
|
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
|
||||||
await element(by.id(`rooms-list-header-server-${ data.server }`)).longPress(1500);
|
await element(by.id(`rooms-list-header-server-${ data.server }`)).longPress(1500);
|
||||||
await element(by.text('Delete').and(by.type('android.widget.Button'))).tap();
|
await element(by.text('Delete').and(by.type(alertButtonType))).tap();
|
||||||
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
||||||
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
|
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
|
||||||
await waitFor(element(by.id(`rooms-list-header-server-${ data.server }`))).toBeNotVisible().withTimeout(10000);
|
await waitFor(element(by.id(`rooms-list-header-server-${ data.server }`))).toBeNotVisible().withTimeout(10000);
|
||||||
|
|
Loading…
Reference in New Issue