til createdmgroup

This commit is contained in:
Diego Mello 2023-02-22 16:38:30 -03:00
parent 8d9644c8ac
commit ae0c55ac21
5 changed files with 191 additions and 292 deletions

View File

@ -1,19 +1,19 @@
import { expect } from 'detox';
import data from '../../data';
import {
navigateToLogin,
login,
mockMessage,
tapBack,
sleep,
searchRoom,
dismissReviewNag,
tryTapping,
platformTypes,
TTextMatcher
TTextMatcher,
mockRandomMessage
} from '../../helpers/app';
import { sendMessage } from '../../helpers/data_setup';
import { createRandomRoom, createRandomUser, ITestUser, sendMessage } from '../../helpers/data_setup';
import random from '../../helpers/random';
async function navigateToRoom(roomName: string) {
await searchRoom(`${roomName}`);
@ -24,22 +24,26 @@ async function navigateToRoom(roomName: string) {
}
describe('Room screen', () => {
const mainRoom = data.groups.private.name;
let room: string;
let alertButtonType: string;
let textMatcher: TTextMatcher;
let user: ITestUser;
let randomMessage: string;
beforeAll(async () => {
user = await createRandomUser();
({ name: room } = await createRandomRoom(user));
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
await navigateToRoom(mainRoom);
await login(user.username, user.password);
await navigateToRoom(room);
});
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}`)))
await waitFor(element(by.id(`room-view-title-${room}`)))
.toExist()
.withTimeout(5000);
});
@ -82,8 +86,7 @@ describe('Room screen', () => {
describe('Usage', () => {
describe('Messagebox', () => {
it('should send message', async () => {
await mockMessage('message');
await expect(element(by[textMatcher](`${data.random}message`)).atIndex(0)).toExist();
randomMessage = await mockRandomMessage('message');
});
// describe('Emoji Keyboard', () => {
@ -227,9 +230,9 @@ describe('Room screen', () => {
});
it('should show and tap on user autocomplete and send mention', async () => {
const { username } = data.users.regular;
const { username } = user;
const messageMention = `@${username}`;
const message = `${data.random}mention`;
const message = `${random()}mention`;
const fullMessage = `${messageMention} ${message}`;
await element(by.id('messagebox-input')).typeText(`@${username}`);
await sleep(300);
@ -241,7 +244,6 @@ describe('Room screen', () => {
.withTimeout(4000);
await tryTapping(element(by.id(`mention-item-${username}`)), 2000);
await expect(element(by.id('messagebox-input'))).toHaveText(`${messageMention} `);
// await tryTapping(element(by.id('messagebox-input')), 2000);
if (device.getPlatform() === 'ios') {
await element(by.id('messagebox-input')).typeText(message);
await element(by.id('messagebox-send-message')).tap();
@ -284,24 +286,23 @@ describe('Room screen', () => {
await element(by.id('messagebox-input')).clearText();
});
it('should draft message', async () => {
await element(by.id('messagebox-input')).typeText(`${data.random}draft`);
const draftMessage = `${random()}draft`;
await element(by.id('messagebox-input')).typeText(draftMessage);
await tapBack();
await navigateToRoom(mainRoom);
await expect(element(by.id('messagebox-input'))).toHaveText(`${data.random}draft`);
await navigateToRoom(room);
await expect(element(by.id('messagebox-input'))).toHaveText(draftMessage);
await element(by.id('messagebox-input')).clearText();
await tapBack();
await navigateToRoom(mainRoom);
await navigateToRoom(room);
await expect(element(by.id('messagebox-input'))).toHaveText('');
});
});
describe('Message', () => {
it('should copy link', async () => {
await element(by[textMatcher](`${data.random}message`))
.atIndex(0)
.longPress();
await element(by[textMatcher](randomMessage)).atIndex(0).longPress();
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -311,9 +312,7 @@ describe('Room screen', () => {
// TODO: test clipboard
});
it('should copy message', async () => {
await element(by[textMatcher](`${data.random}message`))
.atIndex(0)
.longPress();
await element(by[textMatcher](randomMessage)).atIndex(0).longPress();
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -324,25 +323,21 @@ describe('Room screen', () => {
});
it('should react to message', async () => {
await waitFor(element(by[textMatcher](`${data.random}message`)))
await waitFor(element(by[textMatcher](randomMessage)))
.toExist()
.withTimeout(60000);
await element(by[textMatcher](`${data.random}message`))
.atIndex(0)
.tap();
await element(by[textMatcher](`${data.random}message`))
.atIndex(0)
.longPress();
await element(by[textMatcher](randomMessage)).atIndex(0).tap();
await element(by[textMatcher](randomMessage)).atIndex(0).longPress();
await sleep(300); // wait for animation
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.id('add-reaction')).tap();
await sleep(300); // wait for animation
await waitFor(element(by.id('emoji-picker-tab-emoji')))
.toExist()
.withTimeout(2000);
// await element(by.id('action-sheet-handle')).swipe('up', 'fast', 1);
await element(by.id('emoji-picker-tab-emoji')).tap();
await waitFor(element(by.id('emoji-grinning')))
.toExist()
@ -354,9 +349,7 @@ describe('Room screen', () => {
});
it('should search emojis in the reaction picker and react', async () => {
await element(by[textMatcher](`${data.random}message`))
.atIndex(0)
.longPress();
await element(by[textMatcher](randomMessage)).atIndex(0).longPress();
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -377,9 +370,7 @@ describe('Room screen', () => {
});
it('should react to message with frequently used emoji', async () => {
await element(by[textMatcher](`${data.random}message`))
.atIndex(0)
.longPress();
await element(by[textMatcher](randomMessage)).atIndex(0).longPress();
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -438,30 +429,32 @@ describe('Room screen', () => {
});
it('should edit message', async () => {
await mockMessage('edit');
await tryTapping(element(by[textMatcher](`${data.random}edit`)).atIndex(0), 2000, true);
const editMessage = await mockRandomMessage('edit');
const editedMessage = `${editMessage}ed`;
await tryTapping(element(by[textMatcher](editMessage)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by[textMatcher]('Edit')).atIndex(0).tap();
await element(by.id('messagebox-input')).replaceText(`${data.random}edited`);
await element(by.id('messagebox-input')).replaceText(editedMessage);
await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by[textMatcher](`${data.random}edited`)).atIndex(0))
await waitFor(element(by[textMatcher](editedMessage)).atIndex(0))
.toExist()
.withTimeout(60000);
});
it('should quote message', async () => {
await mockMessage('quote');
await tryTapping(element(by[textMatcher](`${data.random}quote`)).atIndex(0), 2000, true);
const quoteMessage = await mockRandomMessage('quote');
const quotedMessage = `${quoteMessage}d`;
await tryTapping(element(by[textMatcher](quoteMessage)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by[textMatcher]('Quote')).atIndex(0).tap();
await element(by.id('messagebox-input')).replaceText(`${data.random}quoted`);
await element(by.id('messagebox-input')).replaceText(quotedMessage);
await waitFor(element(by.id('messagebox-send-message')))
.toExist()
.withTimeout(2000);
@ -470,8 +463,8 @@ describe('Room screen', () => {
});
it('should delete message', async () => {
await mockMessage('delete');
await tryTapping(element(by[textMatcher](`${data.random}delete`)).atIndex(0), 2000, true);
const deleteMessage = await mockRandomMessage('delete');
await tryTapping(element(by[textMatcher](deleteMessage)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -486,40 +479,51 @@ describe('Room screen', () => {
.toExist()
.withTimeout(10000);
await element(by[textMatcher]('Delete').and(by.type(alertButtonType))).tap();
await waitFor(element(by[textMatcher](`${data.random}delete`)).atIndex(0))
await waitFor(element(by[textMatcher](deleteMessage)).atIndex(0))
.not.toExist()
.withTimeout(2000);
await tapBack();
});
it('should reply in DM to another user', async () => {
const channelName = data.userRegularChannels.detoxpublic.name;
const stringToReply = 'Message to reply in DM';
const replyUser = await createRandomUser();
const { name: replyRoom } = await createRandomRoom(replyUser, 'c');
const originalMessage = 'Message to reply in DM';
const replyMessage = `${random()} replied in dm`;
await waitFor(element(by.id('rooms-list-view')))
.toBeVisible()
.withTimeout(2000);
await navigateToRoom(channelName);
await sendMessage(data.users.alternate, channelName, stringToReply);
await waitFor(element(by[textMatcher](stringToReply)).atIndex(0))
await navigateToRoom(replyRoom);
await sendMessage(replyUser, replyRoom, originalMessage);
await waitFor(element(by[textMatcher](originalMessage)).atIndex(0))
.toBeVisible()
.withTimeout(3000);
await element(by[textMatcher](stringToReply)).atIndex(0).longPress();
.withTimeout(10000);
await element(by.id('room-view-join-button')).tap();
await waitFor(element(by.id('room-view-join-button')))
.not.toBeVisible()
.withTimeout(10000);
await element(by[textMatcher](originalMessage)).atIndex(0).tap();
await element(by[textMatcher](originalMessage)).atIndex(0).longPress();
await sleep(300); // wait for animation
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await waitFor(element(by[textMatcher]('Reply in Direct Message')).atIndex(0))
.toExist()
.withTimeout(6000);
await element(by[textMatcher]('Reply in Direct Message')).atIndex(0).tap();
await waitFor(element(by.id(`room-view-title-${data.users.alternate.username}`)))
await waitFor(element(by.id(`room-view-title-${replyUser.username}`)))
.toExist()
.withTimeout(6000);
await element(by.id('messagebox-input')).replaceText(`${data.random} replied in dm`);
await element(by.id('messagebox-input')).replaceText(replyMessage);
await waitFor(element(by.id('messagebox-send-message')))
.toExist()
.withTimeout(2000);
await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by[textMatcher](replyMessage)))
.toExist()
.withTimeout(60000);
await element(by[textMatcher](replyMessage)).atIndex(0).tap();
});
});
});

View File

@ -1,27 +1,28 @@
import { expect } from 'detox';
import data from '../../data';
// import data from '../../data';
import {
navigateToLogin,
login,
tapBack,
sleep,
searchRoom,
mockMessage,
platformTypes,
TTextMatcher,
tapAndWaitFor,
tryTapping
tryTapping,
mockRandomMessage
} from '../../helpers/app';
import { createRandomRoom, createRandomUser, ITestUser, post } from '../../helpers/data_setup';
import random from '../../helpers/random';
const { sendMessage } = require('../../helpers/data_setup');
async function starMessage(message: string) {
const deviceType = device.getPlatform();
const { textMatcher } = platformTypes[deviceType];
const messageLabel = `${data.random}${message}`;
await waitFor(element(by[textMatcher](messageLabel)).atIndex(0)).toExist();
await tryTapping(element(by[textMatcher](messageLabel)).atIndex(0), 2000, true);
await waitFor(element(by[textMatcher](message)).atIndex(0)).toExist();
await tryTapping(element(by[textMatcher](message)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -35,9 +36,8 @@ async function starMessage(message: string) {
async function pinMessage(message: string) {
const deviceType = device.getPlatform();
const { textMatcher } = platformTypes[deviceType];
const messageLabel = `${data.random}${message}`;
await waitFor(element(by[textMatcher](messageLabel)).atIndex(0)).toExist();
await tryTapping(element(by[textMatcher](messageLabel)).atIndex(0), 2000, true);
await waitFor(element(by[textMatcher](message)).atIndex(0)).toExist();
await tryTapping(element(by[textMatcher](message)).atIndex(0), 2000, true);
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -48,13 +48,7 @@ async function pinMessage(message: string) {
.withTimeout(5000);
}
async function navigateToRoomActions(type: string) {
let room;
if (type === 'd') {
room = 'rocket.cat';
} else {
room = data.groups.private.name;
}
async function navigateToRoomActions() {
await searchRoom(room);
await element(by.id(`rooms-list-view-item-${room}`)).tap();
await waitFor(element(by.id('room-view')))
@ -73,93 +67,31 @@ async function backToActions() {
.withTimeout(2000);
}
async function backToRoomsList() {
await tapBack();
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(2000);
await tapBack();
await waitFor(element(by.id('rooms-list-view')))
.toExist()
.withTimeout(2000);
}
async function waitForToast() {
await sleep(1000);
}
let user: ITestUser;
let otherUser: ITestUser;
let room: string;
describe('Room actions screen', () => {
let alertButtonType: string;
let textMatcher: TTextMatcher;
beforeAll(async () => {
user = await createRandomUser();
otherUser = await createRandomUser();
({ name: room } = await createRandomRoom(user));
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
await login(user.username, user.password);
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
});
describe('Render', () => {
describe('Direct', () => {
beforeAll(async () => {
await navigateToRoomActions('d');
});
it('should have room actions screen', async () => {
await expect(element(by.id('room-actions-view'))).toExist();
});
it('should have info', async () => {
await expect(element(by.id('room-actions-info'))).toExist();
});
// it('should have voice', async() => {
// await expect(element(by.id('room-actions-voice'))).toExist();
// });
// it('should have video', async() => {
// await expect(element(by.id('room-actions-video'))).toExist();
// });
it('should have files', async () => {
await expect(element(by.id('room-actions-files'))).toExist();
});
it('should have mentions', async () => {
await expect(element(by.id('room-actions-mentioned'))).toExist();
});
it('should have starred', async () => {
await expect(element(by.id('room-actions-starred'))).toExist();
});
it('should have share', async () => {
await waitFor(element(by.id('room-actions-share'))).toExist();
await expect(element(by.id('room-actions-share'))).toExist();
});
it('should have pinned', async () => {
await waitFor(element(by.id('room-actions-pinned'))).toExist();
await expect(element(by.id('room-actions-pinned'))).toExist();
});
it('should have notifications', async () => {
await waitFor(element(by.id('room-actions-notifications'))).toExist();
await expect(element(by.id('room-actions-notifications'))).toExist();
});
it('should have block user', async () => {
await waitFor(element(by.id('room-actions-block-user'))).toExist();
await expect(element(by.id('room-actions-block-user'))).toExist();
});
afterAll(async () => {
await backToRoomsList();
});
});
describe('Channel/Group', () => {
beforeAll(async () => {
await navigateToRoomActions('c');
await navigateToRoomActions();
});
it('should have room actions screen', async () => {
@ -170,14 +102,6 @@ describe('Room actions screen', () => {
await expect(element(by.id('room-actions-info'))).toExist();
});
// it('should have voice', async() => {
// await expect(element(by.id('room-actions-voice'))).toExist();
// });
// it('should have video', async() => {
// await expect(element(by.id('room-actions-video'))).toExist();
// });
it('should have members', async () => {
await expect(element(by.id('room-actions-members'))).toExist();
});
@ -229,10 +153,10 @@ 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');
const messageToStar = await mockRandomMessage('messageToStar');
// Star the message
await starMessage('messageToStar');
await starMessage(messageToStar);
// Back into Room Actions
await element(by.id('room-header')).tap();
@ -247,19 +171,17 @@ describe('Room actions screen', () => {
await waitFor(element(by.id('starred-messages-view')))
.toExist()
.withTimeout(2000);
await waitFor(element(by[textMatcher](`${data.random}messageToStar`).withAncestor(by.id('starred-messages-view'))))
await waitFor(element(by[textMatcher](messageToStar).withAncestor(by.id('starred-messages-view'))))
.toExist()
.withTimeout(60000);
// Unstar message
await element(by[textMatcher](`${data.random}messageToStar`))
.atIndex(0)
.longPress();
await element(by[textMatcher](messageToStar)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by[textMatcher]('Unstar')).atIndex(0).tap();
await waitFor(element(by[textMatcher](`${data.random}messageToStar`).withAncestor(by.id('starred-messages-view'))))
await waitFor(element(by[textMatcher](messageToStar).withAncestor(by.id('starred-messages-view'))))
.toBeNotVisible()
.withTimeout(60000);
await backToActions();
@ -268,10 +190,10 @@ 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');
const messageToPin = await mockRandomMessage('messageToPin');
// Pin the message
await pinMessage('messageToPin');
await pinMessage(messageToPin);
// Back into Room Actions
await element(by.id('room-header')).tap();
@ -284,10 +206,10 @@ describe('Room actions screen', () => {
await waitFor(element(by.id('pinned-messages-view')))
.toExist()
.withTimeout(2000);
await waitFor(element(by[textMatcher](`${data.random}messageToPin`).withAncestor(by.id('pinned-messages-view'))))
await waitFor(element(by[textMatcher](messageToPin).withAncestor(by.id('pinned-messages-view'))))
.toExist()
.withTimeout(6000);
await element(by[textMatcher](`${data.random}messageToPin`).withAncestor(by.id('pinned-messages-view')))
await element(by[textMatcher](messageToPin).withAncestor(by.id('pinned-messages-view')))
.atIndex(0)
.longPress();
@ -295,7 +217,7 @@ describe('Room actions screen', () => {
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by[textMatcher]('Unpin')).atIndex(0).tap();
await waitFor(element(by[textMatcher](`${data.random}messageToPin`).withAncestor(by.id('pinned-messages-view'))))
await waitFor(element(by[textMatcher](messageToPin).withAncestor(by.id('pinned-messages-view'))))
.not.toExist()
.withTimeout(6000);
await backToActions();
@ -353,11 +275,6 @@ describe('Room actions screen', () => {
});
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;
it('should tap on leave channel and raise alert', async () => {
await waitFor(element(by.id('room-actions-scrollview')))
.toExist()
@ -396,6 +313,7 @@ describe('Room actions screen', () => {
// add rocket.cat
const rocketCat = 'rocket.cat';
await post('im.create', { username: rocketCat }, user);
await waitFor(element(by.id(`select-users-view-item-${rocketCat}`)))
.toExist()
.withTimeout(10000);
@ -408,13 +326,13 @@ describe('Room actions screen', () => {
.toExist()
.withTimeout(4000);
await element(by.id('select-users-view-search')).tap();
await element(by.id('select-users-view-search')).replaceText(user.username);
await element(by.id('select-users-view-search')).replaceText(otherUser.username);
await sleep(300);
await waitFor(element(by.id(`select-users-view-item-${user.username}`)))
await waitFor(element(by.id(`select-users-view-item-${otherUser.username}`)))
.toExist()
.withTimeout(10000);
await element(by.id(`select-users-view-item-${user.username}`)).tap();
await waitFor(element(by.id(`selected-user-${user.username}`)))
await element(by.id(`select-users-view-item-${otherUser.username}`)).tap();
await waitFor(element(by.id(`selected-user-${otherUser.username}`)))
.toExist()
.withTimeout(5000);
@ -470,7 +388,7 @@ describe('Room actions screen', () => {
.toExist()
.withTimeout(2000);
await element(by.id('room-members-view-toggle-status-all')).tap();
await waitFor(element(by.id(`room-members-view-item-${user.username}`)))
await waitFor(element(by.id(`room-members-view-item-${otherUser.username}`)))
.toExist()
.withTimeout(60000);
await tapBack();
@ -486,16 +404,16 @@ describe('Room actions screen', () => {
.toExist()
.withTimeout(2000);
await element(by.id('room-members-view-toggle-status-all')).tap();
await waitFor(element(by.id(`room-members-view-item-${user.username}`)))
await waitFor(element(by.id(`room-members-view-item-${otherUser.username}`)))
.toExist()
.withTimeout(60000);
await element(by.id('room-members-view-search')).replaceText('rocket');
await waitFor(element(by.id(`room-members-view-item-${user.username}`)))
await waitFor(element(by.id(`room-members-view-item-${otherUser.username}`)))
.toBeNotVisible()
.withTimeout(60000);
await element(by.id('room-members-view-search')).tap();
await element(by.id('room-members-view-search')).clearText();
await waitFor(element(by.id(`room-members-view-item-${user.username}`)))
await waitFor(element(by.id(`room-members-view-item-${otherUser.username}`)))
.toExist()
.withTimeout(60000);
});
@ -518,24 +436,24 @@ describe('Room actions screen', () => {
it('should clear search', async () => {
await element(by.id('room-members-view-search')).tap();
await element(by.id('room-members-view-search')).clearText();
await waitFor(element(by.id(`room-members-view-item-${user.username}`)))
await waitFor(element(by.id(`room-members-view-item-${otherUser.username}`)))
.toExist()
.withTimeout(60000);
});
it('should set/remove as owner', async () => {
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await element(by.id('action-sheet-set-owner')).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await waitFor(element(by.id('action-sheet-set-owner-checked')))
.toBeVisible()
.withTimeout(6000);
await element(by.id('action-sheet-set-owner')).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await waitFor(element(by.id('action-sheet-set-owner-unchecked')))
.toBeVisible()
.withTimeout(60000);
@ -543,18 +461,18 @@ describe('Room actions screen', () => {
});
it('should set/remove as leader', async () => {
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await element(by.id('action-sheet-set-leader')).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await waitFor(element(by.id('action-sheet-set-leader-checked')))
.toBeVisible()
.withTimeout(6000);
await element(by.id('action-sheet-set-leader')).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await waitFor(element(by.id('action-sheet-set-owner-unchecked')))
.toBeVisible()
.withTimeout(60000);
@ -562,18 +480,18 @@ describe('Room actions screen', () => {
});
it('should set/remove as moderator', async () => {
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await element(by.id('action-sheet-set-moderator')).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await waitFor(element(by.id('action-sheet-set-moderator-checked')))
.toBeVisible()
.withTimeout(6000);
await element(by.id('action-sheet-set-moderator')).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await waitFor(element(by.id('action-sheet-set-moderator-unchecked')))
.toBeVisible()
.withTimeout(60000);
@ -581,7 +499,7 @@ describe('Room actions screen', () => {
});
it('should set/remove as mute', async () => {
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await element(by[textMatcher]('Mute')).atIndex(0).tap();
await waitFor(element(by[textMatcher]('Are you sure?')))
.toExist()
@ -589,7 +507,7 @@ describe('Room actions screen', () => {
await element(by[textMatcher]('Mute').and(by.type(alertButtonType))).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await element(by[textMatcher]('Unmute')).atIndex(0).tap();
await waitFor(element(by[textMatcher]('Are you sure?')))
.toExist()
@ -597,7 +515,7 @@ describe('Room actions screen', () => {
await element(by[textMatcher]('Unmute').and(by.type(alertButtonType))).tap();
await waitForToast();
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
// Tests if Remove as mute worked
await waitFor(element(by[textMatcher]('Mute')))
.toExist()
@ -606,10 +524,9 @@ describe('Room actions screen', () => {
});
it('should ignore user', async () => {
const message = `${data.random}ignoredmessagecontent`;
const channelName = `#${data.groups.private.name}`;
await sendMessage(user, channelName, message);
await openActionSheet(user.username);
const message = `${random()}ignoredmessagecontent`;
await sendMessage(otherUser, room, message);
await openActionSheet(otherUser.username);
await element(by[textMatcher]('Ignore')).atIndex(0).tap();
await waitForToast();
await backToActions();
@ -648,15 +565,15 @@ describe('Room actions screen', () => {
.toExist()
.withTimeout(2000);
await element(by.id('room-members-view-toggle-status-all')).tap();
await waitFor(element(by.id(`room-members-view-item-${user.username}`)))
await waitFor(element(by.id(`room-members-view-item-${otherUser.username}`)))
.toExist()
.withTimeout(60000);
await openActionSheet(user.username);
await openActionSheet(otherUser.username);
await element(by[textMatcher]('Direct message')).atIndex(0).tap();
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(60000);
await waitFor(element(by.id(`room-view-title-${user.username}`)))
await waitFor(element(by.id(`room-view-title-${otherUser.username}`)))
.toExist()
.withTimeout(60000);
await tapBack();
@ -666,24 +583,5 @@ describe('Room actions screen', () => {
});
});
});
describe('Direct', () => {
beforeAll(async () => {
await navigateToRoomActions('d');
});
it('should block/unblock user', async () => {
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
await waitFor(element(by.id('room-actions-block-user'))).toExist();
await element(by.id('room-actions-block-user')).tap();
await waitFor(element(by[textMatcher]('Unblock user')))
.toExist()
.withTimeout(60000);
await element(by.id('room-actions-block-user')).tap();
await waitFor(element(by[textMatcher]('Block user')))
.toExist()
.withTimeout(60000);
});
});
});
});

