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__
node_modules
coverage
e2e
e2e/docker
android
ios

View File

@ -29,7 +29,8 @@ module.exports = {
"commonjs": true,
"es6": true,
"node": true,
"jquery": true
"jquery": true,
"mocha": true
},
"rules": {
"react/jsx-filename-extension": [1, {
@ -155,5 +156,23 @@ module.exports = {
},
"globals": {
"__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,4 +1,5 @@
const random = require('./helpers/random');
const value = random(20);
const data = {
server: 'https://mobile.rocket.chat',
@ -71,5 +72,5 @@ const data = {
email: `mobile+registeringfour${ value }@rocket.chat`
},
random: value
}
};
module.exports = data;

View File

@ -1,4 +1,6 @@
// eslint-disable-next-line import/no-unresolved
const random = require('./helpers/random');
const value = random(20);
const data = {
server: 'https://mobile.rocket.chat',
@ -68,5 +70,5 @@ const data = {
email: `mobile+registeringfour${ value }@rocket.chat`
},
random: value
}
};
module.exports = data;

View File

@ -1,4 +1,6 @@
// eslint-disable-next-line import/no-unresolved
const random = require('./helpers/random');
const value = random(20);
const data = {
server: 'http://localhost:3000',
@ -71,5 +73,5 @@ const data = {
email: `mobile+registeringfour${ value }@rocket.chat`
},
random: value
}
};
module.exports = data;

View File

@ -1,6 +1,3 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../data');
async function navigateToWorkspace(server = data.server) {
@ -52,27 +49,27 @@ async function logout() {
}
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)).typeText(`${ data.random }${ message }`);
await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by.label(`${ data.random }${ message }`))).toExist().withTimeout(60000);
await expect(element(by.label(`${ data.random }${ message }`))).toExist();
await element(by.label(`${ data.random }${ message }`)).atIndex(0).tap();
};
}
async function starMessage(message) {
const messageLabel = `${ data.random }${ 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 }`
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();
@ -91,7 +88,7 @@ async function tapBack() {
await element(by.id('header-back')).atIndex(0).tap();
}
async function sleep(ms) {
function sleep(ms) {
return new Promise(res => setTimeout(res, ms));
}
@ -107,16 +104,16 @@ async function searchRoom(room) {
async function tryTapping(theElement, timeout, longtap = false) {
try {
if (longtap) {
await theElement.longPress()
await theElement.longPress();
} else {
await theElement.tap()
await theElement.tap();
}
} catch (e) {
if (timeout <= 0) { // TODO: Maths. How closely has the timeout been honoured here?
throw e
throw e;
}
await sleep(100)
await tryTapping(theElement, timeout - 100)
await sleep(100);
await tryTapping(theElement, timeout - 100);
}
}
@ -126,7 +123,7 @@ const checkServer = async(server) => {
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
await waitFor(element(by.label(label))).toBeVisible().withTimeout(10000);
await element(by.id('sidebar-close-drawer')).tap();
}
};
module.exports = {
navigateToWorkspace,

View File

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

View File

@ -1,12 +1,11 @@
const {
expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout } = require('../../helpers/app');
navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout
} = require('../../helpers/app');
const data = require('../../data');
const testuser = data.users.regular
const otheruser = data.users.alternate
const testuser = data.users.regular;
const otheruser = data.users.alternate;
const checkServer = async(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.label(label))).toBeVisible().withTimeout(60000);
await element(by.id('sidebar-close-drawer')).tap();
}
};
const checkBanner = async() => {
await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(10000);
}
};
async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`);
@ -51,14 +50,14 @@ describe('E2E Encryption', () => {
await login(testuser.username, testuser.password);
});
describe('Banner', async() => {
describe('Render', async () => {
describe('Banner', () => {
describe('Render', () => {
it('should have encryption badge', async() => {
await checkBanner();
});
});
describe('Usage', async () => {
describe('Usage', () => {
it('should tap encryption badge and open save password modal', async() => {
await element(by.id('listheader-encryption')).tap();
await waitFor(element(by.id('e2e-save-password-view'))).toBeVisible().withTimeout(2000);
@ -98,9 +97,9 @@ describe('E2E Encryption', () => {
await tapBack();
});
});
})
});
describe('Security and Privacy', async() => {
describe('Security and Privacy', () => {
it('should navigate to security privacy', async() => {
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
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() => {
await element(by.id('security-privacy-view-e2e-encryption')).tap();
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-reset-key').and(by.label('Reset E2E Key')))).toExist();
});
})
});
describe('Change password', async() => {
describe('Change password', () => {
it('should change password', async() => {
await element(by.id('e2e-encryption-security-view-password')).typeText(newPassword);
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() => {
await tapBack();
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 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 sleep(2000)
await sleep(2000);
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 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 login(testuser.username, testuser.password);
await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(2000);
})
});
});
});
@ -211,7 +210,7 @@ describe('E2E Encryption', () => {
it('check save banner', async() => {
await checkServer(data.server);
await checkBanner();
})
});
it('should add server and create new user', async() => {
await sleep(5000);

View File

@ -1,13 +1,13 @@
// const OTP = require('otp.js');
// const GA = OTP.googleAuthenticator;
const {
device, expect, element, by, waitFor
} = require('detox');
const OTP = require('otp.js');
const GA = OTP.googleAuthenticator;
const { navigateToLogin, login, mockMessage, tapBack, sleep, searchRoom } = require('../../helpers/app');
navigateToLogin, login, mockMessage, tapBack, searchRoom
} = require('../../helpers/app');
const data = require('../../data');
const testuser = data.users.regular
const otheruser = data.users.alternate
const testuser = data.users.regular;
const otheruser = data.users.alternate;
describe('Broadcast room', () => {
before(async() => {

View File

@ -1,10 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, sleep } = require('../../helpers/app');
const data = require('../../data');
const profileChangeUser = data.users.profileChanges
const profileChangeUser = data.users.profileChanges;
const scrollDown = 200;
@ -28,7 +25,7 @@ describe('Profile screen', () => {
await waitFor(element(by.id('profile-view'))).toBeVisible().withTimeout(2000);
});
describe('Render', async() => {
describe('Render', () => {
it('should have profile view', async() => {
await expect(element(by.id('profile-view'))).toBeVisible();
});
@ -74,7 +71,7 @@ describe('Profile screen', () => {
});
});
describe('Usage', async() => {
describe('Usage', () => {
it('should change name and username', async() => {
await element(by.id('profile-view-name')).replaceText(`${ 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-new-password')).replaceText(`${ profileChangeUser.password }new`);
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();
});

