Chore: Add Lint to E2E tests (#3217)

* Added eslint plugin dependencie and fixed the eslint.js

* E2E Tests folder Assorted

* Linted all e2e, just e2e/docker that don't changed

* Update 09-jumptomessage.spec.js

* Removed async from describe function

* Remove outdated detox linter lib

* Add overrides to eslintrc

Co-authored-by: Gerzon Z <gerzonc@icloud.com>
Co-authored-by: Gerzon Z <gerzonzcanario@gmail.com>
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Reinaldo Neto 2021-07-02 14:39:39 -03:00 committed by GitHub
parent d547b6129f
commit 8517b1fd13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 905 additions and 951 deletions

View File

@ -1,6 +1,6 @@
__tests__ __tests__
node_modules node_modules
coverage coverage
e2e e2e/docker
android android
ios ios

View File

@ -29,7 +29,8 @@ module.exports = {
"commonjs": true, "commonjs": true,
"es6": true, "es6": true,
"node": true, "node": true,
"jquery": true "jquery": true,
"mocha": true
}, },
"rules": { "rules": {
"react/jsx-filename-extension": [1, { "react/jsx-filename-extension": [1, {
@ -155,5 +156,23 @@ module.exports = {
}, },
"globals": { "globals": {
"__DEV__": true "__DEV__": true
} },
overrides: [
{
files: ['e2e/**'],
globals: {
by: true,
detox: true,
device: true,
element: true,
expect: true,
waitFor: true
},
rules: {
'import/no-extraneous-dependencies': 0,
'no-await-in-loop': 0,
'no-restricted-syntax': 0
}
}
]
}; };

View File

@ -1,75 +1,76 @@
const random = require('./helpers/random'); const random = require('./helpers/random');
const value = random(20); const value = random(20);
const data = { const data = {
server: 'https://mobile.rocket.chat', server: 'https://mobile.rocket.chat',
adminUser: 'e2e_admin', adminUser: 'e2e_admin',
adminPassword: 'p7mFh4yLwCRXSnMvG', adminPassword: 'p7mFh4yLwCRXSnMvG',
alternateServer: 'https://stable.rocket.chat', alternateServer: 'https://stable.rocket.chat',
users: { users: {
regular: { regular: {
username: `userone${ value }`, username: `userone${ value }`,
password: '123', password: '123',
email: `mobile+regular${ value }@rocket.chat` email: `mobile+regular${ value }@rocket.chat`
}, },
alternate: { alternate: {
username: `usertwo${ value }`, username: `usertwo${ value }`,
password: '123', password: '123',
email: `mobile+alternate${ value }@rocket.chat`, email: `mobile+alternate${ value }@rocket.chat`,
totpSecret: 'NA4GOMZGHBQSK6KEFRVT62DMGJJGSYZJFZIHO3ZOGVXWCYZ6MMZQ' totpSecret: 'NA4GOMZGHBQSK6KEFRVT62DMGJJGSYZJFZIHO3ZOGVXWCYZ6MMZQ'
}, },
profileChanges: { profileChanges: {
username: `userthree${ value }`, username: `userthree${ value }`,
password: '123', password: '123',
email: `mobile+profileChanges${ value }@rocket.chat` email: `mobile+profileChanges${ value }@rocket.chat`
}, },
existing: { existing: {
username: `existinguser${ value }`, username: `existinguser${ value }`,
password: '123', password: '123',
email: `mobile+existing${ value }@rocket.chat` email: `mobile+existing${ value }@rocket.chat`
} }
}, },
channels: { channels: {
detoxpublic: { detoxpublic: {
name: 'detox-public' name: 'detox-public'
}, },
detoxpublicprotected: { detoxpublicprotected: {
name: 'detox-public-protected', name: 'detox-public-protected',
joinCode: '123' joinCode: '123'
} }
}, },
groups: { groups: {
private: { private: {
name: `detox-private-${ value }` name: `detox-private-${ value }`
}, },
alternate: { alternate: {
name: `detox-alternate-${ value }` name: `detox-alternate-${ value }`
} }
}, },
teams: { teams: {
private: { private: {
name: `detox-team-${ value }` name: `detox-team-${ value }`
} }
}, },
registeringUser: { registeringUser: {
username: `newuser${ value }`, username: `newuser${ value }`,
password: `password${ value }`, password: `password${ value }`,
email: `mobile+registering${ value }@rocket.chat` email: `mobile+registering${ value }@rocket.chat`
}, },
registeringUser2: { registeringUser2: {
username: `newusertwo${ value }`, username: `newusertwo${ value }`,
password: `passwordtwo${ value }`, password: `passwordtwo${ value }`,
email: `mobile+registeringtwo${ value }@rocket.chat` email: `mobile+registeringtwo${ value }@rocket.chat`
}, },
registeringUser3: { registeringUser3: {
username: `newuserthree${ value }`, username: `newuserthree${ value }`,
password: `passwordthree${ value }`, password: `passwordthree${ value }`,
email: `mobile+registeringthree${ value }@rocket.chat` email: `mobile+registeringthree${ value }@rocket.chat`
}, },
registeringUser4: { registeringUser4: {
username: `newuserfour${ value }`, username: `newuserfour${ value }`,
password: `passwordfour${ value }`, password: `passwordfour${ value }`,
email: `mobile+registeringfour${ value }@rocket.chat` email: `mobile+registeringfour${ value }@rocket.chat`
}, },
random: value random: value
} };
module.exports = data; module.exports = data;

View File

@ -1,72 +1,74 @@
// eslint-disable-next-line import/no-unresolved
const random = require('./helpers/random'); const random = require('./helpers/random');
const value = random(20); const value = random(20);
const data = { const data = {
server: 'https://mobile.rocket.chat', server: 'https://mobile.rocket.chat',
adminUser: 'e2e_admin', adminUser: 'e2e_admin',
adminPassword: 'p7mFh4yLwCRXSnMvG', adminPassword: 'p7mFh4yLwCRXSnMvG',
alternateServer: 'https://stable.rocket.chat', alternateServer: 'https://stable.rocket.chat',
users: { users: {
regular: { regular: {
username: `userone${ value }`, username: `userone${ value }`,
password: '123', password: '123',
email: `mobile+regular${ value }@rocket.chat` email: `mobile+regular${ value }@rocket.chat`
}, },
alternate: { alternate: {
username: `usertwo${ value }`, username: `usertwo${ value }`,
password: '123', password: '123',
email: `mobile+alternate${ value }@rocket.chat`, email: `mobile+alternate${ value }@rocket.chat`,
totpSecret: 'NA4GOMZGHBQSK6KEFRVT62DMGJJGSYZJFZIHO3ZOGVXWCYZ6MMZQ' totpSecret: 'NA4GOMZGHBQSK6KEFRVT62DMGJJGSYZJFZIHO3ZOGVXWCYZ6MMZQ'
}, },
profileChanges: { profileChanges: {
username: `userthree${ value }`, username: `userthree${ value }`,
password: '123', password: '123',
email: `mobile+profileChanges${ value }@rocket.chat` email: `mobile+profileChanges${ value }@rocket.chat`
}, },
existing: { existing: {
username: `existinguser${ value }`, username: `existinguser${ value }`,
password: '123', password: '123',
email: `mobile+existing${ value }@rocket.chat` email: `mobile+existing${ value }@rocket.chat`
} }
}, },
channels: { channels: {
detoxpublic: { detoxpublic: {
name: 'detox-public' name: 'detox-public'
}, },
detoxpublicprotected: { detoxpublicprotected: {
name: 'detox-public-protected', name: 'detox-public-protected',
joinCode: '123' joinCode: '123'
} }
}, },
groups: { groups: {
private: { private: {
name: `detox-private-${ value }` name: `detox-private-${ value }`
} }
}, },
teams: { teams: {
private: { private: {
name: `detox-team-${ value }` name: `detox-team-${ value }`
} }
}, },
registeringUser: { registeringUser: {
username: `newuser${ value }`, username: `newuser${ value }`,
password: `password${ value }`, password: `password${ value }`,
email: `mobile+registering${ value }@rocket.chat` email: `mobile+registering${ value }@rocket.chat`
}, },
registeringUser2: { registeringUser2: {
username: `newusertwo${ value }`, username: `newusertwo${ value }`,
password: `passwordtwo${ value }`, password: `passwordtwo${ value }`,
email: `mobile+registeringtwo${ value }@rocket.chat` email: `mobile+registeringtwo${ value }@rocket.chat`
}, },
registeringUser3: { registeringUser3: {
username: `newuserthree${ value }`, username: `newuserthree${ value }`,
password: `passwordthree${ value }`, password: `passwordthree${ value }`,
email: `mobile+registeringthree${ value }@rocket.chat` email: `mobile+registeringthree${ value }@rocket.chat`
}, },
registeringUser4: { registeringUser4: {
username: `newuserfour${ value }`, username: `newuserfour${ value }`,
password: `passwordfour${ value }`, password: `passwordfour${ value }`,
email: `mobile+registeringfour${ value }@rocket.chat` email: `mobile+registeringfour${ value }@rocket.chat`
}, },
random: value random: value
} };
module.exports = data; module.exports = data;

View File

@ -1,75 +1,77 @@
// eslint-disable-next-line import/no-unresolved
const random = require('./helpers/random'); const random = require('./helpers/random');
const value = random(20); const value = random(20);
const data = { const data = {
server: 'http://localhost:3000', server: 'http://localhost:3000',
adminUser: 'admin', adminUser: 'admin',
adminPassword: 'password', adminPassword: 'password',
alternateServer: 'https://stable.rocket.chat', alternateServer: 'https://stable.rocket.chat',
users: { users: {
regular: { regular: {
username: `userone${ value }`, username: `userone${ value }`,
password: '123', password: '123',
email: `mobile+regular${ value }@rocket.chat` email: `mobile+regular${ value }@rocket.chat`
}, },
alternate: { alternate: {
username: `usertwo${ value }`, username: `usertwo${ value }`,
password: '123', password: '123',
email: `mobile+alternate${ value }@rocket.chat`, email: `mobile+alternate${ value }@rocket.chat`,
totpSecret: 'NA4GOMZGHBQSK6KEFRVT62DMGJJGSYZJFZIHO3ZOGVXWCYZ6MMZQ' totpSecret: 'NA4GOMZGHBQSK6KEFRVT62DMGJJGSYZJFZIHO3ZOGVXWCYZ6MMZQ'
}, },
profileChanges: { profileChanges: {
username: `userthree${ value }`, username: `userthree${ value }`,
password: '123', password: '123',
email: `mobile+profileChanges${ value }@rocket.chat` email: `mobile+profileChanges${ value }@rocket.chat`
}, },
existing: { existing: {
username: `existinguser${ value }`, username: `existinguser${ value }`,
password: '123', password: '123',
email: `mobile+existing${ value }@rocket.chat` email: `mobile+existing${ value }@rocket.chat`
} }
}, },
channels: { channels: {
detoxpublic: { detoxpublic: {
name: 'detox-public' name: 'detox-public'
}, },
detoxpublicprotected: { detoxpublicprotected: {
name: 'detox-public-protected', name: 'detox-public-protected',
joinCode: '123' joinCode: '123'
} }
}, },
groups: { groups: {
private: { private: {
name: `detox-private-${ value }` name: `detox-private-${ value }`
}, },
alternate: { alternate: {
name: `detox-alternate-${ value }` name: `detox-alternate-${ value }`
} }
}, },
teams: { teams: {
private: { private: {
name: `detox-team-${ value }` name: `detox-team-${ value }`
} }
}, },
registeringUser: { registeringUser: {
username: `newuser${ value }`, username: `newuser${ value }`,
password: `password${ value }`, password: `password${ value }`,
email: `mobile+registering${ value }@rocket.chat` email: `mobile+registering${ value }@rocket.chat`
}, },
registeringUser2: { registeringUser2: {
username: `newusertwo${ value }`, username: `newusertwo${ value }`,
password: `passwordtwo${ value }`, password: `passwordtwo${ value }`,
email: `mobile+registeringtwo${ value }@rocket.chat` email: `mobile+registeringtwo${ value }@rocket.chat`
}, },
registeringUser3: { registeringUser3: {
username: `newuserthree${ value }`, username: `newuserthree${ value }`,
password: `passwordthree${ value }`, password: `passwordthree${ value }`,
email: `mobile+registeringthree${ value }@rocket.chat` email: `mobile+registeringthree${ value }@rocket.chat`
}, },
registeringUser4: { registeringUser4: {
username: `newuserfour${ value }`, username: `newuserfour${ value }`,
password: `passwordfour${ value }`, password: `passwordfour${ value }`,
email: `mobile+registeringfour${ value }@rocket.chat` email: `mobile+registeringfour${ value }@rocket.chat`
}, },
random: value random: value
} };
module.exports = data; module.exports = data;

View File

@ -1,122 +1,119 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../data'); const data = require('../data');
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);
await element(by.id('join-workspace')).tap(); await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${server}\n`); await element(by.id('new-server-view-input')).typeText(`${ server }\n`);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('workspace-view'))).toBeVisible(); await expect(element(by.id('workspace-view'))).toBeVisible();
} }
async function navigateToLogin(server) { async function navigateToLogin(server) {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000); await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
await navigateToWorkspace(server); await navigateToWorkspace(server);
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);
await expect(element(by.id('login-view'))).toBeVisible(); await expect(element(by.id('login-view'))).toBeVisible();
} }
async function navigateToRegister(server) { async function navigateToRegister(server) {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000); await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
await navigateToWorkspace(server); await navigateToWorkspace(server);
await element(by.id('workspace-view-register')).tap(); await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
} }
async function login(username, password) { async function login(username, password) {
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
await element(by.id('login-view-email')).replaceText(username); await element(by.id('login-view-email')).replaceText(username);
await element(by.id('login-view-password')).replaceText(password); await element(by.id('login-view-password')).replaceText(password);
await element(by.id('login-view-submit')).tap(); await element(by.id('login-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(30000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(30000);
} }
async function logout() { async function logout() {
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('UIScrollView')).atIndex(1).scrollTo('bottom'); await element(by.type('UIScrollView')).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);
await expect(element(by.text(logoutAlertMessage)).atIndex(0)).toExist(); await expect(element(by.text(logoutAlertMessage)).atIndex(0)).toExist();
await element(by.text('Logout')).tap(); await element(by.text('Logout')).tap();
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
await expect(element(by.id('onboarding-view'))).toBeVisible(); await expect(element(by.id('onboarding-view'))).toBeVisible();
} }
async function mockMessage(message, isThread = false) { async function mockMessage(message, isThread = false) {
let input = isThread ? 'messagebox-input-thread' : 'messagebox-input'; const input = isThread ? 'messagebox-input-thread' : 'messagebox-input';
await element(by.id(input)).tap(); await element(by.id(input)).tap();
await element(by.id(input)).typeText(`${ data.random }${ message }`); await element(by.id(input)).typeText(`${ data.random }${ message }`);
await element(by.id('messagebox-send-message')).tap(); await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by.label(`${ data.random }${ message }`))).toExist().withTimeout(60000); await waitFor(element(by.label(`${ data.random }${ message }`))).toExist().withTimeout(60000);
await expect(element(by.label(`${ data.random }${ message }`))).toExist(); await expect(element(by.label(`${ data.random }${ message }`))).toExist();
await element(by.label(`${ data.random }${ message }`)).atIndex(0).tap(); await element(by.label(`${ data.random }${ message }`)).atIndex(0).tap();
};
async function starMessage(message){
const messageLabel = `${ data.random }${ message }`
await element(by.label(messageLabel)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.label('Star')).atIndex(0).tap();
await waitFor(element(by.id('action-sheet'))).not.toExist().withTimeout(5000);
};
async function pinMessage(message){
const messageLabel = `${ data.random }${ message }`
await waitFor(element(by.label(messageLabel)).atIndex(0)).toExist();
await element(by.label(messageLabel)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.label('Pin')).atIndex(0).tap();
await waitFor(element(by.id('action-sheet'))).not.toExist().withTimeout(5000);
} }
async function dismissReviewNag(){ async function starMessage(message) {
await waitFor(element(by.text('Are you enjoying this app?'))).toExist().withTimeout(60000); const messageLabel = `${ data.random }${ message }`;
await element(by.label('No').and(by.type('_UIAlertControllerActionView'))).tap(); // Tap `no` on ask for review alert await element(by.label(messageLabel)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.label('Star')).atIndex(0).tap();
await waitFor(element(by.id('action-sheet'))).not.toExist().withTimeout(5000);
}
async function pinMessage(message) {
const messageLabel = `${ data.random }${ message }`;
await waitFor(element(by.label(messageLabel)).atIndex(0)).toExist();
await element(by.label(messageLabel)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.label('Pin')).atIndex(0).tap();
await waitFor(element(by.id('action-sheet'))).not.toExist().withTimeout(5000);
}
async function dismissReviewNag() {
await waitFor(element(by.text('Are you enjoying this app?'))).toExist().withTimeout(60000);
await element(by.label('No').and(by.type('_UIAlertControllerActionView'))).tap(); // Tap `no` on ask for review alert
} }
async function tapBack() { async function tapBack() {
await element(by.id('header-back')).atIndex(0).tap(); await element(by.id('header-back')).atIndex(0).tap();
} }
async function sleep(ms) { function sleep(ms) {
return new Promise(res => setTimeout(res, ms)); return new Promise(res => setTimeout(res, ms));
} }
async function searchRoom(room) { async function searchRoom(room) {
await element(by.id('rooms-list-view-search')).tap(); await element(by.id('rooms-list-view-search')).tap();
await expect(element(by.id('rooms-list-view-search-input'))).toExist(); await expect(element(by.id('rooms-list-view-search-input'))).toExist();
await waitFor(element(by.id('rooms-list-view-search-input'))).toExist().withTimeout(5000); await waitFor(element(by.id('rooms-list-view-search-input'))).toExist().withTimeout(5000);
await element(by.id('rooms-list-view-search-input')).typeText(room); await element(by.id('rooms-list-view-search-input')).typeText(room);
await sleep(300); await sleep(300);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000); await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000);
} }
async function tryTapping(theElement, timeout, longtap = false){ async function tryTapping(theElement, timeout, longtap = false) {
try { try {
if(longtap){ if (longtap) {
await theElement.longPress() await theElement.longPress();
} else { } else {
await theElement.tap() await theElement.tap();
}
} catch(e) {
if(timeout <= 0){ //TODO: Maths. How closely has the timeout been honoured here?
throw e
} }
await sleep(100) } catch (e) {
await tryTapping(theElement, timeout - 100) if (timeout <= 0) { // TODO: Maths. How closely has the timeout been honoured here?
throw e;
}
await sleep(100);
await tryTapping(theElement, timeout - 100);
} }
} }
@ -126,21 +123,21 @@ const checkServer = async(server) => {
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
await waitFor(element(by.label(label))).toBeVisible().withTimeout(10000); await waitFor(element(by.label(label))).toBeVisible().withTimeout(10000);
await element(by.id('sidebar-close-drawer')).tap(); await element(by.id('sidebar-close-drawer')).tap();
} };
module.exports = { module.exports = {
navigateToWorkspace, navigateToWorkspace,
navigateToLogin, navigateToLogin,
navigateToRegister, navigateToRegister,
login, login,
logout, logout,
mockMessage, mockMessage,
starMessage, starMessage,
pinMessage, pinMessage,
dismissReviewNag, dismissReviewNag,
tapBack, tapBack,
sleep, sleep,
searchRoom, searchRoom,
tryTapping, tryTapping,
checkServer checkServer
}; };

View File

@ -6,176 +6,174 @@ const TEAM_TYPE = {
PRIVATE: 1 PRIVATE: 1
}; };
let server = data.server const { server } = data;
const rocketchat = axios.create({ const rocketchat = axios.create({
baseURL: `${server}/api/v1/`, baseURL: `${ server }/api/v1/`,
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8'
} }
}) });
const login = async (username, password) => { const login = async(username, password) => {
console.log(`Logging in as user ${username}`) console.log(`Logging in as user ${ username }`);
const response = await rocketchat.post('login', { const response = await rocketchat.post('login', {
"user": username, user: username,
"password": password password
}) });
const userId = response.data.data.userId const { userId } = response.data.data;
const authToken = response.data.data.authToken const { authToken } = response.data.data;
rocketchat.defaults.headers.common['X-User-Id'] = userId rocketchat.defaults.headers.common['X-User-Id'] = userId;
rocketchat.defaults.headers.common['X-Auth-Token'] = authToken rocketchat.defaults.headers.common['X-Auth-Token'] = authToken;
return { authToken, userId }; return { authToken, userId };
} };
const createUser = async (username, password, name, email) => { const createUser = async(username, password, name, email) => {
console.log(`Creating user ${username}`) console.log(`Creating user ${ username }`);
try { try {
await rocketchat.post('users.create', { await rocketchat.post('users.create', {
"username": username, username,
"password": password, password,
"name": name, name,
"email": email email
}) });
} catch (error) { } catch (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error));
throw "Failed to create user" throw new Error('Failed to create user');
} }
} };
const createChannelIfNotExists = async (channelname) => { const createChannelIfNotExists = async(channelname) => {
console.log(`Creating public channel ${channelname}`) console.log(`Creating public channel ${ channelname }`);
try { try {
const room = await rocketchat.post('channels.create', { const room = await rocketchat.post('channels.create', {
"name": channelname name: channelname
}) });
return room return room;
} catch (createError) { } catch (createError) {
try { //Maybe it exists already? try { // Maybe it exists already?
const room = rocketchat.get(`channels.info?roomName=${channelname}`) const room = rocketchat.get(`channels.info?roomName=${ channelname }`);
return room return room;
} catch (infoError) { } catch (infoError) {
console.log(JSON.stringify(createError)) console.log(JSON.stringify(createError));
console.log(JSON.stringify(infoError)) console.log(JSON.stringify(infoError));
throw "Failed to find or create public channel" throw new Error('Failed to find or create public channel');
} }
} }
} };
const createTeamIfNotExists = async (teamname) => { const createTeamIfNotExists = async(teamname) => {
console.log(`Creating private team ${teamname}`) console.log(`Creating private team ${ teamname }`);
try { try {
await rocketchat.post('teams.create', { await rocketchat.post('teams.create', {
"name": teamname, name: teamname,
"type": TEAM_TYPE.PRIVATE type: TEAM_TYPE.PRIVATE
}) });
} catch (createError) { } catch (createError) {
try { //Maybe it exists already? try { // Maybe it exists already?
await rocketchat.get(`teams.info?teamName=${teamname}`) await rocketchat.get(`teams.info?teamName=${ teamname }`);
} catch (infoError) { } catch (infoError) {
console.log(JSON.stringify(createError)) console.log(JSON.stringify(createError));
console.log(JSON.stringify(infoError)) console.log(JSON.stringify(infoError));
throw "Failed to find or create private team" throw new Error('Failed to find or create private team');
} }
} }
} };
const createGroupIfNotExists = async (groupname) => { const createGroupIfNotExists = async(groupname) => {
console.log(`Creating private group ${groupname}`) console.log(`Creating private group ${ groupname }`);
try { try {
await rocketchat.post('groups.create', { await rocketchat.post('groups.create', {
"name": groupname name: groupname
}) });
} catch (createError) { } catch (createError) {
try { //Maybe it exists already? try { // Maybe it exists already?
await rocketchat.get(`groups.info?roomName=${groupname}`) await rocketchat.get(`groups.info?roomName=${ groupname }`);
} catch (infoError) { } catch (infoError) {
console.log(JSON.stringify(createError)) console.log(JSON.stringify(createError));
console.log(JSON.stringify(infoError)) console.log(JSON.stringify(infoError));
throw "Failed to find or create private group" throw new Error('Failed to find or create private group');
} }
} }
} };
const changeChannelJoinCode = async (roomId, joinCode) => { const changeChannelJoinCode = async(roomId, joinCode) => {
console.log(`Changing channel Join Code ${roomId}`) console.log(`Changing channel Join Code ${ roomId }`);
try { try {
await rocketchat.post('method.call/saveRoomSettings', { await rocketchat.post('method.call/saveRoomSettings', {
message: JSON.stringify({ message: JSON.stringify({
method: 'saveRoomSettings', method: 'saveRoomSettings',
params: [ params: [
roomId, roomId,
{ joinCode } { joinCode }
] ]
}) })
}) });
} catch (createError) { } catch (createError) {
console.log(JSON.stringify(createError)) console.log(JSON.stringify(createError));
throw "Failed to create protected channel" throw new Error('Failed to create protected channel');
} }
} };
const sendMessage = async (user, channel, msg) => { const sendMessage = async(user, channel, msg) => {
console.log(`Sending message to ${channel}`) console.log(`Sending message to ${ channel }`);
try { try {
await login(user.username, user.password); await login(user.username, user.password);
await rocketchat.post('chat.postMessage', { channel, msg }); await rocketchat.post('chat.postMessage', { channel, msg });
} catch (infoError) { } catch (infoError) {
console.log(JSON.stringify(infoError)) console.log(JSON.stringify(infoError));
throw "Failed to find or create private group" throw new Error('Failed to find or create private group');
} }
} };
const setup = async () => { const setup = async() => {
await login(data.adminUser, data.adminPassword) await login(data.adminUser, data.adminPassword);
for (var userKey in data.users) {
if (data.users.hasOwnProperty(userKey)) {
const user = data.users[userKey]
await createUser(user.username, user.password, user.username, user.email)
}
}
for (var channelKey in data.channels) { for (const userKey in data.users) {
if (data.channels.hasOwnProperty(channelKey)) { if (Object.prototype.hasOwnProperty.call(data.users, userKey)) {
const channel = data.channels[channelKey] const user = data.users[userKey];
const { data: { channel: { _id } } } = await createChannelIfNotExists(channel.name) await createUser(user.username, user.password, user.username, user.email);
}
}
if (channel.joinCode) { for (const channelKey in data.channels) {
await changeChannelJoinCode(_id, channel.joinCode); if (Object.prototype.hasOwnProperty.call(data.channels, channelKey)) {
} const channel = data.channels[channelKey];
} const { data: { channel: { _id } } } = await createChannelIfNotExists(channel.name);
}
await login(data.users.regular.username, data.users.regular.password) if (channel.joinCode) {
await changeChannelJoinCode(_id, channel.joinCode);
}
}
}
for (var groupKey in data.groups) { await login(data.users.regular.username, data.users.regular.password);
if (data.groups.hasOwnProperty(groupKey)) {
const group = data.groups[groupKey]
await createGroupIfNotExists(group.name)
}
}
for (var teamKey in data.teams) { for (const groupKey in data.groups) {
if (data.teams.hasOwnProperty(teamKey)) { if (Object.prototype.hasOwnProperty.call(data.groups, groupKey)) {
const team = data.teams[teamKey] const group = data.groups[groupKey];
await createTeamIfNotExists(team.name) await createGroupIfNotExists(group.name);
} }
} }
return for (const teamKey in data.teams) {
} if (Object.prototype.hasOwnProperty.call(data.teams, teamKey)) {
const team = data.teams[teamKey];
await createTeamIfNotExists(team.name);
}
}
};
const get = (endpoint) => { const get = (endpoint) => {
console.log(`GET /${ endpoint }`) console.log(`GET /${ endpoint }`);
return rocketchat.get(endpoint); return rocketchat.get(endpoint);
} };
const post = (endpoint, body) => { const post = (endpoint, body) => {
console.log(`POST /${ endpoint } ${ JSON.stringify(body) }`) console.log(`POST /${ endpoint } ${ JSON.stringify(body) }`);
return rocketchat.post(endpoint, body); return rocketchat.post(endpoint, body);
} };
module.exports = { module.exports = {
setup, sendMessage, get, post, login setup, sendMessage, get, post, login
} };

View File

@ -6,4 +6,4 @@ function random(length) {
} }
return text; return text;
} }
module.exports = random; module.exports = random;

View File

@ -1,12 +1,11 @@
const { const {
expect, element, by, waitFor navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout
} = require('detox'); } = require('../../helpers/app');
const { navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
const testuser = data.users.regular const testuser = data.users.regular;
const otheruser = data.users.alternate const otheruser = data.users.alternate;
const checkServer = async(server) => { const checkServer = async(server) => {
const label = `Connected to ${ server }`; const label = `Connected to ${ server }`;
@ -14,11 +13,11 @@ const checkServer = async(server) => {
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
await waitFor(element(by.label(label))).toBeVisible().withTimeout(60000); await waitFor(element(by.label(label))).toBeVisible().withTimeout(60000);
await element(by.id('sidebar-close-drawer')).tap(); await element(by.id('sidebar-close-drawer')).tap();
} };
const checkBanner = async() => { const checkBanner = async() => {
await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(10000);
} };
async function navigateToRoom(roomName) { async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`); await searchRoom(`${ roomName }`);
@ -45,36 +44,36 @@ describe('E2E Encryption', () => {
const room = `encrypted${ data.random }`; const room = `encrypted${ data.random }`;
const newPassword = 'abc'; const newPassword = 'abc';
before(async () => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin(); await navigateToLogin();
await login(testuser.username, testuser.password); await login(testuser.username, testuser.password);
}); });
describe('Banner', async() => { describe('Banner', () => {
describe('Render', async () => { describe('Render', () => {
it('should have encryption badge', async () => { it('should have encryption badge', async() => {
await checkBanner(); await checkBanner();
}); });
}); });
describe('Usage', async () => { describe('Usage', () => {
it('should tap encryption badge and open save password modal', async() => { it('should tap encryption badge and open save password modal', async() => {
await element(by.id('listheader-encryption')).tap(); await element(by.id('listheader-encryption')).tap();
await waitFor(element(by.id('e2e-save-password-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('e2e-save-password-view'))).toBeVisible().withTimeout(2000);
}); });
it('should tap "How it works" and navigate', async() => { it('should tap "How it works" and navigate', async() => {
await element(by.id('e2e-save-password-view-how-it-works').and(by.label('How It Works'))).tap(); await element(by.id('e2e-save-password-view-how-it-works').and(by.label('How It Works'))).tap();
await waitFor(element(by.id('e2e-how-it-works-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('e2e-how-it-works-view'))).toBeVisible().withTimeout(2000);
await tapBack(); await tapBack();
}); });
it('should tap "Save my password" and close modal', async() => { it('should tap "Save my password" and close modal', async() => {
await element(by.id('e2e-save-password-view-saved-password').and(by.label('I Saved My E2E Password'))).tap(); await element(by.id('e2e-save-password-view-saved-password').and(by.label('I Saved My E2E Password'))).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
}); });
it('should create encrypted room', async() => { it('should create encrypted room', async() => {
await element(by.id('rooms-list-view-create-channel')).tap(); await element(by.id('rooms-list-view-create-channel')).tap();
await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);
@ -92,15 +91,15 @@ describe('E2E Encryption', () => {
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
await waitFor(element(by.id(`room-view-title-${ room }`))).toBeVisible().withTimeout(60000); await waitFor(element(by.id(`room-view-title-${ room }`))).toBeVisible().withTimeout(60000);
}); });
it('should send message and be able to read it', async() => { it('should send message and be able to read it', async() => {
await mockMessage('message'); await mockMessage('message');
await tapBack(); await tapBack();
}); });
}); });
}) });
describe('Security and Privacy', async() => { describe('Security and Privacy', () => {
it('should navigate to security privacy', async() => { it('should navigate to security privacy', async() => {
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await element(by.id('rooms-list-view-sidebar')).tap(); await element(by.id('rooms-list-view-sidebar')).tap();
@ -120,7 +119,7 @@ describe('E2E Encryption', () => {
}); });
}); });
describe('E2E Encryption Security', async() => { describe('E2E Encryption Security', () => {
it('should navigate to e2e encryption security', async() => { it('should navigate to e2e encryption security', async() => {
await element(by.id('security-privacy-view-e2e-encryption')).tap(); await element(by.id('security-privacy-view-e2e-encryption')).tap();
await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);
@ -133,9 +132,9 @@ describe('E2E Encryption', () => {
await expect(element(by.id('e2e-encryption-security-view-change-password').and(by.label('Save Changes')))).toExist(); await expect(element(by.id('e2e-encryption-security-view-change-password').and(by.label('Save Changes')))).toExist();
await expect(element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key')))).toExist(); await expect(element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key')))).toExist();
}); });
}) });
describe('Change password', async() => { describe('Change password', () => {
it('should change password', async() => { it('should change password', async() => {
await element(by.id('e2e-encryption-security-view-password')).typeText(newPassword); await element(by.id('e2e-encryption-security-view-password')).typeText(newPassword);
await element(by.id('e2e-encryption-security-view-change-password')).tap(); await element(by.id('e2e-encryption-security-view-change-password')).tap();
@ -184,7 +183,7 @@ describe('E2E Encryption', () => {
}); });
}); });
describe('Reset E2E key', async() => { describe('Reset E2E key', () => {
it('should reset e2e key', async() => { it('should reset e2e key', async() => {
await tapBack(); await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
@ -195,7 +194,7 @@ describe('E2E Encryption', () => {
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.label('Yes, reset it').and(by.type('UILabel'))).tap(); await element(by.label('Yes, reset it').and(by.type('UILabel'))).tap();
await sleep(2000) await sleep(2000);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);
await waitFor(element(by.text('You\'ve been logged out by the server. Please log in again.'))).toExist().withTimeout(2000); await waitFor(element(by.text('You\'ve been logged out by the server. Please log in again.'))).toExist().withTimeout(2000);
await element(by.label('OK').and(by.type('_UIAlertControllerActionView'))).tap(); await element(by.label('OK').and(by.type('_UIAlertControllerActionView'))).tap();
@ -203,7 +202,7 @@ describe('E2E Encryption', () => {
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
await login(testuser.username, testuser.password); await login(testuser.username, testuser.password);
await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(2000);
}) });
}); });
}); });
@ -211,21 +210,21 @@ describe('E2E Encryption', () => {
it('check save banner', async() => { it('check save banner', async() => {
await checkServer(data.server); await checkServer(data.server);
await checkBanner(); await checkBanner();
}) });
it('should add server and create new user', async() => { it('should add server and create new user', async() => {
await sleep(5000); await sleep(5000);
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-add')).tap(); await element(by.id('rooms-list-header-server-add')).tap();
// TODO: refactor // TODO: refactor
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${data.alternateServer}\n`); await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
await element(by.id('workspace-view-register')).tap(); await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
// Register new user // Register new user
await element(by.id('register-view-name')).replaceText(data.registeringUser.username); await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser.username); await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
@ -233,10 +232,10 @@ describe('E2E Encryption', () => {
await element(by.id('register-view-password')).typeText(data.registeringUser.password); await element(by.id('register-view-password')).typeText(data.registeringUser.password);
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);
await checkServer(data.alternateServer); await checkServer(data.alternateServer);
}); });
it('should change back', async() => { it('should change back', async() => {
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);
@ -255,4 +254,4 @@ describe('E2E Encryption', () => {
await checkBanner(); await checkBanner();
}); });
}); });
}); });

View File

@ -1,13 +1,13 @@
// const OTP = require('otp.js');
// const GA = OTP.googleAuthenticator;
const { const {
device, expect, element, by, waitFor navigateToLogin, login, mockMessage, tapBack, searchRoom
} = require('detox'); } = require('../../helpers/app');
const OTP = require('otp.js');
const GA = OTP.googleAuthenticator;
const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
const testuser = data.users.regular const testuser = data.users.regular;
const otheruser = data.users.alternate const otheruser = data.users.alternate;
describe('Broadcast room', () => { describe('Broadcast room', () => {
before(async() => { before(async() => {
@ -28,7 +28,7 @@ describe('Broadcast room', () => {
await element(by.id('selected-users-view-submit')).tap(); await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000);
await element(by.id('create-channel-name')).replaceText(`broadcast${ data.random }`); await element(by.id('create-channel-name')).replaceText(`broadcast${ data.random }`);
await element(by.id('create-channel-broadcast')).longPress(); //https://github.com/facebook/react-native/issues/28032 await element(by.id('create-channel-broadcast')).longPress(); // https://github.com/facebook/react-native/issues/28032
await element(by.id('create-channel-submit')).tap(); await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
await waitFor(element(by.id(`room-view-title-broadcast${ data.random }`))).toBeVisible().withTimeout(60000); await waitFor(element(by.id(`room-view-title-broadcast${ data.random }`))).toBeVisible().withTimeout(60000);
@ -54,11 +54,11 @@ describe('Broadcast room', () => {
await navigateToLogin(); await navigateToLogin();
await login(otheruser.username, otheruser.password); await login(otheruser.username, otheruser.password);
//await waitFor(element(by.id('two-factor'))).toBeVisible().withTimeout(5000); // await waitFor(element(by.id('two-factor'))).toBeVisible().withTimeout(5000);
//await expect(element(by.id('two-factor'))).toBeVisible(); // await expect(element(by.id('two-factor'))).toBeVisible();
//const code = GA.gen(data.alternateUserTOTPSecret); // const code = GA.gen(data.alternateUserTOTPSecret);
//await element(by.id('two-factor-input')).replaceText(code); // await element(by.id('two-factor-input')).replaceText(code);
//await element(by.id('two-factor-send')).tap(); // await element(by.id('two-factor-send')).tap();
await searchRoom(`broadcast${ data.random }`); await searchRoom(`broadcast${ data.random }`);
await element(by.id(`rooms-list-view-item-broadcast${ data.random }`)).tap(); await element(by.id(`rooms-list-view-item-broadcast${ data.random }`)).tap();

View File

@ -1,10 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, sleep } = require('../../helpers/app'); const { navigateToLogin, login, sleep } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
const profileChangeUser = data.users.profileChanges const profileChangeUser = data.users.profileChanges;
const scrollDown = 200; const scrollDown = 200;
@ -28,7 +25,7 @@ describe('Profile screen', () => {
await waitFor(element(by.id('profile-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('profile-view'))).toBeVisible().withTimeout(2000);
}); });
describe('Render', async() => { describe('Render', () => {
it('should have profile view', async() => { it('should have profile view', async() => {
await expect(element(by.id('profile-view'))).toBeVisible(); await expect(element(by.id('profile-view'))).toBeVisible();
}); });
@ -56,7 +53,7 @@ describe('Profile screen', () => {
it('should have avatar url', async() => { it('should have avatar url', async() => {
await expect(element(by.id('profile-view-avatar-url'))).toExist(); await expect(element(by.id('profile-view-avatar-url'))).toExist();
}); });
it('should have reset avatar button', async() => { it('should have reset avatar button', async() => {
await waitFor(element(by.id('profile-view-reset-avatar'))).toExist().whileElement(by.id('profile-view-list')).scroll(scrollDown, 'down'); await waitFor(element(by.id('profile-view-reset-avatar'))).toExist().whileElement(by.id('profile-view-list')).scroll(scrollDown, 'down');
}); });
@ -74,7 +71,7 @@ describe('Profile screen', () => {
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
it('should change name and username', async() => { it('should change name and username', async() => {
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`);
@ -87,7 +84,7 @@ 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('_UIAlertControllerTextField')).typeText(`${ profileChangeUser.password }\n`) await element(by.type('_UIAlertControllerTextField')).typeText(`${ profileChangeUser.password }\n`);
await waitForToast(); await waitForToast();
}); });

View File

@ -1,11 +1,8 @@
const { const { navigateToLogin, login } = require('../../helpers/app');
device, expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, tapBack } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
const testuser = data.users.regular const testuser = data.users.regular;
describe('Settings screen', () => { describe('Settings screen', () => {
before(async() => { before(async() => {
@ -20,7 +17,7 @@ describe('Settings screen', () => {
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
}); });
describe('Render', async() => { describe('Render', () => {
it('should have settings view', async() => { it('should have settings view', async() => {
await expect(element(by.id('settings-view'))).toBeVisible(); await expect(element(by.id('settings-view'))).toBeVisible();
}); });
@ -62,14 +59,14 @@ describe('Settings screen', () => {
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
it('should tap clear cache and navigate to roomslistview', async() => { it('should tap clear cache and navigate to roomslistview', async() => {
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.label('Clear').and(by.type('_UIAlertControllerActionView'))).tap(); await element(by.label('Clear').and(by.type('_UIAlertControllerActionView'))).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);
}) });
}); });
}); });

View File

@ -1,10 +1,9 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom } = require('../../helpers/app'); const {
navigateToLogin, login, mockMessage, tapBack, searchRoom
} = require('../../helpers/app');
const testuser = data.users.regular const testuser = data.users.regular;
const room = data.channels.detoxpublic.name; const room = data.channels.detoxpublic.name;
async function navigateToRoom() { async function navigateToRoom() {
@ -26,7 +25,7 @@ describe('Join public room', () => {
await navigateToRoom(); await navigateToRoom();
}); });
describe('Render', async() => { describe('Render', () => {
it('should have room screen', async() => { it('should have room screen', async() => {
await expect(element(by.id('room-view'))).toBeVisible(); await expect(element(by.id('room-view'))).toBeVisible();
}); });
@ -36,14 +35,14 @@ describe('Join public room', () => {
// }); // });
// Render - Header // Render - Header
describe('Header', async() => { describe('Header', () => {
it('should have actions button ', async() => { it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toBeVisible(); await expect(element(by.id('room-header'))).toBeVisible();
}); });
}); });
// Render - Join // Render - Join
describe('Join', async() => { describe('Join', () => {
it('should have join', async() => { it('should have join', async() => {
await expect(element(by.id('room-view-join'))).toBeVisible(); await expect(element(by.id('room-view-join'))).toBeVisible();
}); });
@ -61,7 +60,7 @@ describe('Join public room', () => {
}); });
}); });
describe('Room Actions', async() => { describe('Room Actions', () => {
before(async() => { before(async() => {
await navigateToRoomActions(); await navigateToRoomActions();
}); });
@ -117,11 +116,11 @@ describe('Join public room', () => {
after(async() => { after(async() => {
await tapBack(); await tapBack();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(2000);
}) });
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
it('should join room', async() => { it('should join room', async() => {
await element(by.id('room-view-join-button')).tap(); await element(by.id('room-view-join-button')).tap();
await tapBack(); await tapBack();

View File

@ -1,17 +1,15 @@
const {
expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, sleep } = require('../../helpers/app'); const { navigateToLogin, login, sleep } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
const testuser = data.users.regular
const testuser = data.users.regular;
async function waitForToast() { async function waitForToast() {
await sleep(300); await sleep(300);
} }
describe('Status screen', () => { describe('Status screen', () => {
before(async () => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin(); await navigateToLogin();
await login(testuser.username, testuser.password); await login(testuser.username, testuser.password);
@ -24,8 +22,8 @@ describe('Status screen', () => {
await waitFor(element(by.id('status-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('status-view'))).toBeVisible().withTimeout(2000);
}); });
describe('Render', async () => { describe('Render', () => {
it('should have status input', async () => { it('should have status input', async() => {
await expect(element(by.id('status-view-input'))).toBeVisible(); await expect(element(by.id('status-view-input'))).toBeVisible();
await expect(element(by.id('status-view-online'))).toExist(); await expect(element(by.id('status-view-online'))).toExist();
await expect(element(by.id('status-view-busy'))).toExist(); await expect(element(by.id('status-view-busy'))).toExist();
@ -34,17 +32,17 @@ describe('Status screen', () => {
}); });
}); });
describe('Usage', async () => { describe('Usage', () => {
it('should change status', async () => { it('should change status', async() => {
await element(by.id('status-view-busy')).tap(); await element(by.id('status-view-busy')).tap();
await waitFor(element(by.id('status-view-current-busy'))).toExist().withTimeout(2000); await waitFor(element(by.id('status-view-current-busy'))).toExist().withTimeout(2000);
}); });
it('should change status text', async () => { it('should change status text', async() => {
await element(by.id('status-view-input')).typeText('status-text-new'); await element(by.id('status-view-input')).typeText('status-text-new');
await element(by.id('status-view-submit')).tap(); await element(by.id('status-view-submit')).tap();
await waitForToast(); await waitForToast();
await waitFor(element(by.label('status-text-new').withAncestor(by.id('sidebar-custom-status')))).toExist().withTimeout(2000); await waitFor(element(by.label('status-text-new').withAncestor(by.id('sidebar-custom-status')))).toExist().withTimeout(2000);
}); });
}); });
}); });

View File

@ -1,6 +1,3 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, checkServer } = require('../../helpers/app'); const { navigateToLogin, login, checkServer } = require('../../helpers/app');
@ -8,7 +5,7 @@ const reopenAndCheckServer = async(server) => {
await device.launchApp({ permissions: { notifications: 'YES' } }); await device.launchApp({ permissions: { notifications: 'YES' } });
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(6000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(6000);
await checkServer(server); await checkServer(server);
} };
describe('Change server', () => { describe('Change server', () => {
before(async() => { before(async() => {
@ -24,7 +21,7 @@ describe('Change server', () => {
await element(by.id('rooms-list-header-server-add')).tap(); await element(by.id('rooms-list-header-server-add')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(6000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(6000);
await element(by.id('new-server-view-input')).typeText(`${data.alternateServer}\n`); await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);
await reopenAndCheckServer(data.server); await reopenAndCheckServer(data.server);
}); });
@ -64,5 +61,5 @@ describe('Change server', () => {
it('should reopen the app and show main server', async() => { it('should reopen the app and show main server', async() => {
await reopenAndCheckServer(data.server); await reopenAndCheckServer(data.server);
}) });
}); });

View File

@ -1,12 +1,11 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom } = require('../../helpers/app'); const {
navigateToLogin, login, mockMessage, searchRoom
} = require('../../helpers/app');
const testuser = data.users.regular const testuser = data.users.regular;
const room = data.channels.detoxpublicprotected.name const room = data.channels.detoxpublicprotected.name;
const joinCode = data.channels.detoxpublicprotected.joinCode const { joinCode } = data.channels.detoxpublicprotected;
async function navigateToRoom() { async function navigateToRoom() {
await searchRoom(room); await searchRoom(room);
@ -27,10 +26,10 @@ describe('Join protected room', () => {
await navigateToRoom(); await navigateToRoom();
}); });
describe('Usage', async() => { describe('Usage', () => {
it('should tap join and ask for join code', async() => { it('should tap join and ask for join code', async() => {
await openJoinCode(); await openJoinCode();
}) });
it('should cancel join room', async() => { it('should cancel join room', async() => {
await element(by.id('join-code-cancel')).tap(); await element(by.id('join-code-cancel')).tap();

View File

@ -1,13 +1,12 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, tapBack, sleep } = require('../../helpers/app'); const {
navigateToLogin, login, tapBack, sleep
} = require('../../helpers/app');
const testuser = data.users.regular const testuser = data.users.regular;
async function navigateToRoom(search) { async function navigateToRoom(search) {
await element(by.id('directory-view-search')).replaceText(search); await element(by.id('directory-view-search')).replaceText(search);
await waitFor(element(by.id(`directory-view-item-${ search }`))).toBeVisible().withTimeout(10000); await waitFor(element(by.id(`directory-view-item-${ search }`))).toBeVisible().withTimeout(10000);
await sleep(300); // app takes some time to animate await sleep(300); // app takes some time to animate
await element(by.id(`directory-view-item-${ search }`)).tap(); await element(by.id(`directory-view-item-${ search }`)).tap();
@ -22,34 +21,34 @@ describe('Join room from directory', () => {
await login(testuser.username, testuser.password); await login(testuser.username, testuser.password);
}); });
describe('Usage', async() => { describe('Usage', () => {
it('should tap directory', async() => { it('should tap directory', async() => {
await element(by.id('rooms-list-view-directory')).tap(); await element(by.id('rooms-list-view-directory')).tap();
await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000);
}) });
it('should search public channel and navigate', async() => { it('should search public channel and navigate', async() => {
await navigateToRoom(data.channels.detoxpublic.name); await navigateToRoom(data.channels.detoxpublic.name);
}) });
it('should search user and navigate', async() => {
await tapBack();
await element(by.id('rooms-list-view-directory')).tap();
await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000);
await element(by.id('directory-view-dropdown')).tap();
await element(by.label('Users')).tap();
await element(by.label('Search by')).tap();
await navigateToRoom(data.users.alternate.username);
})
it('should search user and navigate', async() => { it('should search user and navigate', async() => {
await tapBack(); await tapBack();
await element(by.id('rooms-list-view-directory')).tap(); await element(by.id('rooms-list-view-directory')).tap();
await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000);
await element(by.id('directory-view-dropdown')).tap(); await element(by.id('directory-view-dropdown')).tap();
await element(by.label('Users')).tap();
await element(by.label('Search by')).tap();
await navigateToRoom(data.users.alternate.username);
});
it('should search user and navigate', async() => {
await tapBack();
await element(by.id('rooms-list-view-directory')).tap();
await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000);
await element(by.id('directory-view-dropdown')).tap();
await element(by.label('Teams')).tap(); await element(by.label('Teams')).tap();
await element(by.label('Search by')).tap(); await element(by.label('Search by')).tap();
await navigateToRoom(data.teams.private.name); await navigateToRoom(data.teams.private.name);
}) });
}); });
}); });

View File

@ -1,8 +1,7 @@
const {
device, element, by, waitFor
} = require('detox');
const data = require('../../data'); 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', () => {
before(async() => { before(async() => {
@ -13,7 +12,7 @@ describe('Delete server', () => {
it('should be logged in main server', async() => { it('should be logged in main server', async() => {
await checkServer(data.server); await checkServer(data.server);
}) });
it('should add server', async() => { it('should add server', async() => {
await sleep(5000); await sleep(5000);
@ -22,7 +21,7 @@ describe('Delete server', () => {
await element(by.id('rooms-list-header-server-add')).tap(); await element(by.id('rooms-list-header-server-add')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(10000);
await element(by.id('new-server-view-input')).typeText(`${data.alternateServer}\n`); await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);
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-register')).tap(); await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
@ -42,7 +41,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.label('Delete').and(by.type('_UIAlertControllerActionView'))).tap(); await element(by.label('Delete').and(by.type('_UIAlertControllerActionView'))).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);

View File

@ -1,13 +1,10 @@
const {
device, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { tapBack, checkServer, navigateToRegister } = require('../../helpers/app'); const { tapBack, checkServer, navigateToRegister } = require('../../helpers/app');
const { post, get, login } = require('../../helpers/data_setup'); const { get, login } = require('../../helpers/data_setup');
const DEEPLINK_METHODS = { AUTH: 'auth', ROOM: 'room' }; const DEEPLINK_METHODS = { AUTH: 'auth', ROOM: 'room' };
const getDeepLink = (method, server, params) => { const getDeepLink = (method, server, params) => {
const deeplink = `rocketchat://${ method }?host=${ server.replace(/^(http:\/\/|https:\/\/)/, '') }&${params}`; const deeplink = `rocketchat://${ method }?host=${ server.replace(/^(http:\/\/|https:\/\/)/, '') }&${ params }`;
console.log(`Deeplinking to: ${ deeplink }`); console.log(`Deeplinking to: ${ deeplink }`);
return deeplink; return deeplink;
}; };
@ -43,7 +40,7 @@ describe('Deep linking', () => {
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await checkServer(data.server); await checkServer(data.server);
await waitFor(element(by.id(`rooms-list-view-item-${ data.groups.private.name }`))).toBeVisible().withTimeout(2000); await waitFor(element(by.id(`rooms-list-view-item-${ data.groups.private.name }`))).toBeVisible().withTimeout(2000);
} };
it('should authenticate and navigate', async() => { it('should authenticate and navigate', async() => {
await authAndNavigate(); await authAndNavigate();
@ -63,7 +60,7 @@ describe('Deep linking', () => {
}); });
describe('Room', () => { describe('Room', () => {
describe('While logged in', async() => { describe('While logged in', () => {
it('should navigate to the room using path', async() => { it('should navigate to the room using path', async() => {
await device.launchApp({ await device.launchApp({
permissions: { notifications: 'YES' }, permissions: { notifications: 'YES' },
@ -75,7 +72,7 @@ describe('Deep linking', () => {
}); });
it('should navigate to the room using rid', async() => { it('should navigate to the room using rid', async() => {
const roomResult = await get(`groups.info?roomName=${ data.groups.private.name }`) const roomResult = await get(`groups.info?roomName=${ data.groups.private.name }`);
await device.launchApp({ await device.launchApp({
permissions: { notifications: 'YES' }, permissions: { notifications: 'YES' },
newInstance: true, newInstance: true,
@ -87,7 +84,7 @@ describe('Deep linking', () => {
}); });
}); });
describe('Others', async() => { describe('Others', () => {
it('should change server', async() => { it('should change server', async() => {
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await element(by.id('rooms-list-header-server-dropdown-button')).tap(); await element(by.id('rooms-list-header-server-dropdown-button')).tap();

View File

@ -1,11 +1,9 @@
const {
device, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, sleep } = require('../../helpers/app'); const { navigateToLogin, login, sleep } = require('../../helpers/app');
const { post } = require('../../helpers/data_setup'); const { post } = require('../../helpers/data_setup');
const data = require('../../data'); const data = require('../../data');
const testuser = data.users.regular
const testuser = data.users.regular;
const defaultLaunchArgs = { permissions: { notifications: 'YES' } }; const defaultLaunchArgs = { permissions: { notifications: 'YES' } };
const navToLanguage = async() => { const navToLanguage = async() => {
@ -25,8 +23,8 @@ describe('i18n', () => {
await device.launchApp({ await device.launchApp({
...defaultLaunchArgs, ...defaultLaunchArgs,
languageAndLocale: { languageAndLocale: {
language: "en", language: 'en',
locale: "en" locale: 'en'
}, },
delete: true delete: true
}); });
@ -34,20 +32,20 @@ describe('i18n', () => {
await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible(); await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible();
await expect(element(by.id('create-workspace-button').and(by.label('Create a new workspace')))).toBeVisible(); await expect(element(by.id('create-workspace-button').and(by.label('Create a new workspace')))).toBeVisible();
}); });
it('OS set to unavailable language and fallback to \'en\'', async() => { it('OS set to unavailable language and fallback to \'en\'', async() => {
await device.launchApp({ await device.launchApp({
...defaultLaunchArgs, ...defaultLaunchArgs,
languageAndLocale: { languageAndLocale: {
language: "es-MX", language: 'es-MX',
locale: "es-MX" locale: 'es-MX'
} }
}); });
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000); await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible(); await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible();
await expect(element(by.id('create-workspace-button').and(by.label('Create a new workspace')))).toBeVisible(); await expect(element(by.id('create-workspace-button').and(by.label('Create a new workspace')))).toBeVisible();
}); });
/** /**
* This test might become outdated as soon as we support the language * This test might become outdated as soon as we support the language
* Although this seems to be a bad approach, that's the intention for having fallback enabled * Although this seems to be a bad approach, that's the intention for having fallback enabled
@ -110,5 +108,5 @@ describe('i18n', () => {
await expect(element(by.id('sidebar-settings').withDescendant(by.label('Settings')))).toBeVisible(); await expect(element(by.id('sidebar-settings').withDescendant(by.label('Settings')))).toBeVisible();
await post('users.setPreferences', { data: { language: 'en' } }); // Set back to english await post('users.setPreferences', { data: { language: 'en' } }); // Set back to english
}); });
}) });
}); });

View File

@ -1,13 +1,13 @@
const detox = require('detox'); const detox = require('detox');
const config = require('../../package.json').detox;
const { setup } = require('../helpers/data_setup')
const adapter = require('detox/runners/mocha/adapter'); const adapter = require('detox/runners/mocha/adapter');
const config = require('../../package.json').detox;
const { setup } = require('../helpers/data_setup');
before(async() => { before(async() => {
await Promise.all([setup(), detox.init(config, { launchApp: false })]) await Promise.all([setup(), detox.init(config, { launchApp: false })]);
//await dataSetup() // await dataSetup()
//await detox.init(config, { launchApp: false }); // await detox.init(config, { launchApp: false });
//await device.launchApp({ permissions: { notifications: 'YES' } }); // await device.launchApp({ permissions: { notifications: 'YES' } });
}); });
beforeEach(async function() { beforeEach(async function() {

View File

@ -1,6 +1,3 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
describe('Onboarding', () => { describe('Onboarding', () => {
@ -12,10 +9,10 @@ describe('Onboarding', () => {
describe('Render', () => { describe('Render', () => {
it('should have onboarding screen', async() => { it('should have onboarding screen', async() => {
await expect(element(by.id('onboarding-view'))).toBeVisible(); await expect(element(by.id('onboarding-view'))).toBeVisible();
}); });
it('should have "Join a workspace"', async() => { it('should have "Join a workspace"', async() => {
await expect(element(by.id('join-workspace'))).toBeVisible(); await expect(element(by.id('join-workspace'))).toBeVisible();
}); });
it('should have "Create a new workspace"', async() => { it('should have "Create a new workspace"', async() => {
@ -27,7 +24,7 @@ describe('Onboarding', () => {
// it('should navigate to create new workspace', async() => { // it('should navigate to create new workspace', async() => {
// // webviews are not supported by detox: https://github.com/wix/detox/issues/136#issuecomment-306591554 // // webviews are not supported by detox: https://github.com/wix/detox/issues/136#issuecomment-306591554
// }); // });
it('should navigate to join a workspace', async() => { it('should navigate to join a workspace', async() => {
await element(by.id('join-workspace')).tap(); await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
@ -50,7 +47,7 @@ describe('Onboarding', () => {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
await element(by.id('join-workspace')).tap(); await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${data.server}\n`); await element(by.id('new-server-view-input')).typeText(`${ data.server }\n`);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
}); });
}); });

View File

@ -1,24 +1,20 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { navigateToRegister, navigateToLogin } = require('../../helpers/app'); const { navigateToRegister, navigateToLogin } = require('../../helpers/app');
describe('Legal screen', () => { describe('Legal screen', () => {
describe('From Login', () => { describe('From Login', () => {
before(async() => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin(); await navigateToLogin();
}); });
it('should have legal button on login', async() => { it('should have legal button on login', async() => {
await waitFor(element(by.id('login-view-more'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('login-view-more'))).toBeVisible().withTimeout(60000);
}); });
it('should navigate to legal from login', async() => { it('should navigate to legal from login', async() => {
await expect(element(by.id('login-view-more'))).toBeVisible(); await expect(element(by.id('login-view-more'))).toBeVisible();
await element(by.id('login-view-more')).tap(); await element(by.id('login-view-more')).tap();
await waitFor(element(by.id('legal-view'))).toBeVisible().withTimeout(4000) await waitFor(element(by.id('legal-view'))).toBeVisible().withTimeout(4000);
}); });
}); });
@ -28,32 +24,32 @@ describe('Legal screen', () => {
await navigateToRegister(); await navigateToRegister();
}); });
it('should have legal button on register', async() => { it('should have legal button on register', async() => {
await waitFor(element(by.id('register-view-more'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('register-view-more'))).toBeVisible().withTimeout(60000);
}); });
it('should navigate to legal from register', async() => { it('should navigate to legal from register', async() => {
await expect(element(by.id('register-view-more'))).toBeVisible(); await expect(element(by.id('register-view-more'))).toBeVisible();
await element(by.id('register-view-more')).tap(); await element(by.id('register-view-more')).tap();
await waitFor(element(by.id('legal-view'))).toBeVisible().withTimeout(4000); await waitFor(element(by.id('legal-view'))).toBeVisible().withTimeout(4000);
}); });
it('should have terms of service button', async() => { it('should have terms of service button', async() => {
await expect(element(by.id('legal-terms-button'))).toBeVisible(); await expect(element(by.id('legal-terms-button'))).toBeVisible();
}); });
it('should have privacy policy button', async() => { it('should have privacy policy button', async() => {
await expect(element(by.id('legal-privacy-button'))).toBeVisible(); await expect(element(by.id('legal-privacy-button'))).toBeVisible();
}); });
// We can't simulate how webview behaves, so I had to disable :( // We can't simulate how webview behaves, so I had to disable :(
/* /*
it('should navigate to terms', async() => { it('should navigate to terms', async() => {
await element(by.id('legal-terms-button')).tap(); await element(by.id('legal-terms-button')).tap();
await waitFor(element(by.id('terms-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('terms-view'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('terms-view'))).toBeVisible(); await expect(element(by.id('terms-view'))).toBeVisible();
}); });
it('should navigate to privacy', async() => { it('should navigate to privacy', async() => {
await tapBack(); await tapBack();
await element(by.id('legal-privacy-button')).tap(); await element(by.id('legal-privacy-button')).tap();

View File

@ -1,6 +1,3 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin } = require('../../helpers/app'); const { navigateToLogin } = require('../../helpers/app');
@ -12,7 +9,7 @@ describe('Forgot password screen', () => {
await waitFor(element(by.id('forgot-password-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('forgot-password-view'))).toExist().withTimeout(2000);
}); });
describe('Render', async() => { describe('Render', () => {
it('should have forgot password screen', async() => { it('should have forgot password screen', async() => {
await expect(element(by.id('forgot-password-view'))).toExist(); await expect(element(by.id('forgot-password-view'))).toExist();
}); });
@ -26,7 +23,7 @@ describe('Forgot password screen', () => {
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
it('should reset password and navigate to login', async() => { it('should reset password and navigate to login', async() => {
await element(by.id('forgot-password-view-email')).replaceText(data.users.existing.email); await element(by.id('forgot-password-view-email')).replaceText(data.users.existing.email);
await element(by.id('forgot-password-view-submit')).tap(); await element(by.id('forgot-password-view-submit')).tap();

View File

@ -1,7 +1,4 @@
const { const { navigateToRegister } = require('../../helpers/app');
device, expect, element, by, waitFor
} = require('detox');
const { navigateToRegister, sleep } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
describe('Create user screen', () => { describe('Create user screen', () => {
@ -37,7 +34,6 @@ describe('Create user screen', () => {
}); });
describe('Usage', () => { describe('Usage', () => {
// FIXME: Detox isn't able to check if it's tappable: https://github.com/wix/Detox/issues/246 // FIXME: Detox isn't able to check if it's tappable: https://github.com/wix/Detox/issues/246
// it('should submit invalid email and do nothing', async() => { // it('should submit invalid email and do nothing', async() => {
// const invalidEmail = 'invalidemail'; // const invalidEmail = 'invalidemail';

View File

@ -1,7 +1,4 @@
const { const { navigateToLogin, tapBack } = require('../../helpers/app');
expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, tapBack, sleep } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
describe('Login screen', () => { describe('Login screen', () => {
@ -46,13 +43,13 @@ describe('Login screen', () => {
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
await tapBack(); await tapBack();
}); });
it('should navigate to forgot password', async() => { it('should navigate to forgot password', async() => {
await element(by.id('login-view-forgot-password')).tap(); await element(by.id('login-view-forgot-password')).tap();
await waitFor(element(by.id('forgot-password-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('forgot-password-view'))).toExist().withTimeout(2000);
await tapBack(); await tapBack();
}); });
it('should insert wrong password and get error', async() => { it('should insert wrong password and get error', async() => {
await element(by.id('login-view-email')).replaceText(data.users.regular.username); await element(by.id('login-view-email')).replaceText(data.users.regular.username);
await element(by.id('login-view-password')).replaceText('NotMyActualPassword'); await element(by.id('login-view-password')).replaceText('NotMyActualPassword');
@ -60,7 +57,7 @@ describe('Login screen', () => {
await waitFor(element(by.text('Your credentials were rejected! Please try again.'))).toBeVisible().withTimeout(10000); await waitFor(element(by.text('Your credentials were rejected! Please try again.'))).toBeVisible().withTimeout(10000);
await element(by.text('OK')).tap(); await element(by.text('OK')).tap();
}); });
it('should login with success', async() => { it('should login with success', async() => {
await element(by.id('login-view-password')).replaceText(data.users.regular.password); await element(by.id('login-view-password')).replaceText(data.users.regular.password);
await element(by.id('login-view-submit')).tap(); await element(by.id('login-view-submit')).tap();

View File

@ -1,15 +1,13 @@
const { const {
device, expect, element, by, waitFor login, navigateToLogin, logout, tapBack, searchRoom
} = require('detox'); } = require('../../helpers/app');
const { login, navigateToLogin, logout, tapBack, sleep, searchRoom } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
describe('Rooms list screen', () => { describe('Rooms list screen', () => {
before(async() => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
await navigateToLogin(); await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password) await login(data.users.regular.username, data.users.regular.password);
}); });
describe('Render', () => { describe('Render', () => {
@ -20,13 +18,13 @@ describe('Rooms list screen', () => {
it('should have room item', async() => { it('should have room item', async() => {
await expect(element(by.id('rooms-list-view-item-general'))).toExist(); await expect(element(by.id('rooms-list-view-item-general'))).toExist();
}); });
// Render - Header // Render - Header
describe('Header', () => { describe('Header', () => {
it('should have create channel button', async() => { it('should have create channel button', async() => {
await expect(element(by.id('rooms-list-view-create-channel'))).toBeVisible(); await expect(element(by.id('rooms-list-view-create-channel'))).toBeVisible();
}); });
it('should have sidebar button', async() => { it('should have sidebar button', async() => {
await expect(element(by.id('rooms-list-view-sidebar'))).toBeVisible(); await expect(element(by.id('rooms-list-view-sidebar'))).toBeVisible();
}); });

View File

@ -1,7 +1,6 @@
const { const {
device, expect, element, by, waitFor login, navigateToLogin, logout, tapBack
} = require('detox'); } = require('../../helpers/app');
const { login, navigateToLogin, logout, tapBack } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
describe('Server history', () => { describe('Server history', () => {
@ -16,7 +15,7 @@ describe('Server history', () => {
await logout(); await logout();
await element(by.id('join-workspace')).tap(); await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
}) });
it('should show servers history', async() => { it('should show servers history', async() => {
await element(by.id('new-server-view-input')).tap(); await element(by.id('new-server-view-input')).tap();

View File

@ -1,10 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { tapBack, sleep, navigateToLogin, login, tryTapping } = require('../../helpers/app'); const {
tapBack, navigateToLogin, login, tryTapping
} = require('../../helpers/app');
describe('Create room screen', () => { describe('Create room screen', () => {
before(async() => { before(async() => {
@ -13,30 +10,30 @@ describe('Create room screen', () => {
await login(data.users.regular.username, data.users.regular.password); await login(data.users.regular.username, data.users.regular.password);
}); });
describe('New Message', async() => { describe('New Message', () => {
before(async() => { before(async() => {
await element(by.id('rooms-list-view-create-channel')).tap(); await element(by.id('rooms-list-view-create-channel')).tap();
}); });
describe('Render', async() => { describe('Render', () => {
it('should have new message screen', async() => { it('should have new message screen', async() => {
await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);
}); });
it('should have search input', async() => { it('should have search input', async() => {
await waitFor(element(by.id('new-message-view-search'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('new-message-view-search'))).toBeVisible().withTimeout(2000);
}); });
}) });
describe('Usage', async() => { describe('Usage', () => {
it('should back to rooms list', async() => { it('should back to rooms list', async() => {
await waitFor(element(by.id('new-message-view-close'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('new-message-view-close'))).toBeVisible().withTimeout(5000);
await element(by.id('new-message-view-close')).tap(); await element(by.id('new-message-view-close')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(5000);
await tryTapping(element(by.id('rooms-list-view-create-channel')), 3000); await tryTapping(element(by.id('rooms-list-view-create-channel')), 3000);
//await element(by.id('rooms-list-view-create-channel')).tap(); // await element(by.id('rooms-list-view-create-channel')).tap();
await waitFor(element(by.id('new-message-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('new-message-view'))).toExist().withTimeout(5000);
}); });
@ -56,13 +53,13 @@ describe('Create room screen', () => {
await element(by.id('new-message-view-create-channel')).tap(); await element(by.id('new-message-view-create-channel')).tap();
await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(5000);
}); });
}) });
}); });
describe('Select Users', async() => { describe('Select Users', () => {
it('should search users', async() => { it('should search users', async() => {
await element(by.id('select-users-view-search')).replaceText('rocket.cat'); await element(by.id('select-users-view-search')).replaceText('rocket.cat');
await waitFor(element(by.id(`select-users-view-item-rocket.cat`))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('select-users-view-item-rocket.cat'))).toBeVisible().withTimeout(10000);
}); });
it('should select/unselect user', async() => { it('should select/unselect user', async() => {
@ -80,27 +77,27 @@ describe('Create room screen', () => {
await element(by.id('selected-users-view-submit')).tap(); await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000); await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);
}); });
}) });
describe('Create Channel', async() => { describe('Create Channel', () => {
describe('Render', async() => { describe('Render', () => {
it('should render all fields', async() => { it('should render all fields', async() => {
await expect(element(by.id('create-channel-name'))).toBeVisible(); await expect(element(by.id('create-channel-name'))).toBeVisible();
await expect(element(by.id('create-channel-type'))).toBeVisible(); await expect(element(by.id('create-channel-type'))).toBeVisible();
await expect(element(by.id('create-channel-readonly'))).toBeVisible(); await expect(element(by.id('create-channel-readonly'))).toBeVisible();
await expect(element(by.id('create-channel-broadcast'))).toBeVisible(); await expect(element(by.id('create-channel-broadcast'))).toBeVisible();
}) });
}) });
describe('Usage', async() => { describe('Usage', () => {
it('should get invalid room', async() => { it('should get invalid room', async() => {
await element(by.id('create-channel-name')).typeText('general'); await element(by.id('create-channel-name')).typeText('general');
await element(by.id('create-channel-submit')).tap(); await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.text(`A channel with name general exists`))).toExist().withTimeout(60000); await waitFor(element(by.text('A channel with name general exists'))).toExist().withTimeout(60000);
await expect(element(by.text(`A channel with name general exists`))).toExist(); await expect(element(by.text('A channel with name general exists'))).toExist();
await element(by.text('OK')).tap(); await element(by.text('OK')).tap();
}); });
it('should create public room', async() => { it('should create public room', async() => {
const room = `public${ data.random }`; const room = `public${ data.random }`;
await element(by.id('create-channel-name')).replaceText(''); await element(by.id('create-channel-name')).replaceText('');
@ -116,7 +113,7 @@ describe('Create room screen', () => {
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(6000); await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(6000);
await expect(element(by.id(`rooms-list-view-item-${ room }`))).toExist(); await expect(element(by.id(`rooms-list-view-item-${ room }`))).toExist();
}); });
it('should create private room', async() => { it('should create private room', async() => {
const room = `private${ data.random }`; const room = `private${ data.random }`;
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(5000);
@ -161,6 +158,6 @@ describe('Create room screen', () => {
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000); await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-${ room }`))).toExist(); await expect(element(by.id(`rooms-list-view-item-${ room }`))).toExist();
}); });
}) });
}); });
}); });

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom, starMessage, pinMessage, dismissReviewNag, tryTapping, logout } = require('../../helpers/app'); const {
navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom, starMessage, pinMessage, dismissReviewNag, tryTapping
} = require('../../helpers/app');
async function navigateToRoom(roomName) { async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`); await searchRoom(`${ roomName }`);
@ -20,14 +19,14 @@ describe('Room screen', () => {
await navigateToRoom(mainRoom); await navigateToRoom(mainRoom);
}); });
describe('Render', async() => { describe('Render', () => {
it('should have room screen', async() => { it('should have room screen', async() => {
await expect(element(by.id('room-view'))).toExist(); await expect(element(by.id('room-view'))).toExist();
await waitFor(element(by.id(`room-view-title-${ mainRoom }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ mainRoom }`))).toExist().withTimeout(5000);
}); });
// Render - Header // Render - Header
describe('Header', async() => { describe('Header', () => {
it('should have actions button ', async() => { it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist(); await expect(element(by.id('room-header'))).toExist();
}); });
@ -38,7 +37,7 @@ describe('Room screen', () => {
}); });
// Render - Messagebox // Render - Messagebox
describe('Messagebox', async() => { describe('Messagebox', () => {
it('should have messagebox', async() => { it('should have messagebox', async() => {
await expect(element(by.id('messagebox'))).toExist(); await expect(element(by.id('messagebox'))).toExist();
}); });
@ -63,15 +62,15 @@ describe('Room screen', () => {
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
describe('Messagebox', async() => { describe('Messagebox', () => {
it('should send message', async() => { it('should send message', async() => {
await mockMessage('message') await mockMessage('message');
await expect(element(by.label(`${ data.random }message`)).atIndex(0)).toExist(); await expect(element(by.label(`${ data.random }message`)).atIndex(0)).toExist();
}); });
it('should show/hide emoji keyboard', async () => { it('should show/hide emoji keyboard', async() => {
if (device.getPlatform() === 'android') { if (device.getPlatform() === 'android') {
await element(by.id('messagebox-open-emoji')).tap(); await element(by.id('messagebox-open-emoji')).tap();
await waitFor(element(by.id('messagebox-keyboard-emoji'))).toExist().withTimeout(10000); await waitFor(element(by.id('messagebox-keyboard-emoji'))).toExist().withTimeout(10000);
@ -105,20 +104,20 @@ describe('Room screen', () => {
it('should not show emoji autocomplete on semicolon in middle of a string', async() => { it('should not show emoji autocomplete on semicolon in middle of a string', async() => {
await element(by.id('messagebox-input')).tap(); await element(by.id('messagebox-input')).tap();
// await element(by.id('messagebox-input')).replaceText(':'); // await element(by.id('messagebox-input')).replaceText(':');
await element(by.id('messagebox-input')).typeText('name:is'); await element(by.id('messagebox-input')).typeText('name:is');
await waitFor(element(by.id('messagebox-container'))).toNotExist().withTimeout(20000); await waitFor(element(by.id('messagebox-container'))).toNotExist().withTimeout(20000);
await element(by.id('messagebox-input')).clearText(); await element(by.id('messagebox-input')).clearText();
}); });
it('should show and tap on user autocomplete and send mention', async() => { it('should show and tap on user autocomplete and send mention', async() => {
const username = data.users.regular.username const { username } = data.users.regular;
await element(by.id('messagebox-input')).tap(); await element(by.id('messagebox-input')).tap();
await element(by.id('messagebox-input')).typeText(`@${ username }`); await element(by.id('messagebox-input')).typeText(`@${ username }`);
await waitFor(element(by.id('messagebox-container'))).toExist().withTimeout(4000); await waitFor(element(by.id('messagebox-container'))).toExist().withTimeout(4000);
await waitFor(element(by.id(`mention-item-${ username }`))).toBeVisible().withTimeout(4000) await waitFor(element(by.id(`mention-item-${ username }`))).toBeVisible().withTimeout(4000);
await tryTapping(element(by.id(`mention-item-${ username }`)), 2000, true); await tryTapping(element(by.id(`mention-item-${ username }`)), 2000, true);
await expect(element(by.id('messagebox-input'))).toHaveText(`@${ username } `); await expect(element(by.id('messagebox-input'))).toHaveText(`@${ username } `);
await tryTapping(element(by.id('messagebox-input')), 2000) await tryTapping(element(by.id('messagebox-input')), 2000);
await element(by.id('messagebox-input')).typeText(`${ data.random }mention`); await element(by.id('messagebox-input')).typeText(`${ data.random }mention`);
await element(by.id('messagebox-send-message')).tap(); await element(by.id('messagebox-send-message')).tap();
// await waitFor(element(by.label(`@${ data.user } ${ data.random }mention`)).atIndex(0)).toExist().withTimeout(60000); // await waitFor(element(by.label(`@${ data.user } ${ data.random }mention`)).atIndex(0)).toExist().withTimeout(60000);
@ -126,7 +125,7 @@ describe('Room screen', () => {
it('should not show user autocomplete on @ in the middle of a string', async() => { it('should not show user autocomplete on @ in the middle of a string', async() => {
await element(by.id('messagebox-input')).tap(); await element(by.id('messagebox-input')).tap();
await element(by.id('messagebox-input')).typeText(`email@gmail`); await element(by.id('messagebox-input')).typeText('email@gmail');
await waitFor(element(by.id('messagebox-container'))).toNotExist().withTimeout(4000); await waitFor(element(by.id('messagebox-container'))).toNotExist().withTimeout(4000);
await element(by.id('messagebox-input')).clearText(); await element(by.id('messagebox-input')).clearText();
}); });
@ -134,9 +133,9 @@ describe('Room screen', () => {
it('should show and tap on room autocomplete', async() => { it('should show and tap on room autocomplete', async() => {
await element(by.id('messagebox-input')).tap(); await element(by.id('messagebox-input')).tap();
await element(by.id('messagebox-input')).typeText('#general'); await element(by.id('messagebox-input')).typeText('#general');
//await waitFor(element(by.id('messagebox-container'))).toExist().withTimeout(4000); // await waitFor(element(by.id('messagebox-container'))).toExist().withTimeout(4000);
await waitFor(element(by.id('mention-item-general'))).toBeVisible().withTimeout(4000); await waitFor(element(by.id('mention-item-general'))).toBeVisible().withTimeout(4000);
await tryTapping(element(by.id('mention-item-general')), 2000, true) await tryTapping(element(by.id('mention-item-general')), 2000, true);
await expect(element(by.id('messagebox-input'))).toHaveText('#general '); await expect(element(by.id('messagebox-input'))).toHaveText('#general ');
await element(by.id('messagebox-input')).clearText(); await element(by.id('messagebox-input')).clearText();
}); });
@ -147,7 +146,7 @@ describe('Room screen', () => {
await waitFor(element(by.id('messagebox-container'))).toNotExist().withTimeout(4000); await waitFor(element(by.id('messagebox-container'))).toNotExist().withTimeout(4000);
await element(by.id('messagebox-input')).clearText(); await element(by.id('messagebox-input')).clearText();
}); });
it('should draft message', async () => { it('should draft message', async() => {
await element(by.id('messagebox-input')).tap(); await element(by.id('messagebox-input')).tap();
await element(by.id('messagebox-input')).typeText(`${ data.random }draft`); await element(by.id('messagebox-input')).typeText(`${ data.random }draft`);
await tapBack(); await tapBack();
@ -159,10 +158,10 @@ describe('Room screen', () => {
await navigateToRoom(mainRoom); await navigateToRoom(mainRoom);
await expect(element(by.id('messagebox-input'))).toHaveText(''); await expect(element(by.id('messagebox-input'))).toHaveText('');
}); });
}); });
describe('Message', async() => { describe('Message', () => {
it('should copy permalink', async() => { it('should copy permalink', async() => {
await element(by.label(`${ data.random }message`)).atIndex(0).longPress(); await element(by.label(`${ data.random }message`)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist(); await expect(element(by.id('action-sheet'))).toExist();
@ -184,9 +183,9 @@ describe('Room screen', () => {
}); });
it('should star message', async() => { it('should star message', async() => {
await starMessage('message') await starMessage('message');
await sleep(1000) //https://github.com/RocketChat/Rocket.Chat.ReactNative/issues/2324 await sleep(1000); // https://github.com/RocketChat/Rocket.Chat.ReactNative/issues/2324
await element(by.label(`${ data.random }message`)).atIndex(0).longPress(); await element(by.label(`${ data.random }message`)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist(); await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible(); await expect(element(by.id('action-sheet-handle'))).toBeVisible();
@ -229,8 +228,8 @@ describe('Room screen', () => {
}); });
it('should ask for review', async() => { it('should ask for review', async() => {
await dismissReviewNag() //TODO: Create a proper test for this elsewhere. await dismissReviewNag(); // TODO: Create a proper test for this elsewhere.
}) });
it('should remove reaction', async() => { it('should remove reaction', async() => {
await element(by.id('message-reaction-:grinning:')).tap(); await element(by.id('message-reaction-:grinning:')).tap();
@ -263,8 +262,8 @@ describe('Room screen', () => {
}); });
it('should pin message', async() => { it('should pin message', async() => {
await mockMessage('pin') await mockMessage('pin');
await pinMessage('pin') await pinMessage('pin');
await waitFor(element(by.label(`${ data.random }pin`)).atIndex(0)).toExist().withTimeout(5000); await waitFor(element(by.label(`${ data.random }pin`)).atIndex(0)).toExist().withTimeout(5000);
await waitFor(element(by.label(`${ data.users.regular.username } Message pinned`)).atIndex(0)).toExist().withTimeout(5000); await waitFor(element(by.label(`${ data.users.regular.username } Message pinned`)).atIndex(0)).toExist().withTimeout(5000);
@ -277,7 +276,7 @@ describe('Room screen', () => {
}); });
it('should delete message', async() => { it('should delete message', async() => {
await mockMessage('delete') await mockMessage('delete');
await waitFor(element(by.label(`${ data.random }delete`)).atIndex(0)).toBeVisible(); await waitFor(element(by.label(`${ data.random }delete`)).atIndex(0)).toBeVisible();
await element(by.label(`${ data.random }delete`)).atIndex(0).longPress(); await element(by.label(`${ data.random }delete`)).atIndex(0).longPress();

View File

@ -1,9 +1,8 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, tapBack, sleep, searchRoom, mockMessage, starMessage, pinMessage } = require('../../helpers/app'); const {
const { sendMessage } = require('../../helpers/data_setup') navigateToLogin, login, tapBack, sleep, searchRoom, mockMessage, starMessage, pinMessage
} = require('../../helpers/app');
const { sendMessage } = require('../../helpers/data_setup');
async function navigateToRoomActions(type) { async function navigateToRoomActions(type) {
let room; let room;
@ -36,15 +35,14 @@ async function waitForToast() {
} }
describe('Room actions screen', () => { describe('Room actions screen', () => {
before(async() => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin(); await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password); await login(data.users.regular.username, data.users.regular.password);
}); });
describe('Render', async() => { describe('Render', () => {
describe('Direct', async() => { describe('Direct', () => {
before(async() => { before(async() => {
await navigateToRoomActions('d'); await navigateToRoomActions('d');
}); });
@ -52,41 +50,41 @@ describe('Room actions screen', () => {
it('should have room actions screen', async() => { it('should have room actions screen', async() => {
await expect(element(by.id('room-actions-view'))).toExist(); await expect(element(by.id('room-actions-view'))).toExist();
}); });
it('should have info', async() => { it('should have info', async() => {
await expect(element(by.id('room-actions-info'))).toExist(); await expect(element(by.id('room-actions-info'))).toExist();
}); });
// it('should have voice', async() => { // it('should have voice', async() => {
// await expect(element(by.id('room-actions-voice'))).toExist(); // await expect(element(by.id('room-actions-voice'))).toExist();
// }); // });
// it('should have video', async() => { // it('should have video', async() => {
// await expect(element(by.id('room-actions-video'))).toExist(); // await expect(element(by.id('room-actions-video'))).toExist();
// }); // });
it('should have files', async() => { it('should have files', async() => {
await expect(element(by.id('room-actions-files'))).toExist(); await expect(element(by.id('room-actions-files'))).toExist();
}); });
it('should have mentions', async() => { it('should have mentions', async() => {
await expect(element(by.id('room-actions-mentioned'))).toExist(); await expect(element(by.id('room-actions-mentioned'))).toExist();
}); });
it('should have starred', async() => { it('should have starred', async() => {
await expect(element(by.id('room-actions-starred'))).toExist(); await expect(element(by.id('room-actions-starred'))).toExist();
}); });
it('should have share', async() => { it('should have share', async() => {
await waitFor(element(by.id('room-actions-share'))).toExist(); await waitFor(element(by.id('room-actions-share'))).toExist();
await expect(element(by.id('room-actions-share'))).toExist(); await expect(element(by.id('room-actions-share'))).toExist();
}); });
it('should have pinned', async() => { it('should have pinned', async() => {
await waitFor(element(by.id('room-actions-pinned'))).toExist(); await waitFor(element(by.id('room-actions-pinned'))).toExist();
await expect(element(by.id('room-actions-pinned'))).toExist(); await expect(element(by.id('room-actions-pinned'))).toExist();
}); });
it('should have notifications', async() => { it('should have notifications', async() => {
await waitFor(element(by.id('room-actions-notifications'))).toExist(); await waitFor(element(by.id('room-actions-notifications'))).toExist();
await expect(element(by.id('room-actions-notifications'))).toExist(); await expect(element(by.id('room-actions-notifications'))).toExist();
@ -102,7 +100,7 @@ describe('Room actions screen', () => {
}); });
}); });
describe('Channel/Group', async() => { describe('Channel/Group', () => {
before(async() => { before(async() => {
await navigateToRoomActions('c'); await navigateToRoomActions('c');
}); });
@ -110,15 +108,15 @@ describe('Room actions screen', () => {
it('should have room actions screen', async() => { it('should have room actions screen', async() => {
await expect(element(by.id('room-actions-view'))).toExist(); await expect(element(by.id('room-actions-view'))).toExist();
}); });
it('should have info', async() => { it('should have info', async() => {
await expect(element(by.id('room-actions-info'))).toExist(); await expect(element(by.id('room-actions-info'))).toExist();
}); });
// it('should have voice', async() => { // it('should have voice', async() => {
// await expect(element(by.id('room-actions-voice'))).toExist(); // await expect(element(by.id('room-actions-voice'))).toExist();
// }); // });
// it('should have video', async() => { // it('should have video', async() => {
// await expect(element(by.id('room-actions-video'))).toExist(); // await expect(element(by.id('room-actions-video'))).toExist();
// }); // });
@ -130,34 +128,34 @@ describe('Room actions screen', () => {
it('should have add user', async() => { it('should have add user', async() => {
await expect(element(by.id('room-actions-add-user'))).toExist(); await expect(element(by.id('room-actions-add-user'))).toExist();
}); });
it('should have files', async() => { it('should have files', async() => {
await expect(element(by.id('room-actions-files'))).toExist(); await expect(element(by.id('room-actions-files'))).toExist();
}); });
it('should have mentions', async() => { it('should have mentions', async() => {
await expect(element(by.id('room-actions-mentioned'))).toExist(); await expect(element(by.id('room-actions-mentioned'))).toExist();
}); });
it('should have starred', async() => { it('should have starred', async() => {
await expect(element(by.id('room-actions-starred'))).toExist(); await expect(element(by.id('room-actions-starred'))).toExist();
}); });
it('should have share', async() => { it('should have share', async() => {
await waitFor(element(by.id('room-actions-share'))).toExist(); await waitFor(element(by.id('room-actions-share'))).toExist();
await expect(element(by.id('room-actions-share'))).toExist(); await expect(element(by.id('room-actions-share'))).toExist();
}); });
it('should have pinned', async() => { it('should have pinned', async() => {
await waitFor(element(by.id('room-actions-pinned'))).toExist(); await waitFor(element(by.id('room-actions-pinned'))).toExist();
await expect(element(by.id('room-actions-pinned'))).toExist(); await expect(element(by.id('room-actions-pinned'))).toExist();
}); });
it('should have notifications', async() => { it('should have notifications', async() => {
await waitFor(element(by.id('room-actions-notifications'))).toExist(); await waitFor(element(by.id('room-actions-notifications'))).toExist();
await expect(element(by.id('room-actions-notifications'))).toExist(); await expect(element(by.id('room-actions-notifications'))).toExist();
}); });
it('should have leave channel', async() => { it('should have leave channel', async() => {
await waitFor(element(by.id('room-actions-leave-channel'))).toExist(); await waitFor(element(by.id('room-actions-leave-channel'))).toExist();
await expect(element(by.id('room-actions-leave-channel'))).toExist(); await expect(element(by.id('room-actions-leave-channel'))).toExist();
@ -165,7 +163,7 @@ describe('Room actions screen', () => {
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
describe('TDB', async() => { describe('TDB', async() => {
// TODO: test into a jitsi call // TODO: test into a jitsi call
// it('should NOT navigate to voice call', async() => { // it('should NOT navigate to voice call', async() => {
@ -191,7 +189,7 @@ describe('Room actions screen', () => {
// }); // });
}); });
describe('Common', async() => { describe('Common', () => {
it('should show mentioned messages', async() => { it('should show mentioned messages', async() => {
await element(by.id('room-actions-mentioned')).tap(); await element(by.id('room-actions-mentioned')).tap();
await waitFor(element(by.id('mentioned-messages-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('mentioned-messages-view'))).toExist().withTimeout(2000);
@ -200,24 +198,23 @@ describe('Room actions screen', () => {
}); });
it('should show starred message and unstar it', async() => { it('should show starred message and unstar it', async() => {
// Go back to room and send a message
//Go back to room and send a message
await tapBack(); await tapBack();
await mockMessage('messageToStar'); await mockMessage('messageToStar');
//Star the message // Star the message
await starMessage('messageToStar') await starMessage('messageToStar');
//Back into Room Actions // Back into Room Actions
await element(by.id('room-header')).tap(); await element(by.id('room-header')).tap();
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);
//Go to starred messages // Go to starred messages
await element(by.id('room-actions-starred')).tap(); await element(by.id('room-actions-starred')).tap();
await waitFor(element(by.id('starred-messages-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('starred-messages-view'))).toExist().withTimeout(2000);
await waitFor(element(by.label(`${ data.random }messageToStar`).withAncestor(by.id('starred-messages-view')))).toExist().withTimeout(60000); await waitFor(element(by.label(`${ data.random }messageToStar`).withAncestor(by.id('starred-messages-view')))).toExist().withTimeout(60000);
//Unstar message // Unstar message
await element(by.label(`${ data.random }messageToStar`)).atIndex(0).longPress(); await element(by.label(`${ data.random }messageToStar`)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist(); await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible(); await expect(element(by.id('action-sheet-handle'))).toBeVisible();
@ -228,15 +225,14 @@ describe('Room actions screen', () => {
}); });
it('should show pinned message and unpin it', async() => { it('should show pinned message and unpin it', async() => {
// Go back to room and send a message
//Go back to room and send a message
await tapBack(); await tapBack();
await mockMessage('messageToPin'); await mockMessage('messageToPin');
//Pin the message // Pin the message
await pinMessage('messageToPin') await pinMessage('messageToPin');
//Back into Room Actions // Back into Room Actions
await element(by.id('room-header')).tap(); await element(by.id('room-header')).tap();
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);
await element(by.id('room-actions-scrollview')).scrollTo('bottom'); await element(by.id('room-actions-scrollview')).scrollTo('bottom');
@ -273,7 +269,7 @@ describe('Room actions screen', () => {
// }); // });
}); });
describe('Notification', async() => { describe('Notification', () => {
it('should navigate to notification preference view', async() => { it('should navigate to notification preference view', async() => {
await element(by.id('room-actions-scrollview')).scrollTo('bottom'); await element(by.id('room-actions-scrollview')).scrollTo('bottom');
await waitFor(element(by.id('room-actions-notifications'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-actions-notifications'))).toExist().withTimeout(2000);
@ -318,13 +314,13 @@ describe('Room actions screen', () => {
after(async() => { after(async() => {
await backToActions(); await backToActions();
}); });
}) });
describe('Channel/Group', async() => { describe('Channel/Group', () => {
// Currently, there's no way to add more owners to the room // Currently, there's no way to add more owners to the room
// So we test only for the 'You are the last owner...' message // So we test only for the 'You are the last owner...' message
const user = data.users.alternate const user = data.users.alternate;
it('should tap on leave channel and raise alert', async() => { it('should tap on leave channel and raise alert', async() => {
await element(by.id('room-actions-scrollview')).scrollTo('bottom'); await element(by.id('room-actions-scrollview')).scrollTo('bottom');
@ -363,12 +359,24 @@ describe('Room actions screen', () => {
await backToActions(); await backToActions();
}); });
describe('Room Members', async() => { describe('Room Members', () => {
before(async() => { before(async() => {
await element(by.id('room-actions-members')).tap(); await element(by.id('room-actions-members')).tap();
await waitFor(element(by.id('room-members-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-members-view'))).toExist().withTimeout(2000);
}); });
const openActionSheet = async(username) => {
await waitFor(element(by.id(`room-members-view-item-${ username }`))).toExist().withTimeout(5000);
await element(by.id(`room-members-view-item-${ username }`)).tap();
await sleep(300);
await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
};
const closeActionSheet = async() => {
await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6);
};
it('should show all users', async() => { it('should show all users', async() => {
await element(by.id('room-members-view-toggle-status')).tap(); await element(by.id('room-members-view-toggle-status')).tap();
await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000); await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);
@ -397,18 +405,6 @@ describe('Room actions screen', () => {
await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000); await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);
}); });
const openActionSheet = async(username) => {
await waitFor(element(by.id(`room-members-view-item-${ username }`))).toExist().withTimeout(5000);
await element(by.id(`room-members-view-item-${ username }`)).tap();
await sleep(300);
await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
}
const closeActionSheet = async() => {
await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6);
}
it('should set/remove as owner', async() => { it('should set/remove as owner', async() => {
await openActionSheet(user.username); await openActionSheet(user.username);
await element(by.id('action-sheet-set-owner')).tap(); await element(by.id('action-sheet-set-owner')).tap();
@ -504,9 +500,9 @@ describe('Room actions screen', () => {
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
}); });
}); });
}) });
describe('Direct', async() => { describe('Direct', () => {
before(async() => { before(async() => {
await navigateToRoomActions('d'); await navigateToRoomActions('d');
}); });

View File

@ -1,7 +1,6 @@
const { const {
expect, element, by, waitFor navigateToLogin, login, mockMessage, tapBack, searchRoom
} = require('detox'); } = require('../../helpers/app');
const { navigateToLogin, login, mockMessage, tapBack, searchRoom } = require('../../helpers/app');
const data = require('../../data'); const data = require('../../data');
const channel = data.groups.private.name; const channel = data.groups.private.name;
@ -10,28 +9,28 @@ const navigateToRoom = async() => {
await searchRoom(channel); await searchRoom(channel);
await element(by.id(`rooms-list-view-item-${ channel }`)).tap(); await element(by.id(`rooms-list-view-item-${ channel }`)).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
} };
describe('Discussion', () => { describe('Discussion', () => {
before(async() => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
await navigateToLogin(); await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password) await login(data.users.regular.username, data.users.regular.password);
}); });
it('should create discussion from NewMessageView', async() => { it('should create discussion from NewMessageView', async() => {
const discussionName = `${data.random} Discussion NewMessageView`; const discussionName = `${ data.random } Discussion NewMessageView`;
await element(by.id('rooms-list-view-create-channel')).tap(); await element(by.id('rooms-list-view-create-channel')).tap();
await waitFor(element(by.id('new-message-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('new-message-view'))).toExist().withTimeout(2000);
await element(by.label('Create Discussion')).atIndex(0).tap(); await element(by.label('Create Discussion')).atIndex(0).tap();
await waitFor(element(by.id('create-discussion-view'))).toExist().withTimeout(60000); await waitFor(element(by.id('create-discussion-view'))).toExist().withTimeout(60000);
await expect(element(by.id('create-discussion-view'))).toExist(); await expect(element(by.id('create-discussion-view'))).toExist();
await element(by.label('Select a Channel...')).tap(); await element(by.label('Select a Channel...')).tap();
await element(by.id('multi-select-search')).replaceText(`${channel}`); await element(by.id('multi-select-search')).replaceText(`${ channel }`);
await waitFor(element(by.id(`multi-select-item-${channel}`))).toExist().withTimeout(10000); await waitFor(element(by.id(`multi-select-item-${ channel }`))).toExist().withTimeout(10000);
await element(by.id(`multi-select-item-${channel}`)).tap(); await element(by.id(`multi-select-item-${ channel }`)).tap();
await element(by.id('multi-select-discussion-name')).replaceText(discussionName); await element(by.id('multi-select-discussion-name')).replaceText(discussionName);
await waitFor(element(by.id(`create-discussion-submit`))).toExist().withTimeout(10000); await waitFor(element(by.id('create-discussion-submit'))).toExist().withTimeout(10000);
await element(by.id('create-discussion-submit')).tap(); await element(by.id('create-discussion-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-view'))).toExist().withTimeout(10000);
await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000);
@ -40,20 +39,20 @@ describe('Discussion', () => {
}); });
it('should create discussion from action button', async() => { it('should create discussion from action button', async() => {
const discussionName = `${data.random} Discussion Action Button`; const discussionName = `${ data.random } Discussion Action Button`;
await navigateToRoom(); await navigateToRoom();
await element(by.id('messagebox-actions')).tap(); await element(by.id('messagebox-actions')).tap();
await waitFor(element(by.id('action-sheet'))).toExist().withTimeout(2000); await waitFor(element(by.id('action-sheet'))).toExist().withTimeout(2000);
await element(by.label('Create Discussion')).atIndex(0).tap(); await element(by.label('Create Discussion')).atIndex(0).tap();
await waitFor(element(by.id('create-discussion-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('create-discussion-view'))).toExist().withTimeout(2000);
await element(by.id('multi-select-discussion-name')).replaceText(discussionName); await element(by.id('multi-select-discussion-name')).replaceText(discussionName);
await waitFor(element(by.id(`create-discussion-submit`))).toExist().withTimeout(10000); await waitFor(element(by.id('create-discussion-submit'))).toExist().withTimeout(10000);
await element(by.id('create-discussion-submit')).tap(); await element(by.id('create-discussion-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-view'))).toExist().withTimeout(10000);
await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000);
}); });
describe('Create Discussion from action sheet', async() => { describe('Create Discussion from action sheet', () => {
it('should send a message', async() => { it('should send a message', async() => {
await waitFor(element(by.id('messagebox'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('messagebox'))).toBeVisible().withTimeout(60000);
await mockMessage('message'); await mockMessage('message');
@ -63,15 +62,15 @@ describe('Discussion', () => {
const discussionName = `${ data.random }message`; const discussionName = `${ data.random }message`;
await element(by.label(discussionName)).atIndex(0).longPress(); await element(by.label(discussionName)).atIndex(0).longPress();
await waitFor(element(by.id('action-sheet'))).toExist().withTimeout(2000); await waitFor(element(by.id('action-sheet'))).toExist().withTimeout(2000);
await element(by.label(`Start a Discussion`)).atIndex(0).tap(); await element(by.label('Start a Discussion')).atIndex(0).tap();
await waitFor(element(by.id('create-discussion-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('create-discussion-view'))).toExist().withTimeout(2000);
await element(by.id('create-discussion-submit')).tap(); await element(by.id('create-discussion-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-view'))).toExist().withTimeout(10000);
await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000);
}); });
}); });
describe('Check RoomActionsView render', async() => { describe('Check RoomActionsView render', () => {
it('should navigete to RoomActionsView', async() => { it('should navigete to RoomActionsView', async() => {
await waitFor(element(by.id('room-header'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('room-header'))).toBeVisible().withTimeout(5000);
await element(by.id('room-header')).tap(); await element(by.id('room-header')).tap();

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom, starMessage, pinMessage, dismissReviewNag, tryTapping } = require('../../helpers/app'); const {
navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom, dismissReviewNag
} = require('../../helpers/app');
async function navigateToRoom(roomName) { async function navigateToRoom(roomName) {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
@ -20,14 +19,14 @@ describe('Threads', () => {
await navigateToRoom(mainRoom); await navigateToRoom(mainRoom);
}); });
describe('Render', async() => { describe('Render', () => {
it('should have room screen', async() => { it('should have room screen', async() => {
await expect(element(by.id('room-view'))).toExist(); await expect(element(by.id('room-view'))).toExist();
await waitFor(element(by.id(`room-view-title-${ mainRoom }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ mainRoom }`))).toExist().withTimeout(5000);
}); });
// Render - Header // Render - Header
describe('Header', async() => { describe('Header', () => {
it('should have actions button ', async() => { it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist(); await expect(element(by.id('room-header'))).toExist();
}); });
@ -38,7 +37,7 @@ describe('Threads', () => {
}); });
// Render - Messagebox // Render - Messagebox
describe('Messagebox', async() => { describe('Messagebox', () => {
it('should have messagebox', async() => { it('should have messagebox', async() => {
await expect(element(by.id('messagebox'))).toExist(); await expect(element(by.id('messagebox'))).toExist();
}); });
@ -63,8 +62,8 @@ describe('Threads', () => {
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
describe('Thread', async() => { describe('Thread', () => {
const thread = `${ data.random }thread`; const thread = `${ data.random }thread`;
it('should create thread', async() => { it('should create thread', async() => {
await mockMessage('thread'); await mockMessage('thread');
@ -104,9 +103,9 @@ describe('Threads', () => {
const messageText = 'threadonly'; const messageText = 'threadonly';
await mockMessage(messageText, true); await mockMessage(messageText, true);
await tapBack(); await tapBack();
await waitFor(element(by.id('room-header').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('room-header').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000);
await waitFor(element(by.id('room-header').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); await waitFor(element(by.id('room-header').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000);
await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( await sleep(500); // TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :(
await waitFor(element(by.label(`${ data.random }${ messageText }`)).atIndex(0)).toNotExist().withTimeout(2000); await waitFor(element(by.label(`${ data.random }${ messageText }`)).atIndex(0)).toNotExist().withTimeout(2000);
}); });
@ -117,24 +116,24 @@ describe('Threads', () => {
await element(by.id('messagebox-send-to-channel')).tap(); await element(by.id('messagebox-send-to-channel')).tap();
await element(by.id('messagebox-send-message')).tap(); await element(by.id('messagebox-send-message')).tap();
await tapBack(); await tapBack();
await waitFor(element(by.id('room-header').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('room-header').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000);
await waitFor(element(by.id('room-header').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); await waitFor(element(by.id('room-header').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000);
await sleep(500) //TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :( await sleep(500); // TODO: Find a better way to wait for the animation to finish and the messagebox-input to be available and usable :(
await waitFor(element(by.label(messageText)).atIndex(0)).toExist().withTimeout(2000); await waitFor(element(by.label(messageText)).atIndex(0)).toExist().withTimeout(2000);
}); });
it('should navigate to thread from thread name', async() => { it('should navigate to thread from thread name', async() => {
const messageText = 'navthreadname'; const messageText = 'navthreadname';
await mockMessage('dummymessagebetweenthethread'); await mockMessage('dummymessagebetweenthethread');
await dismissReviewNag() //TODO: Create a proper test for this elsewhere. await dismissReviewNag(); // TODO: Create a proper test for this elsewhere.
await element(by.id(`message-thread-button-${ thread }`)).tap(); await element(by.id(`message-thread-button-${ thread }`)).tap();
await element(by.id('messagebox-input-thread')).typeText(messageText); await element(by.id('messagebox-input-thread')).typeText(messageText);
await element(by.id('messagebox-send-to-channel')).tap(); await element(by.id('messagebox-send-to-channel')).tap();
await element(by.id('messagebox-send-message')).tap(); await element(by.id('messagebox-send-message')).tap();
await tapBack(); await tapBack();
await waitFor(element(by.id('room-header').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('room-header').and(by.label(`${ mainRoom }`)))).toBeVisible().withTimeout(2000);
await waitFor(element(by.id('room-header').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000); await waitFor(element(by.id('room-header').and(by.label(`${ data.random }thread`)))).toBeNotVisible().withTimeout(2000);
await waitFor(element(by.id(`message-thread-replied-on-${ thread }`))).toBeVisible().withTimeout(2000); await waitFor(element(by.id(`message-thread-replied-on-${ thread }`))).toBeVisible().withTimeout(2000);
await element(by.id(`message-thread-replied-on-${ thread }`)).tap(); await element(by.id(`message-thread-replied-on-${ thread }`)).tap();
await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000);
await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); await expect(element(by.id(`room-view-title-${ thread }`))).toExist();
@ -155,7 +154,7 @@ describe('Threads', () => {
await tapBack(); await tapBack();
}); });
it('should draft thread message', async () => { it('should draft thread message', async() => {
await element(by.id(`message-thread-button-${ thread }`)).tap(); await element(by.id(`message-thread-button-${ thread }`)).tap();
await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000);
await element(by.id('messagebox-input-thread')).typeText(`${ thread }draft`); await element(by.id('messagebox-input-thread')).typeText(`${ thread }draft`);

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { tapBack, sleep, navigateToLogin, login, tryTapping } = require('../../helpers/app'); const {
navigateToLogin, login
} = require('../../helpers/app');
@ -13,41 +12,39 @@ describe('Group DM', () => {
await login(data.users.regular.username, data.users.regular.password); await login(data.users.regular.username, data.users.regular.password);
}); });
describe('Create Group DM', async() => { describe('Create Group DM', () => {
before(async() => { before(async() => {
await element(by.id('rooms-list-view-create-channel')).tap(); await element(by.id('rooms-list-view-create-channel')).tap();
}); });
describe('Render', async() => { describe('Render', () => {
it('should have new message screen', async() => { it('should have new message screen', async() => {
await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);
}); });
it('should have search input', async() => { it('should have search input', async() => {
await waitFor(element(by.id('new-message-view-search'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('new-message-view-search'))).toBeVisible().withTimeout(2000);
}); });
}) });
describe('Usage', async() => { describe('Usage', () => {
it('should navigate to create DM', async() => { it('should navigate to create DM', async() => {
await element(by.label('Create Direct Messages')).tap(); await element(by.label('Create Direct Messages')).tap();
}); });
it('should add users', async() => { it('should add users', async() => {
await element(by.id('select-users-view-search')).replaceText('rocket.cat'); await element(by.id('select-users-view-search')).replaceText('rocket.cat');
await waitFor(element(by.id(`select-users-view-item-rocket.cat`))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('select-users-view-item-rocket.cat'))).toBeVisible().withTimeout(10000);
await element(by.id('select-users-view-item-rocket.cat')).tap(); await element(by.id('select-users-view-item-rocket.cat')).tap();
await element(by.id('select-users-view-search')).replaceText(data.users.existing.username); await element(by.id('select-users-view-search')).replaceText(data.users.existing.username);
await waitFor(element(by.id(`select-users-view-item-${data.users.existing.username}`))).toBeVisible().withTimeout(10000); await waitFor(element(by.id(`select-users-view-item-${ data.users.existing.username }`))).toBeVisible().withTimeout(10000);
await element(by.id(`select-users-view-item-${data.users.existing.username}`)).tap(); await element(by.id(`select-users-view-item-${ data.users.existing.username }`)).tap();
await element(by.id('selected-users-view-submit')).tap(); await element(by.id('selected-users-view-submit')).tap();
}); });
it('check Group DM exist', async() => { it('check Group DM exist', async() => {
await waitFor(element(by.id(`room-view-title-${data.users.existing.username}, rocket.cat`))).toExist().withTimeout(10000); await waitFor(element(by.id(`room-view-title-${ data.users.existing.username }, rocket.cat`))).toExist().withTimeout(10000);
}); });
});
})
}); });
}); });

View File

@ -1,9 +1,8 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, searchRoom, sleep } = require('../../helpers/app'); const {
const { sendMessage } = require('../../helpers/data_setup') navigateToLogin, login, searchRoom, sleep
} = require('../../helpers/app');
const { sendMessage } = require('../../helpers/data_setup');
async function navigateToRoom(user) { async function navigateToRoom(user) {
await searchRoom(`${ user }`); await searchRoom(`${ user }`);
@ -12,7 +11,7 @@ async function navigateToRoom(user) {
} }
describe('Mark as unread', () => { describe('Mark as unread', () => {
const user = data.users.alternate.username const user = data.users.alternate.username;
before(async() => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
@ -21,9 +20,8 @@ describe('Mark as unread', () => {
await navigateToRoom(user); await navigateToRoom(user);
}); });
// TODO: Fix flakiness. If it fails, run it solo. describe('Usage', () => {
describe('Usage', async() => { describe('Mark message as unread', () => {
describe('Mark message as unread', async() => {
it('should mark message as unread', async() => { it('should mark message as unread', async() => {
const message = `${ data.random }message-mark-as-unread`; const message = `${ data.random }message-mark-as-unread`;
const channelName = `@${ data.users.regular.username }`; const channelName = `@${ data.users.regular.username }`;
@ -35,7 +33,7 @@ describe('Mark as unread', () => {
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5); await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.label('Mark Unread')).atIndex(0).tap(); await element(by.label('Mark Unread')).atIndex(0).tap();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(5000);
await expect(element(by.id(`rooms-list-view-item-${data.users.alternate.username}`))).toExist(); await expect(element(by.id(`rooms-list-view-item-${ data.users.alternate.username }`))).toExist();
}); });
}); });
}); });

View File

@ -1,10 +1,9 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, tapBack, sleep, searchRoom } = require('../../helpers/app'); const {
navigateToLogin, login, tapBack, sleep, searchRoom
} = require('../../helpers/app');
const privateRoomName = data.groups.private.name const privateRoomName = data.groups.private.name;
async function navigateToRoomInfo(type) { async function navigateToRoomInfo(type) {
let room; let room;
@ -31,14 +30,13 @@ async function waitForToast() {
} }
describe('Room info screen', () => { describe('Room info screen', () => {
before(async() => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin(); await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password); await login(data.users.regular.username, data.users.regular.password);
}); });
describe('Direct', async() => { describe('Direct', () => {
before(async() => { before(async() => {
await navigateToRoomInfo('d'); await navigateToRoomInfo('d');
}); });
@ -49,107 +47,107 @@ describe('Room info screen', () => {
}); });
after(async() => { after(async() => {
await tapBack() await tapBack();
await tapBack() await tapBack();
await tapBack() await tapBack();
}) });
}); });
describe('Channel/Group', async() => { describe('Channel/Group', () => {
before(async() => { before(async() => {
await navigateToRoomInfo('c'); await navigateToRoomInfo('c');
}); });
describe('Render', async() => { describe('Render', () => {
it('should have room info view', async() => { it('should have room info view', async() => {
await expect(element(by.id('room-info-view'))).toExist(); await expect(element(by.id('room-info-view'))).toExist();
}); });
it('should have name', async() => { it('should have name', async() => {
await expect(element(by.id('room-info-view-name'))).toExist(); await expect(element(by.id('room-info-view-name'))).toExist();
}); });
it('should have description', async() => { it('should have description', async() => {
await expect(element(by.label('Description'))).toExist(); await expect(element(by.label('Description'))).toExist();
}); });
it('should have topic', async() => { it('should have topic', async() => {
await expect(element(by.label('Topic'))).toExist(); await expect(element(by.label('Topic'))).toExist();
}); });
it('should have announcement', async() => { it('should have announcement', async() => {
await expect(element(by.label('Announcement'))).toExist(); await expect(element(by.label('Announcement'))).toExist();
}); });
it('should have edit button', async() => { it('should have edit button', async() => {
await expect(element(by.id('room-info-view-edit-button'))).toExist(); await expect(element(by.id('room-info-view-edit-button'))).toExist();
}); });
}); });
describe('Render Edit', async() => { describe('Render Edit', () => {
before(async() => { before(async() => {
await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000);
await element(by.id('room-info-view-edit-button')).tap(); await element(by.id('room-info-view-edit-button')).tap();
await waitFor(element(by.id('room-info-edit-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-info-edit-view'))).toExist().withTimeout(2000);
}); });
it('should have room info edit view', async() => { it('should have room info edit view', async() => {
await expect(element(by.id('room-info-edit-view'))).toExist(); await expect(element(by.id('room-info-edit-view'))).toExist();
}); });
it('should have name input', async() => { it('should have name input', async() => {
await expect(element(by.id('room-info-edit-view-name'))).toExist(); await expect(element(by.id('room-info-edit-view-name'))).toExist();
}); });
it('should have description input', async() => { it('should have description input', async() => {
await expect(element(by.id('room-info-edit-view-description'))).toExist(); await expect(element(by.id('room-info-edit-view-description'))).toExist();
}); });
it('should have topic input', async() => { it('should have topic input', async() => {
await expect(element(by.id('room-info-edit-view-topic'))).toExist(); await expect(element(by.id('room-info-edit-view-topic'))).toExist();
}); });
it('should have announcement input', async() => { it('should have announcement input', async() => {
await expect(element(by.id('room-info-edit-view-announcement'))).toExist(); await expect(element(by.id('room-info-edit-view-announcement'))).toExist();
}); });
it('should have password input', async() => { it('should have password input', async() => {
await expect(element(by.id('room-info-edit-view-password'))).toExist(); await expect(element(by.id('room-info-edit-view-password'))).toExist();
}); });
it('should have type switch', async() => { it('should have type switch', async() => {
// Ugly hack to scroll on detox // Ugly hack to scroll on detox
await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.8); await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.8);
await expect(element(by.id('room-info-edit-view-t'))).toExist(); await expect(element(by.id('room-info-edit-view-t'))).toExist();
}); });
it('should have ready only switch', async() => { it('should have ready only switch', async() => {
await expect(element(by.id('room-info-edit-view-ro'))).toExist(); await expect(element(by.id('room-info-edit-view-ro'))).toExist();
}); });
it('should have submit button', async() => { it('should have submit button', async() => {
await expect(element(by.id('room-info-edit-view-submit'))).toExist(); await expect(element(by.id('room-info-edit-view-submit'))).toExist();
}); });
it('should have reset button', async() => { it('should have reset button', async() => {
await expect(element(by.id('room-info-edit-view-reset'))).toExist(); await expect(element(by.id('room-info-edit-view-reset'))).toExist();
}); });
it('should have archive button', async() => { it('should have archive button', async() => {
await expect(element(by.id('room-info-edit-view-archive'))).toExist(); await expect(element(by.id('room-info-edit-view-archive'))).toExist();
}); });
it('should have delete button', async() => { it('should have delete button', async() => {
await expect(element(by.id('room-info-edit-view-delete'))).toExist(); await expect(element(by.id('room-info-edit-view-delete'))).toExist();
}); });
after(async() => { after(async() => {
// Ugly hack to scroll on detox // Ugly hack to scroll on detox
await element(by.id('room-info-edit-view-list')).swipe('down', 'fast', 0.8); await element(by.id('room-info-edit-view-list')).swipe('down', 'fast', 0.8);
}); });
}); });
describe('Usage', async() => { describe('Usage', () => {
// it('should enter "invalid name" and get error', async() => { // it('should enter "invalid name" and get error', async() => {
// await element(by.type('UIScrollView')).atIndex(1).swipe('down'); // await element(by.type('UIScrollView')).atIndex(1).swipe('down');
// await element(by.id('room-info-edit-view-name')).replaceText('invalid name'); // await element(by.id('room-info-edit-view-name')).replaceText('invalid name');
@ -161,7 +159,7 @@ describe('Room info screen', () => {
// await waitFor(element(by.text('There was an error while saving settings!'))).toBeNotVisible().withTimeout(10000); // await waitFor(element(by.text('There was an error while saving settings!'))).toBeNotVisible().withTimeout(10000);
// await element(by.type('UIScrollView')).atIndex(1).swipe('down'); // await element(by.type('UIScrollView')).atIndex(1).swipe('down');
// }); // });
it('should change room name', async() => { it('should change room name', async() => {
await element(by.id('room-info-edit-view-name')).replaceText(`${ privateRoomName }new`); await element(by.id('room-info-edit-view-name')).replaceText(`${ privateRoomName }new`);
await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5); await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5);
@ -179,7 +177,7 @@ describe('Room info screen', () => {
await waitForToast(); await waitForToast();
await element(by.id('room-info-edit-view-list')).swipe('down', 'fast', 0.8); await element(by.id('room-info-edit-view-list')).swipe('down', 'fast', 0.8);
}); });
it('should reset form', async() => { it('should reset form', async() => {
await element(by.id('room-info-edit-view-name')).replaceText('abc'); await element(by.id('room-info-edit-view-name')).replaceText('abc');
await element(by.id('room-info-edit-view-description')).replaceText('abc'); await element(by.id('room-info-edit-view-description')).replaceText('abc');
@ -188,7 +186,7 @@ describe('Room info screen', () => {
await element(by.id('room-info-edit-view-password')).replaceText('abc'); await element(by.id('room-info-edit-view-password')).replaceText('abc');
await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5); await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5);
await element(by.id('room-info-edit-view-t')).tap(); await element(by.id('room-info-edit-view-t')).tap();
await element(by.id('room-info-edit-view-ro')).longPress(); //https://github.com/facebook/react-native/issues/28032 await element(by.id('room-info-edit-view-ro')).longPress(); // https://github.com/facebook/react-native/issues/28032
await element(by.id('room-info-edit-view-react-when-ro')).tap(); await element(by.id('room-info-edit-view-react-when-ro')).tap();
await element(by.id('room-info-edit-view-reset')).tap(); await element(by.id('room-info-edit-view-reset')).tap();
// after reset // after reset
@ -202,7 +200,7 @@ describe('Room info screen', () => {
await expect(element(by.id('room-info-edit-view-react-when-ro'))).toBeNotVisible(); await expect(element(by.id('room-info-edit-view-react-when-ro'))).toBeNotVisible();
await element(by.id('room-info-edit-view-list')).swipe('down', 'fast', 0.8); await element(by.id('room-info-edit-view-list')).swipe('down', 'fast', 0.8);
}); });
it('should change room description', async() => { it('should change room description', async() => {
await element(by.id('room-info-edit-view-description')).replaceText('new description'); await element(by.id('room-info-edit-view-description')).replaceText('new description');
await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5); await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5);
@ -212,7 +210,7 @@ describe('Room info screen', () => {
await waitFor(element(by.id('room-info-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-info-view'))).toExist().withTimeout(2000);
await expect(element(by.label('new description').withAncestor(by.id('room-info-view-description')))).toExist(); await expect(element(by.label('new description').withAncestor(by.id('room-info-view-description')))).toExist();
}); });
it('should change room topic', async() => { it('should change room topic', async() => {
await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000);
await element(by.id('room-info-view-edit-button')).tap(); await element(by.id('room-info-view-edit-button')).tap();
@ -225,7 +223,7 @@ describe('Room info screen', () => {
await waitFor(element(by.id('room-info-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-info-view'))).toExist().withTimeout(2000);
await expect(element(by.label('new topic').withAncestor(by.id('room-info-view-topic')))).toExist(); await expect(element(by.label('new topic').withAncestor(by.id('room-info-view-topic')))).toExist();
}); });
it('should change room announcement', async() => { it('should change room announcement', async() => {
await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000);
await element(by.id('room-info-view-edit-button')).tap(); await element(by.id('room-info-view-edit-button')).tap();
@ -238,7 +236,7 @@ describe('Room info screen', () => {
await waitFor(element(by.id('room-info-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-info-view'))).toExist().withTimeout(2000);
await expect(element(by.label('new announcement').withAncestor(by.id('room-info-view-announcement')))).toExist(); await expect(element(by.label('new announcement').withAncestor(by.id('room-info-view-announcement')))).toExist();
}); });
it('should change room password', async() => { it('should change room password', async() => {
await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000);
await element(by.id('room-info-view-edit-button')).tap(); await element(by.id('room-info-view-edit-button')).tap();
@ -248,7 +246,7 @@ describe('Room info screen', () => {
await element(by.id('room-info-edit-view-submit')).tap(); await element(by.id('room-info-edit-view-submit')).tap();
await waitForToast(); await waitForToast();
}); });
it('should change room type', async() => { it('should change room type', async() => {
await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5); await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5);
await element(by.id('room-info-edit-view-t')).tap(); await element(by.id('room-info-edit-view-t')).tap();
@ -258,7 +256,7 @@ describe('Room info screen', () => {
await element(by.id('room-info-edit-view-submit')).tap(); await element(by.id('room-info-edit-view-submit')).tap();
await waitForToast(); await waitForToast();
}); });
// it('should change room read only and allow reactions', async() => { // it('should change room read only and allow reactions', async() => {
// await sleep(1000); // await sleep(1000);
// await element(by.type('UIScrollView')).atIndex(1).swipe('up'); // await element(by.type('UIScrollView')).atIndex(1).swipe('up');
@ -270,7 +268,7 @@ describe('Room info screen', () => {
// await waitForToast(); // await waitForToast();
// // TODO: test if it's possible to react // // TODO: test if it's possible to react
// }); // });
it('should archive room', async() => { it('should archive room', async() => {
await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5); await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5);
await element(by.id('room-info-edit-view-archive')).tap(); await element(by.id('room-info-edit-view-archive')).tap();

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, mockMessage, tapBack, login, sleep, searchRoom } = require('../../helpers/app'); const {
navigateToLogin, tapBack, login, searchRoom
} = require('../../helpers/app');
async function navigateToRoom(roomName) { async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`); await searchRoom(`${ roomName }`);
@ -20,9 +19,9 @@ async function clearCache() {
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.label('Clear').and(by.type('_UIAlertControllerActionView'))).tap(); await element(by.label('Clear').and(by.type('_UIAlertControllerActionView'))).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-jumping`))).toExist().withTimeout(10000); await waitFor(element(by.id('rooms-list-view-item-jumping'))).toExist().withTimeout(10000);
} }
async function waitForLoading() { async function waitForLoading() {
@ -51,7 +50,7 @@ describe('Room', () => {
await element(by.id('nav-jump-to-bottom')).tap(); await element(by.id('nav-jump-to-bottom')).tap();
await waitFor(element(by.label('Quote first message'))).toExist().withTimeout(5000); await waitFor(element(by.label('Quote first message'))).toExist().withTimeout(5000);
await clearCache(); await clearCache();
}) });
it('should load messages on scroll', async() => { it('should load messages on scroll', async() => {
await navigateToRoom('jumping'); await navigateToRoom('jumping');
@ -64,6 +63,7 @@ describe('Room', () => {
await expect(element(by.label('249'))).toExist(); await expect(element(by.label('249'))).toExist();
found = true; found = true;
} catch { } catch {
//
} }
} }
await clearCache(); await clearCache();
@ -80,7 +80,7 @@ describe('Room', () => {
await expect(element(by.label('30'))).toExist(); await expect(element(by.label('30'))).toExist();
await expect(element(by.label('31'))).toExist(); await expect(element(by.label('31'))).toExist();
await expect(element(by.label('32'))).toExist(); await expect(element(by.label('32'))).toExist();
}) });
it('should load newer and older messages', async() => { it('should load newer and older messages', async() => {
await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.8); await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.8);
@ -114,9 +114,9 @@ describe('Room', () => {
const expectThreadMessages = async(message) => { const expectThreadMessages = async(message) => {
await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);
await expect(element(by.label(message))).toExist(); await expect(element(by.label(message))).toExist();
} };
describe('Threads', async() => { describe('Threads', () => {
it('should navigate to a thread from another room', async() => { it('should navigate to a thread from another room', async() => {
await navigateToRoom('jumping'); await navigateToRoom('jumping');
await waitFor(element(by.label('Go to jumping-thread\'s thread')).atIndex(0)).toExist().withTimeout(5000); await waitFor(element(by.label('Go to jumping-thread\'s thread')).atIndex(0)).toExist().withTimeout(5000);
@ -150,5 +150,5 @@ describe('Threads', async() => {
await expectThreadMessages('to be searched'); await expectThreadMessages('to be searched');
}); });
//TODO: Threads pagination // TODO: Threads pagination
}); });

View File

@ -1,6 +1,3 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login } = require('../../helpers/app'); const { navigateToLogin, login } = require('../../helpers/app');
@ -13,7 +10,7 @@ describe('Create team screen', () => {
await login(data.users.regular.username, data.users.regular.password); await login(data.users.regular.username, data.users.regular.password);
}); });
describe('New Message', async() => { describe('New Message', () => {
before(async() => { before(async() => {
await element(by.id('rooms-list-view-create-channel')).tap(); await element(by.id('rooms-list-view-create-channel')).tap();
}); });
@ -28,17 +25,17 @@ describe('Create team screen', () => {
}); });
}); });
describe('Select Users', async() => { describe('Select Users', () => {
it('should nav to create team', async() => { it('should nav to create team', async() => {
await element(by.id('selected-users-view-submit')).tap(); await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000); await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);
}); });
}) });
describe('Create Team', async() => { describe('Create Team', () => {
describe('Usage', async() => { describe('Usage', () => {
it('should get invalid team name', async() => { it('should get invalid team name', async() => {
await element(by.id('create-channel-name')).typeText(`${data.teams.private.name}`); await element(by.id('create-channel-name')).typeText(`${ data.teams.private.name }`);
await element(by.id('create-channel-submit')).tap(); await element(by.id('create-channel-submit')).tap();
await element(by.text('OK')).tap(); await element(by.text('OK')).tap();
}); });
@ -52,10 +49,10 @@ describe('Create team screen', () => {
await waitFor(element(by.id(`room-view-title-${ teamName }`))).toExist().withTimeout(6000); await waitFor(element(by.id(`room-view-title-${ teamName }`))).toExist().withTimeout(6000);
await expect(element(by.id(`room-view-title-${ teamName }`))).toExist(); await expect(element(by.id(`room-view-title-${ teamName }`))).toExist();
}); });
}) });
}); });
describe('Delete Team', async() => { describe('Delete Team', () => {
it('should navigate to room info edit view', async() => { it('should navigate to room info edit view', async() => {
await element(by.id('room-header')).tap(); await element(by.id('room-header')).tap();
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, tapBack, sleep, searchRoom } = require('../../helpers/app'); const {
navigateToLogin, login, tapBack, sleep, searchRoom
} = require('../../helpers/app');
async function navigateToRoom(roomName) { async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`); await searchRoom(`${ roomName }`);
@ -29,7 +28,7 @@ async function backToActions() {
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000);
} }
async function closeActionSheet() { async function closeActionSheet() {
await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6); await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6);
} }
async function waitForToast() { async function waitForToast() {
@ -49,13 +48,13 @@ describe('Team', () => {
await navigateToRoom(team); await navigateToRoom(team);
}); });
describe('Team Room', async() => { describe('Team Room', () => {
describe('Team Header', async() => { describe('Team Header', () => {
it('should have actions button ', async() => { it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist(); await expect(element(by.id('room-header'))).toExist();
}); });
it('should have team channels button ', async() => { it('should have team channels button ', async() => {
await expect(element(by.id('room-view-header-team-channels'))).toExist(); await expect(element(by.id('room-view-header-team-channels'))).toExist();
}); });
@ -69,19 +68,19 @@ describe('Team', () => {
}); });
}); });
describe('Team Header Usage', async() => { describe('Team Header Usage', () => {
it('should navigate to team channels view', async() => { it('should navigate to team channels view', async() => {
await element(by.id('room-view-header-team-channels')).tap(); await element(by.id('room-view-header-team-channels')).tap();
await waitFor(element(by.id('team-channels-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('team-channels-view'))).toExist().withTimeout(5000);
}); });
}) });
describe('Team Channels Header', async() => { describe('Team Channels Header', () => {
it('should have actions button ', async() => { it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist(); await expect(element(by.id('room-header'))).toExist();
}); });
it('should have team channels button ', async() => { it('should have team channels button ', async() => {
await expect(element(by.id('team-channels-view-create'))).toExist(); await expect(element(by.id('team-channels-view-create'))).toExist();
}); });
@ -90,10 +89,10 @@ describe('Team', () => {
}); });
}); });
describe('Team Channels Header Usage', async() => { describe('Team Channels Header Usage', () => {
it('should navigate to add team channels view', async() => { it('should navigate to add team channels view', async() => {
await element(by.id('team-channels-view-create')).tap(); await element(by.id('team-channels-view-create')).tap();
await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);
}); });
it('should have create new button', async() => { it('should have create new button', async() => {
@ -103,11 +102,10 @@ describe('Team', () => {
it('should add existing button', async() => { it('should add existing button', async() => {
await waitFor(element(by.id('add-channel-team-view-add-existing'))).toExist().withTimeout(5000); await waitFor(element(by.id('add-channel-team-view-add-existing'))).toExist().withTimeout(5000);
}); });
}) });
describe('Channels', async() => { describe('Channels', () => {
it('should create new channel for team', async() => { it('should create new channel for team', async() => {
await element(by.id('add-channel-team-view-create-channel')).tap(); await element(by.id('add-channel-team-view-create-channel')).tap();
await element(by.id('select-users-view-search')).replaceText('rocket.cat'); await element(by.id('select-users-view-search')).replaceText('rocket.cat');
@ -138,12 +136,11 @@ describe('Team', () => {
}); });
it('should add existing channel to team', async() => { it('should add existing channel to team', async() => {
await element(by.id('team-channels-view-create')).tap(); await element(by.id('team-channels-view-create')).tap();
await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);
await element(by.id('add-channel-team-view-add-existing')).tap(); await element(by.id('add-channel-team-view-add-existing')).tap();
await waitFor(element(by.id('add-existing-channel-view'))).toExist().withTimeout(60000) await waitFor(element(by.id('add-existing-channel-view'))).toExist().withTimeout(60000);
await expect(element(by.id(`add-existing-channel-view-item-${ existingRoom }`))).toExist(); await expect(element(by.id(`add-existing-channel-view-item-${ existingRoom }`))).toExist();
await element(by.id(`add-existing-channel-view-item-${ existingRoom }`)).tap(); await element(by.id(`add-existing-channel-view-item-${ existingRoom }`)).tap();
await waitFor(element(by.id('add-existing-channel-view-submit'))).toExist().withTimeout(6000); await waitFor(element(by.id('add-existing-channel-view-submit'))).toExist().withTimeout(6000);
@ -174,14 +171,14 @@ describe('Team', () => {
await waitFor(element(by.id('auto-join-tag'))).toBeNotVisible().withTimeout(5000); await waitFor(element(by.id('auto-join-tag'))).toBeNotVisible().withTimeout(5000);
await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(6000); await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(6000);
}); });
}) });
describe('Team actions', () => { describe('Team actions', () => {
before(async() => { before(async() => {
await tapBack(); await tapBack();
await navigateToRoomActions(); await navigateToRoomActions();
}); });
it('should add users to the team', async() => { it('should add users to the team', async() => {
await waitFor(element(by.id('room-actions-add-user'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-actions-add-user'))).toExist().withTimeout(10000);
await element(by.id('room-actions-add-user')).tap(); await element(by.id('room-actions-add-user')).tap();
@ -214,9 +211,9 @@ describe('Team', () => {
await element(by.id('room-actions-leave-channel')).tap(); await element(by.id('room-actions-leave-channel')).tap();
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${room}`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${existingRoom}`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000);
await element(by.id(`select-list-view-item-${room}`)).tap(); await element(by.id(`select-list-view-item-${ room }`)).tap();
await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000); await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000);
await element(by.text('OK')).tap(); await element(by.text('OK')).tap();
@ -227,8 +224,8 @@ describe('Team', () => {
await tapBack(); await tapBack();
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000);
}); });
describe('Room Members', async() => { describe('Room Members', () => {
before(async() => { before(async() => {
await element(by.id('room-actions-members')).tap(); await element(by.id('room-actions-members')).tap();
await waitFor(element(by.id('room-members-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-members-view'))).toExist().withTimeout(2000);
@ -278,9 +275,9 @@ describe('Team', () => {
await element(by.id('room-actions-leave-channel')).tap(); await element(by.id('room-actions-leave-channel')).tap();
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${room}`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${existingRoom}`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000);
await element(by.id(`select-list-view-item-${room}`)).tap(); await element(by.id(`select-list-view-item-${ room }`)).tap();
await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000); await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000);
await element(by.text('OK')).tap(); await element(by.text('OK')).tap();
@ -291,4 +288,4 @@ describe('Team', () => {
}); });
}); });
}); });
}); });

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data'); const data = require('../../data');
const { navigateToLogin, login, tapBack, searchRoom, sleep } = require('../../helpers/app'); const {
navigateToLogin, login, tapBack, searchRoom, sleep
} = require('../../helpers/app');
const toBeConverted = `to-be-converted-${ data.random }`; const toBeConverted = `to-be-converted-${ data.random }`;
const toBeMoved = `to-be-moved-${ data.random }`; const toBeMoved = `to-be-moved-${ data.random }`;
@ -21,7 +20,7 @@ const createChannel = async(room) => {
await tapBack(); await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000); await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
} };
async function navigateToRoom(room) { async function navigateToRoom(room) {
await searchRoom(`${ room }`); await searchRoom(`${ room }`);
@ -42,7 +41,7 @@ describe('Move/Convert Team', () => {
await login(data.users.regular.username, data.users.regular.password); await login(data.users.regular.username, data.users.regular.password);
}); });
describe('Convert', async() => { describe('Convert', () => {
before(async() => { before(async() => {
await createChannel(toBeConverted); await createChannel(toBeConverted);
}); });
@ -61,10 +60,10 @@ describe('Move/Convert Team', () => {
after(async() => { after(async() => {
await tapBack(); await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
}) });
}); });
describe('Move', async() => { describe('Move', () => {
before(async() => { before(async() => {
await createChannel(toBeMoved); await createChannel(toBeMoved);
}); });
@ -78,12 +77,12 @@ describe('Move/Convert Team', () => {
await element(by.id('select-list-view-submit')).tap(); await element(by.id('select-list-view-submit')).tap();
await sleep(2000); await sleep(2000);
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${toBeConverted}`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ toBeConverted }`))).toExist().withTimeout(2000);
await element(by.id(`select-list-view-item-${toBeConverted}`)).tap(); await element(by.id(`select-list-view-item-${ toBeConverted }`)).tap();
await element(by.id('select-list-view-submit')).atIndex(0).tap(); await element(by.id('select-list-view-submit')).atIndex(0).tap();
await waitFor(element(by.label('After reading the previous intructions about this behavior, do you still want to move this channel to the selected team?'))).toExist().withTimeout(2000); await waitFor(element(by.label('After reading the previous intructions about this behavior, do you still want to move this channel to the selected team?'))).toExist().withTimeout(2000);
await element(by.text('Yes, move it!')).tap(); await element(by.text('Yes, move it!')).tap();
await waitFor(element(by.id('room-view-header-team-channels'))).toExist().withTimeout(10000); await waitFor(element(by.id('room-view-header-team-channels'))).toExist().withTimeout(10000);
}); });
}) });
}); });