View File

@ -1,29 +1,34 @@
import { expect } from 'detox';
import { TTextMatcher, navigateToLogin, login, mockMessage, tapBack, searchRoom, platformTypes } from '../../helpers/app';
import data from '../../data';
const channel = data.groups.private.name;
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);
};
import {
TTextMatcher,
navigateToLogin,
login,
tapBack,
navigateToRoom,
platformTypes,
mockRandomMessage
} from '../../helpers/app';
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
describe('Discussion', () => {
let textMatcher: TTextMatcher;
let user: ITestUser;
let room: string;
const discussionFromNewMessage = `${random()} Discussion NewMessageView`;
const discussionFromMessagebox = `${random()} Discussion Messagebox actions`;
let discussionFromActionSheet: string;
beforeAll(async () => {
user = await createRandomUser();
({ name: room } = await createRandomRoom(user));
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
({ textMatcher } = platformTypes[device.getPlatform()]);
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
await login(user.username, user.password);
});
it('should create discussion from NewMessageView', async () => {
const discussionName = `${data.random} Discussion NewMessageView`;
await waitFor(element(by.id('rooms-list-view-create-channel')))
.toExist()
.withTimeout(2000);
@ -37,12 +42,12 @@ describe('Discussion', () => {
.withTimeout(60000);
await expect(element(by.id('create-discussion-view'))).toExist();
await element(by[textMatcher]('Select a Channel...')).tap();
await element(by.id('multi-select-search')).replaceText(`${channel}`);
await waitFor(element(by.id(`multi-select-item-${channel}`)))
await element(by.id('multi-select-search')).replaceText(`${room}`);
await waitFor(element(by.id(`multi-select-item-${room}`)))
.toExist()
.withTimeout(10000);
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-item-${room}`)).tap();
await element(by.id('multi-select-discussion-name')).replaceText(discussionFromNewMessage);
await waitFor(element(by.id('create-discussion-submit')))
.toExist()
.withTimeout(10000);
@ -50,18 +55,17 @@ describe('Discussion', () => {
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(10000);
await waitFor(element(by.id(`room-view-title-${discussionName}`)))
await waitFor(element(by.id(`room-view-title-${discussionFromNewMessage}`)))
.toExist()
.withTimeout(5000);
await tapBack();
await waitFor(element(by.id(`rooms-list-view-item-${discussionName}`)))
await waitFor(element(by.id(`rooms-list-view-item-${discussionFromNewMessage}`)))
.toExist()
.withTimeout(5000);
});
it('should create discussion from action button', async () => {
const discussionName = `${data.random} Discussion Action Button`;
await navigateToRoom();
it('should create discussion from Messagebox Actions', async () => {
await navigateToRoom(room);
await element(by.id('messagebox-actions')).tap();
await waitFor(element(by.id('action-sheet')))
.toExist()
@ -70,7 +74,7 @@ describe('Discussion', () => {
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(discussionFromMessagebox);
await waitFor(element(by.id('create-discussion-submit')))
.toExist()
.withTimeout(10000);
@ -78,7 +82,7 @@ describe('Discussion', () => {
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(10000);
await waitFor(element(by.id(`room-view-title-${discussionName}`)))
await waitFor(element(by.id(`room-view-title-${discussionFromMessagebox}`)))
.toExist()
.withTimeout(5000);
});
@ -88,13 +92,12 @@ describe('Discussion', () => {
await waitFor(element(by.id('messagebox')))
.toBeVisible()
.withTimeout(60000);
await mockMessage('message');
discussionFromActionSheet = await mockRandomMessage('message');
});
it('should create discussion', async () => {
const discussionName = `${data.random}message`;
await element(by[textMatcher](discussionName)).atIndex(0).tap();
await element(by[textMatcher](discussionName)).atIndex(0).longPress();
await element(by[textMatcher](discussionFromActionSheet)).atIndex(0).tap();
await element(by[textMatcher](discussionFromActionSheet)).atIndex(0).longPress();
await waitFor(element(by.id('action-sheet')))
.toExist()
.withTimeout(2000);
@ -106,7 +109,7 @@ describe('Discussion', () => {
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(10000);
await waitFor(element(by.id(`room-view-title-${discussionName}`)))
await waitFor(element(by.id(`room-view-title-${discussionFromActionSheet}`)))
.toExist()
.withTimeout(5000);
});
@ -181,24 +184,20 @@ describe('Discussion', () => {
});
describe('Open Discussion from DiscussionsView', () => {
const discussionName = `${data.random}message`;
it('should go back to main room', async () => {
await tapBack();
await waitFor(element(by.id('room-actions-view')))
.toBeVisible()
.withTimeout(5000);
await tapBack();
await waitFor(element(by.id(`room-view-title-${discussionName}`)))
await waitFor(element(by.id(`room-view-title-${discussionFromActionSheet}`)))
.toExist()
.withTimeout(5000);
await tapBack();
await navigateToRoom();
await navigateToRoom(room);
});
it('should navigate to DiscussionsView', async () => {
await waitFor(element(by.id(`room-view-title-${channel}`)))
.toExist()
.withTimeout(5000);
await waitFor(element(by.id('room-header')))
.toBeVisible()
.withTimeout(5000);
@ -213,12 +212,11 @@ describe('Discussion', () => {
});
it('should navigate to discussion', async () => {
const discussionName = `${data.random} Discussion NewMessageView`;
await waitFor(element(by.label(discussionName)).atIndex(0))
await waitFor(element(by.label(discussionFromNewMessage)).atIndex(0))
.toExist()
.withTimeout(5000);
await element(by.label(discussionName)).atIndex(0).tap();
await waitFor(element(by.id(`room-view-title-${discussionName}`)))
await element(by.label(discussionFromNewMessage)).atIndex(0).tap();
await waitFor(element(by.id(`room-view-title-${discussionFromNewMessage}`)))
.toExist()
.withTimeout(5000);
});

View File

@ -1,42 +1,38 @@
import { expect } from 'detox';
import data from '../../data';
import {
navigateToLogin,
login,
mockMessage,
tapBack,
sleep,
searchRoom,
platformTypes,
dismissReviewNag,
TTextMatcher,
tapAndWaitFor
tapAndWaitFor,
navigateToRoom,
mockRandomMessage
} from '../../helpers/app';
async function navigateToRoom(roomName: string) {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
await searchRoom(`${roomName}`);
await element(by.id(`rooms-list-view-item-${roomName}`)).tap();
await waitFor(element(by.id(`room-view-title-${roomName}`)))
.toExist()
.withTimeout(5000);
}
import { createRandomRoom, createRandomUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
describe('Threads', () => {
const mainRoom = data.groups.private.name;
let room: string;
let textMatcher: TTextMatcher;
beforeAll(async () => {
const user = await createRandomUser();
({ name: room } = await createRandomRoom(user));
({ textMatcher } = platformTypes[device.getPlatform()]);
await navigateToRoom(mainRoom);
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
await login(user.username, user.password);
await navigateToRoom(room);
});
describe('Render', () => {
it('should have room screen', async () => {
await waitFor(element(by.id(`room-view-title-${mainRoom}`)))
await waitFor(element(by.id(`room-view-title-${room}`)))
.toExist()
.withTimeout(5000);
});
@ -80,9 +76,9 @@ describe('Threads', () => {
describe('Usage', () => {
describe('Thread', () => {
const thread = `${data.random}thread`;
let thread: string;
it('should create thread', async () => {
await mockMessage('thread');
thread = await mockRandomMessage('thread');
await element(by[textMatcher](thread)).atIndex(0).tap();
await element(by[textMatcher](thread)).atIndex(0).longPress();
await expect(element(by.id('action-sheet'))).toExist();
@ -127,16 +123,15 @@ describe('Threads', () => {
});
it('should send message in thread only', async () => {
const messageText = 'threadonly';
await mockMessage(messageText, true);
const messageText = await mockRandomMessage('threadonly', true);
await tapBack();
await waitFor(element(by.id(`room-view-title-${data.random}thread`)))
await waitFor(element(by.id(`room-view-title-${thread}`)))
.not.toExist()
.withTimeout(5000);
await waitFor(element(by.id(`room-view-title-${mainRoom}`)))
await waitFor(element(by.id(`room-view-title-${room}`)))
.toExist()
.withTimeout(5000);
await waitFor(element(by[textMatcher](`${data.random}${messageText}`)).atIndex(0))
await waitFor(element(by[textMatcher](messageText)).atIndex(0))
.toNotExist()
.withTimeout(2000);
});
@ -151,10 +146,10 @@ describe('Threads', () => {
await element(by.id('messagebox-send-to-channel')).tap();
await element(by.id('messagebox-send-message')).tap();
await tapBack();
await waitFor(element(by.id(`room-view-title-${data.random}thread`)))
await waitFor(element(by.id(`room-view-title-${thread}`)))
.not.toExist()
.withTimeout(5000);
await waitFor(element(by.id(`room-view-title-${mainRoom}`)))
await waitFor(element(by.id(`room-view-title-${room}`)))
.toExist()
.withTimeout(5000);
await waitFor(element(by[textMatcher](messageText)).atIndex(0))
@ -164,7 +159,8 @@ describe('Threads', () => {
it('should navigate to thread from thread name', async () => {
const messageText = 'navthreadname';
await mockMessage('dummymessagebetweenthethread'); // TODO: Create a proper test for this elsewhere.
await mockRandomMessage('dummymessagebetweenthethread');
// TODO: Create a proper test for this elsewhere.
await dismissReviewNag();
await element(by.id(`message-thread-button-${thread}`)).tap();
await waitFor(element(by.id('messagebox-input-thread')))
@ -174,10 +170,10 @@ describe('Threads', () => {
await element(by.id('messagebox-send-to-channel')).tap();
await element(by.id('messagebox-send-message')).tap();
await tapBack();
await waitFor(element(by.id(`room-view-title-${data.random}thread`)))
await waitFor(element(by.id(`room-view-title-${thread}`)))
.not.toExist()
.withTimeout(5000);
await waitFor(element(by.id(`room-view-title-${mainRoom}`)))
await waitFor(element(by.id(`room-view-title-${room}`)))
.toExist()
.withTimeout(5000);
await waitFor(element(by.id(`message-thread-replied-on-${thread}`)))

View File

@ -1,13 +1,16 @@
import data from '../../data';
import { navigateToLogin, login, platformTypes, TTextMatcher } from '../../helpers/app';
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
describe('Group DM', () => {
let textMatcher: TTextMatcher;
let otherUser: ITestUser;
beforeAll(async () => {
const user = await createRandomUser();
otherUser = await createRandomUser();
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
({ textMatcher } = platformTypes[device.getPlatform()]);
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
await login(user.username, user.password);
});
describe('Create Group DM', () => {
@ -43,16 +46,16 @@ describe('Group DM', () => {
.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}`)))
await element(by.id('select-users-view-search')).replaceText(otherUser.username);
await waitFor(element(by.id(`select-users-view-item-${otherUser.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-${otherUser.username}`)).tap();
await element(by.id('selected-users-view-submit')).tap();
});
it('check Group DM exist', async () => {
await waitFor(element(by.id(`room-view-title-${data.users.existing.username}, rocket.cat`)))
await waitFor(element(by.id(`room-view-title-rocket.cat, ${otherUser.username}`)))
.toExist()
.withTimeout(10000);
});