View File

@ -1,11 +1,8 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, tapBack } = require('../../helpers/app');
const { navigateToLogin, login } = require('../../helpers/app');
const data = require('../../data');
const testuser = data.users.regular
const testuser = data.users.regular;
describe('Settings screen', () => {
before(async() => {
@ -20,7 +17,7 @@ describe('Settings screen', () => {
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
});
describe('Render', async() => {
describe('Render', () => {
it('should have settings view', async() => {
await expect(element(by.id('settings-view'))).toBeVisible();
});
@ -62,7 +59,7 @@ describe('Settings screen', () => {
});
});
describe('Usage', async() => {
describe('Usage', () => {
it('should tap clear cache and navigate to roomslistview', async() => {
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
await element(by.id('settings-view-clear-cache')).tap();
@ -70,6 +67,6 @@ describe('Settings screen', () => {
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-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 { 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;
async function navigateToRoom() {
@ -26,7 +25,7 @@ describe('Join public room', () => {
await navigateToRoom();
});
describe('Render', async() => {
describe('Render', () => {
it('should have room screen', async() => {
await expect(element(by.id('room-view'))).toBeVisible();
});
@ -36,14 +35,14 @@ describe('Join public room', () => {
// });
// Render - Header
describe('Header', async() => {
describe('Header', () => {
it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toBeVisible();
});
});
// Render - Join
describe('Join', async() => {
describe('Join', () => {
it('should have join', async() => {
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() => {
await navigateToRoomActions();
});
@ -117,11 +116,11 @@ describe('Join public room', () => {
after(async() => {
await tapBack();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(2000);
})
});
});
});
describe('Usage', async() => {
describe('Usage', () => {
it('should join room', async() => {
await element(by.id('room-view-join-button')).tap();
await tapBack();

View File

@ -1,10 +1,8 @@
const {
expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, sleep } = require('../../helpers/app');
const data = require('../../data');
const testuser = data.users.regular
const testuser = data.users.regular;
async function waitForToast() {
await sleep(300);
@ -24,7 +22,7 @@ describe('Status screen', () => {
await waitFor(element(by.id('status-view'))).toBeVisible().withTimeout(2000);
});
describe('Render', async () => {
describe('Render', () => {
it('should have status input', async() => {
await expect(element(by.id('status-view-input'))).toBeVisible();
await expect(element(by.id('status-view-online'))).toExist();
@ -34,7 +32,7 @@ describe('Status screen', () => {
});
});
describe('Usage', async () => {
describe('Usage', () => {
it('should change status', async() => {
await element(by.id('status-view-busy')).tap();
await waitFor(element(by.id('status-view-current-busy'))).toExist().withTimeout(2000);

View File

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

View File

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

View File

@ -1,10 +1,9 @@
const {
device, expect, element, by, waitFor
} = require('detox');
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) {
await element(by.id('directory-view-search')).replaceText(search);
@ -22,15 +21,15 @@ describe('Join room from directory', () => {
await login(testuser.username, testuser.password);
});
describe('Usage', async() => {
describe('Usage', () => {
it('should tap directory', async() => {
await element(by.id('rooms-list-view-directory')).tap();
await waitFor(element(by.id('directory-view'))).toExist().withTimeout(2000);
})
});
it('should search public channel and navigate', async() => {
await navigateToRoom(data.channels.detoxpublic.name);
})
});
it('should search user and navigate', async() => {
await tapBack();
@ -40,7 +39,7 @@ describe('Join room from directory', () => {
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();
@ -50,6 +49,6 @@ describe('Join room from directory', () => {
await element(by.label('Teams')).tap();
await element(by.label('Search by')).tap();
await navigateToRoom(data.teams.private.name);
})
});
});
});

View File

@ -1,8 +1,7 @@
const {
device, element, by, waitFor
} = require('detox');
const data = require('../../data');
const { sleep, navigateToLogin, login, checkServer } = require('../../helpers/app');
const {
sleep, navigateToLogin, login, checkServer
} = require('../../helpers/app');
describe('Delete server', () => {
before(async() => {
@ -13,7 +12,7 @@ describe('Delete server', () => {
it('should be logged in main server', async() => {
await checkServer(data.server);
})
});
it('should add server', async() => {
await sleep(5000);

View File

@ -1,9 +1,6 @@
const {
device, element, by, waitFor
} = require('detox');
const data = require('../../data');
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 getDeepLink = (method, server, params) => {
@ -43,7 +40,7 @@ describe('Deep linking', () => {
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await checkServer(data.server);
await waitFor(element(by.id(`rooms-list-view-item-${ data.groups.private.name }`))).toBeVisible().withTimeout(2000);
}
};
it('should authenticate and navigate', async() => {
await authAndNavigate();
@ -63,7 +60,7 @@ describe('Deep linking', () => {
});
describe('Room', () => {
describe('While logged in', async() => {
describe('While logged in', () => {
it('should navigate to the room using path', async() => {
await device.launchApp({
permissions: { notifications: 'YES' },
@ -75,7 +72,7 @@ describe('Deep linking', () => {
});
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({
permissions: { notifications: 'YES' },
newInstance: true,
@ -87,7 +84,7 @@ describe('Deep linking', () => {
});
});
describe('Others', async() => {
describe('Others', () => {
it('should change server', async() => {
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
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 { post } = require('../../helpers/data_setup');
const data = require('../../data');
const testuser = data.users.regular
const testuser = data.users.regular;
const defaultLaunchArgs = { permissions: { notifications: 'YES' } };
const navToLanguage = async() => {
@ -25,8 +23,8 @@ describe('i18n', () => {
await device.launchApp({
...defaultLaunchArgs,
languageAndLocale: {
language: "en",
locale: "en"
language: 'en',
locale: 'en'
},
delete: true
});
@ -39,8 +37,8 @@ describe('i18n', () => {
await device.launchApp({
...defaultLaunchArgs,
languageAndLocale: {
language: "es-MX",
locale: "es-MX"
language: 'es-MX',
locale: 'es-MX'
}
});
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
@ -110,5 +108,5 @@ describe('i18n', () => {
await expect(element(by.id('sidebar-settings').withDescendant(by.label('Settings')))).toBeVisible();
await post('users.setPreferences', { data: { language: 'en' } }); // Set back to english
});
})
});
});

View File

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

View File

@ -1,6 +1,3 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data');
describe('Onboarding', () => {

View File

@ -1,10 +1,6 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { navigateToRegister, navigateToLogin } = require('../../helpers/app');
describe('Legal screen', () => {
describe('From Login', () => {
before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
@ -18,7 +14,7 @@ describe('Legal screen', () => {
it('should navigate to legal from login', async() => {
await expect(element(by.id('login-view-more'))).toBeVisible();
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);
});
});

View File

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

View File

@ -1,7 +1,4 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { navigateToRegister, sleep } = require('../../helpers/app');
const { navigateToRegister } = require('../../helpers/app');
const data = require('../../data');
describe('Create user screen', () => {
@ -37,7 +34,6 @@ describe('Create user screen', () => {
});
describe('Usage', () => {
// 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() => {
// const invalidEmail = 'invalidemail';

View File

@ -1,7 +1,4 @@
const {
expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, tapBack, sleep } = require('../../helpers/app');
const { navigateToLogin, tapBack } = require('../../helpers/app');
const data = require('../../data');
describe('Login screen', () => {

View File

@ -1,15 +1,13 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { login, navigateToLogin, logout, tapBack, sleep, searchRoom } = require('../../helpers/app');
login, navigateToLogin, logout, tapBack, searchRoom
} = require('../../helpers/app');
const data = require('../../data');
describe('Rooms list screen', () => {
before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password)
await login(data.users.regular.username, data.users.regular.password);
});
describe('Render', () => {

View File

@ -1,7 +1,6 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const { login, navigateToLogin, logout, tapBack } = require('../../helpers/app');
login, navigateToLogin, logout, tapBack
} = require('../../helpers/app');
const data = require('../../data');
describe('Server history', () => {
@ -16,7 +15,7 @@ describe('Server history', () => {
await logout();
await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
})
});
it('should show servers history', async() => {
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 { tapBack, sleep, navigateToLogin, login, tryTapping } = require('../../helpers/app');
const {
tapBack, navigateToLogin, login, tryTapping
} = require('../../helpers/app');
describe('Create room screen', () => {
before(async() => {
@ -13,12 +10,12 @@ describe('Create room screen', () => {
await login(data.users.regular.username, data.users.regular.password);
});
describe('New Message', async() => {
describe('New Message', () => {
before(async() => {
await element(by.id('rooms-list-view-create-channel')).tap();
});
describe('Render', async() => {
describe('Render', () => {
it('should have new message screen', async() => {
await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);
});
@ -26,9 +23,9 @@ describe('Create room screen', () => {
it('should have search input', async() => {
await waitFor(element(by.id('new-message-view-search'))).toBeVisible().withTimeout(2000);
});
})
});
describe('Usage', async() => {
describe('Usage', () => {
it('should back to rooms list', async() => {
await waitFor(element(by.id('new-message-view-close'))).toBeVisible().withTimeout(5000);
await element(by.id('new-message-view-close')).tap();
@ -56,13 +53,13 @@ describe('Create room screen', () => {
await element(by.id('new-message-view-create-channel')).tap();
await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(5000);
});
})
});
});
describe('Select Users', async() => {
describe('Select Users', () => {
it('should search users', async() => {
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() => {
@ -80,24 +77,24 @@ describe('Create room screen', () => {
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);
});
})
});
describe('Create Channel', async() => {
describe('Render', async() => {
describe('Create Channel', () => {
describe('Render', () => {
it('should render all fields', async() => {
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-readonly'))).toBeVisible();
await expect(element(by.id('create-channel-broadcast'))).toBeVisible();
})
})
});
});
describe('Usage', async() => {
describe('Usage', () => {
it('should get invalid room', async() => {
await element(by.id('create-channel-name')).typeText('general');
await element(by.id('create-channel-submit')).tap();
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 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 element(by.text('OK')).tap();
});
@ -161,6 +158,6 @@ describe('Create room screen', () => {
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
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 { 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) {
await searchRoom(`${ roomName }`);
@ -20,14 +19,14 @@ describe('Room screen', () => {
await navigateToRoom(mainRoom);
});
describe('Render', async() => {
describe('Render', () => {
it('should have room screen', async() => {
await expect(element(by.id('room-view'))).toExist();
await waitFor(element(by.id(`room-view-title-${ mainRoom }`))).toExist().withTimeout(5000);
});
// Render - Header
describe('Header', async() => {
describe('Header', () => {
it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist();
});
@ -38,7 +37,7 @@ describe('Room screen', () => {
});
// Render - Messagebox
describe('Messagebox', async() => {
describe('Messagebox', () => {
it('should have messagebox', async() => {
await expect(element(by.id('messagebox'))).toExist();
});
@ -63,10 +62,10 @@ describe('Room screen', () => {
});
});
describe('Usage', async() => {
describe('Messagebox', async() => {
describe('Usage', () => {
describe('Messagebox', () => {
it('should send message', async() => {
await mockMessage('message')
await mockMessage('message');
await expect(element(by.label(`${ data.random }message`)).atIndex(0)).toExist();
});
@ -111,14 +110,14 @@ describe('Room screen', () => {
});
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')).typeText(`@${ username }`);
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 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-send-message')).tap();
// 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() => {
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 element(by.id('messagebox-input')).clearText();
});
@ -136,7 +135,7 @@ describe('Room screen', () => {
await element(by.id('messagebox-input')).typeText('#general');
// await waitFor(element(by.id('messagebox-container'))).toExist().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 element(by.id('messagebox-input')).clearText();
});
@ -162,7 +161,7 @@ describe('Room screen', () => {
});
});
describe('Message', async() => {
describe('Message', () => {
it('should copy permalink', async() => {
await element(by.label(`${ data.random }message`)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
@ -184,9 +183,9 @@ describe('Room screen', () => {
});
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 expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
@ -229,8 +228,8 @@ describe('Room screen', () => {
});
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() => {
await element(by.id('message-reaction-:grinning:')).tap();
@ -263,8 +262,8 @@ describe('Room screen', () => {
});
it('should pin message', async() => {
await mockMessage('pin')
await pinMessage('pin')
await mockMessage('pin');
await pinMessage('pin');
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);
@ -277,7 +276,7 @@ describe('Room screen', () => {
});
it('should delete message', async() => {
await mockMessage('delete')
await mockMessage('delete');
await waitFor(element(by.label(`${ data.random }delete`)).atIndex(0)).toBeVisible();
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 { navigateToLogin, login, tapBack, sleep, searchRoom, mockMessage, starMessage, pinMessage } = require('../../helpers/app');
const { sendMessage } = require('../../helpers/data_setup')
const {
navigateToLogin, login, tapBack, sleep, searchRoom, mockMessage, starMessage, pinMessage
} = require('../../helpers/app');
const { sendMessage } = require('../../helpers/data_setup');
async function navigateToRoomActions(type) {
let room;
@ -36,15 +35,14 @@ async function waitForToast() {
}
describe('Room actions screen', () => {
before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
});
describe('Render', async() => {
describe('Direct', async() => {
describe('Render', () => {
describe('Direct', () => {
before(async() => {
await navigateToRoomActions('d');
});
@ -102,7 +100,7 @@ describe('Room actions screen', () => {
});
});
describe('Channel/Group', async() => {
describe('Channel/Group', () => {
before(async() => {
await navigateToRoomActions('c');
});
@ -165,7 +163,7 @@ describe('Room actions screen', () => {
});
});
describe('Usage', async() => {
describe('Usage', () => {
describe('TDB', async() => {
// TODO: test into a jitsi call
// 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() => {
await element(by.id('room-actions-mentioned')).tap();
await waitFor(element(by.id('mentioned-messages-view'))).toExist().withTimeout(2000);
@ -200,13 +198,12 @@ describe('Room actions screen', () => {
});
it('should show starred message and unstar it', async() => {
// Go back to room and send a message
await tapBack();
await mockMessage('messageToStar');
// Star the message
await starMessage('messageToStar')
await starMessage('messageToStar');
// Back into Room Actions
await element(by.id('room-header')).tap();
@ -228,13 +225,12 @@ describe('Room actions screen', () => {
});
it('should show pinned message and unpin it', async() => {
// Go back to room and send a message
await tapBack();
await mockMessage('messageToPin');
// Pin the message
await pinMessage('messageToPin')
await pinMessage('messageToPin');
// Back into Room Actions
await element(by.id('room-header')).tap();
@ -273,7 +269,7 @@ describe('Room actions screen', () => {
// });
});
describe('Notification', async() => {
describe('Notification', () => {
it('should navigate to notification preference view', async() => {
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
await waitFor(element(by.id('room-actions-notifications'))).toExist().withTimeout(2000);
@ -318,13 +314,13 @@ describe('Room actions screen', () => {
after(async() => {
await backToActions();
});
})
});
describe('Channel/Group', async() => {
describe('Channel/Group', () => {
// Currently, there's no way to add more owners to the room
// 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() => {
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
@ -363,12 +359,24 @@ describe('Room actions screen', () => {
await backToActions();
});
describe('Room Members', async() => {
describe('Room Members', () => {
before(async() => {
await element(by.id('room-actions-members')).tap();
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() => {
await element(by.id('room-members-view-toggle-status')).tap();
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);
});
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() => {
await openActionSheet(user.username);
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);
});
});
})
});
describe('Direct', async() => {
describe('Direct', () => {
before(async() => {
await navigateToRoomActions('d');
});

View File

@ -1,7 +1,6 @@
const {
expect, element, by, waitFor
} = require('detox');
const { navigateToLogin, login, mockMessage, tapBack, searchRoom } = require('../../helpers/app');
navigateToLogin, login, mockMessage, tapBack, searchRoom
} = require('../../helpers/app');
const data = require('../../data');
const channel = data.groups.private.name;
@ -10,13 +9,13 @@ const navigateToRoom = async() => {
await searchRoom(channel);
await element(by.id(`rooms-list-view-item-${ channel }`)).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
}
};
describe('Discussion', () => {
before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
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() => {
@ -31,7 +30,7 @@ describe('Discussion', () => {
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-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 waitFor(element(by.id('room-view'))).toExist().withTimeout(10000);
await waitFor(element(by.id(`room-view-title-${ discussionName }`))).toExist().withTimeout(5000);
@ -47,13 +46,13 @@ describe('Discussion', () => {
await element(by.label('Create Discussion')).atIndex(0).tap();
await waitFor(element(by.id('create-discussion-view'))).toExist().withTimeout(2000);
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 waitFor(element(by.id('room-view'))).toExist().withTimeout(10000);
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() => {
await waitFor(element(by.id('messagebox'))).toBeVisible().withTimeout(60000);
await mockMessage('message');
@ -63,7 +62,7 @@ describe('Discussion', () => {
const discussionName = `${ data.random }message`;
await element(by.label(discussionName)).atIndex(0).longPress();
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 element(by.id('create-discussion-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(10000);
@ -71,7 +70,7 @@ describe('Discussion', () => {
});
});
describe('Check RoomActionsView render', async() => {
describe('Check RoomActionsView render', () => {
it('should navigete to RoomActionsView', async() => {
await waitFor(element(by.id('room-header'))).toBeVisible().withTimeout(5000);
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 { 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) {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
@ -20,14 +19,14 @@ describe('Threads', () => {
await navigateToRoom(mainRoom);
});
describe('Render', async() => {
describe('Render', () => {
it('should have room screen', async() => {
await expect(element(by.id('room-view'))).toExist();
await waitFor(element(by.id(`room-view-title-${ mainRoom }`))).toExist().withTimeout(5000);
});
// Render - Header
describe('Header', async() => {
describe('Header', () => {
it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist();
});
@ -38,7 +37,7 @@ describe('Threads', () => {
});
// Render - Messagebox
describe('Messagebox', async() => {
describe('Messagebox', () => {
it('should have messagebox', async() => {
await expect(element(by.id('messagebox'))).toExist();
});
@ -63,8 +62,8 @@ describe('Threads', () => {
});
});
describe('Usage', async() => {
describe('Thread', async() => {
describe('Usage', () => {
describe('Thread', () => {
const thread = `${ data.random }thread`;
it('should create thread', async() => {
await mockMessage('thread');
@ -106,7 +105,7 @@ describe('Threads', () => {
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(`${ 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);
});
@ -119,14 +118,14 @@ describe('Threads', () => {
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(`${ 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);
});
it('should navigate to thread from thread name', async() => {
const messageText = 'navthreadname';
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('messagebox-input-thread')).typeText(messageText);
await element(by.id('messagebox-send-to-channel')).tap();

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data');
const { tapBack, sleep, navigateToLogin, login, tryTapping } = require('../../helpers/app');
const {
navigateToLogin, login
} = require('../../helpers/app');
@ -13,12 +12,12 @@ describe('Group DM', () => {
await login(data.users.regular.username, data.users.regular.password);
});
describe('Create Group DM', async() => {
describe('Create Group DM', () => {
before(async() => {
await element(by.id('rooms-list-view-create-channel')).tap();
});
describe('Render', async() => {
describe('Render', () => {
it('should have new message screen', async() => {
await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);
});
@ -26,16 +25,16 @@ describe('Group DM', () => {
it('should have search input', async() => {
await waitFor(element(by.id('new-message-view-search'))).toBeVisible().withTimeout(2000);
});
})
});
describe('Usage', async() => {
describe('Usage', () => {
it('should navigate to create DM', async() => {
await element(by.label('Create Direct Messages')).tap();
});
it('should add users', async() => {
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-search')).replaceText(data.users.existing.username);
await waitFor(element(by.id(`select-users-view-item-${ data.users.existing.username }`))).toBeVisible().withTimeout(10000);
@ -46,8 +45,6 @@ describe('Group DM', () => {
it('check Group DM exist', async() => {
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 { navigateToLogin, login, searchRoom, sleep } = require('../../helpers/app');
const { sendMessage } = require('../../helpers/data_setup')
const {
navigateToLogin, login, searchRoom, sleep
} = require('../../helpers/app');
const { sendMessage } = require('../../helpers/data_setup');
async function navigateToRoom(user) {
await searchRoom(`${ user }`);
@ -12,7 +11,7 @@ async function navigateToRoom(user) {
}
describe('Mark as unread', () => {
const user = data.users.alternate.username
const user = data.users.alternate.username;
before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
@ -21,9 +20,8 @@ describe('Mark as unread', () => {
await navigateToRoom(user);
});
// TODO: Fix flakiness. If it fails, run it solo.
describe('Usage', async() => {
describe('Mark message as unread', async() => {
describe('Usage', () => {
describe('Mark message as unread', () => {
it('should mark message as unread', async() => {
const message = `${ data.random }message-mark-as-unread`;
const channelName = `@${ data.users.regular.username }`;

View File

@ -1,10 +1,9 @@
const {
device, expect, element, by, waitFor
} = require('detox');
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) {
let room;
@ -31,14 +30,13 @@ async function waitForToast() {
}
describe('Room info screen', () => {
before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
});
describe('Direct', async() => {
describe('Direct', () => {
before(async() => {
await navigateToRoomInfo('d');
});
@ -49,18 +47,18 @@ describe('Room info screen', () => {
});
after(async() => {
await tapBack()
await tapBack()
await tapBack()
})
await tapBack();
await tapBack();
await tapBack();
});
});
describe('Channel/Group', async() => {
describe('Channel/Group', () => {
before(async() => {
await navigateToRoomInfo('c');
});
describe('Render', async() => {
describe('Render', () => {
it('should have room info view', async() => {
await expect(element(by.id('room-info-view'))).toExist();
});
@ -86,7 +84,7 @@ describe('Room info screen', () => {
});
});
describe('Render Edit', async() => {
describe('Render Edit', () => {
before(async() => {
await waitFor(element(by.id('room-info-view-edit-button'))).toExist().withTimeout(10000);
await element(by.id('room-info-view-edit-button')).tap();
@ -149,7 +147,7 @@ describe('Room info screen', () => {
});
});
describe('Usage', async() => {
describe('Usage', () => {
// it('should enter "invalid name" and get error', async() => {
// await element(by.type('UIScrollView')).atIndex(1).swipe('down');
// await element(by.id('room-info-edit-view-name')).replaceText('invalid name');

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
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) {
await searchRoom(`${ roomName }`);
@ -22,7 +21,7 @@ async function clearCache() {
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 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() {
@ -51,7 +50,7 @@ describe('Room', () => {
await element(by.id('nav-jump-to-bottom')).tap();
await waitFor(element(by.label('Quote first message'))).toExist().withTimeout(5000);
await clearCache();
})
});
it('should load messages on scroll', async() => {
await navigateToRoom('jumping');
@ -64,6 +63,7 @@ describe('Room', () => {
await expect(element(by.label('249'))).toExist();
found = true;
} catch {
//
}
}
await clearCache();
@ -80,7 +80,7 @@ describe('Room', () => {
await expect(element(by.label('30'))).toExist();
await expect(element(by.label('31'))).toExist();
await expect(element(by.label('32'))).toExist();
})
});
it('should load newer and older messages', async() => {
await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.8);
@ -114,9 +114,9 @@ describe('Room', () => {
const expectThreadMessages = async(message) => {
await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);
await expect(element(by.label(message))).toExist();
}
};
describe('Threads', async() => {
describe('Threads', () => {
it('should navigate to a thread from another room', async() => {
await navigateToRoom('jumping');
await waitFor(element(by.label('Go to jumping-thread\'s thread')).atIndex(0)).toExist().withTimeout(5000);

View File

@ -1,6 +1,3 @@
const {
device, expect, element, by, waitFor
} = require('detox');
const data = require('../../data');
const { navigateToLogin, login } = require('../../helpers/app');
@ -13,7 +10,7 @@ describe('Create team screen', () => {
await login(data.users.regular.username, data.users.regular.password);
});
describe('New Message', async() => {
describe('New Message', () => {
before(async() => {
await element(by.id('rooms-list-view-create-channel')).tap();
});
@ -28,15 +25,15 @@ describe('Create team screen', () => {
});
});
describe('Select Users', async() => {
describe('Select Users', () => {
it('should nav to create team', async() => {
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);
});
})
});
describe('Create Team', async() => {
describe('Usage', async() => {
describe('Create Team', () => {
describe('Usage', () => {
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-submit')).tap();
@ -52,10 +49,10 @@ describe('Create team screen', () => {
await waitFor(element(by.id(`room-view-title-${ teamName }`))).toExist().withTimeout(6000);
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() => {
await element(by.id('room-header')).tap();
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 { navigateToLogin, login, tapBack, sleep, searchRoom } = require('../../helpers/app');
const {
navigateToLogin, login, tapBack, sleep, searchRoom
} = require('../../helpers/app');
async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`);
@ -49,8 +48,8 @@ describe('Team', () => {
await navigateToRoom(team);
});
describe('Team Room', async() => {
describe('Team Header', async() => {
describe('Team Room', () => {
describe('Team Header', () => {
it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist();
});
@ -69,14 +68,14 @@ describe('Team', () => {
});
});
describe('Team Header Usage', async() => {
describe('Team Header Usage', () => {
it('should navigate to team channels view', async() => {
await element(by.id('room-view-header-team-channels')).tap();
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() => {
await expect(element(by.id('room-header'))).toExist();
});
@ -90,7 +89,7 @@ describe('Team', () => {
});
});
describe('Team Channels Header Usage', async() => {
describe('Team Channels Header Usage', () => {
it('should navigate to add team channels view', async() => {
await element(by.id('team-channels-view-create')).tap();
await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);
@ -103,11 +102,10 @@ describe('Team', () => {
it('should add existing button', async() => {
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() => {
await element(by.id('add-channel-team-view-create-channel')).tap();
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() => {
await element(by.id('team-channels-view-create')).tap();
await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);
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 element(by.id(`add-existing-channel-view-item-${ existingRoom }`)).tap();
await waitFor(element(by.id('add-existing-channel-view-submit'))).toExist().withTimeout(6000);
@ -174,7 +171,7 @@ describe('Team', () => {
await waitFor(element(by.id('auto-join-tag'))).toBeNotVisible().withTimeout(5000);
await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(6000);
});
})
});
describe('Team actions', () => {
before(async() => {
@ -228,7 +225,7 @@ describe('Team', () => {
await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000);
});
describe('Room Members', async() => {
describe('Room Members', () => {
before(async() => {
await element(by.id('room-actions-members')).tap();
await waitFor(element(by.id('room-members-view'))).toExist().withTimeout(2000);

View File

@ -1,8 +1,7 @@
const {
device, expect, element, by, waitFor
} = require('detox');
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 toBeMoved = `to-be-moved-${ data.random }`;
@ -21,7 +20,7 @@ const createChannel = async(room) => {
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(60000);
}
};
async function navigateToRoom(room) {
await searchRoom(`${ room }`);
@ -42,7 +41,7 @@ describe('Move/Convert Team', () => {
await login(data.users.regular.username, data.users.regular.password);
});
describe('Convert', async() => {
describe('Convert', () => {
before(async() => {
await createChannel(toBeConverted);
});
@ -61,10 +60,10 @@ describe('Move/Convert Team', () => {
after(async() => {
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
})
});
});
describe('Move', async() => {
describe('Move', () => {
before(async() => {
await createChannel(toBeMoved);
});
@ -85,5 +84,5 @@ describe('Move/Convert Team', () => {
await element(by.text('Yes, move it!')).tap();
await waitFor(element(by.id('room-view-header-team-channels'))).toExist().withTimeout(10000);
});
})
});
});