first iteration

This commit is contained in:
Diego Mello 2023-02-22 17:54:30 -03:00
parent ae0c55ac21
commit d2aa631b37
7 changed files with 90 additions and 161 deletions

View File

@ -1,35 +1,28 @@
import { expect } from 'detox';
import data from '../../data';
import { navigateToLogin, login, searchRoom, sleep, platformTypes, TTextMatcher } from '../../helpers/app';
import { sendMessage } from '../../helpers/data_setup';
async function navigateToRoom(user: string) {
await searchRoom(`${user}`);
await element(by.id(`rooms-list-view-item-${user}`)).tap();
await waitFor(element(by.id('room-view')))
.toBeVisible()
.withTimeout(5000);
}
import { navigateToLogin, login, sleep, platformTypes, TTextMatcher, navigateToRoom } from '../../helpers/app';
import { createRandomUser, ITestUser, sendMessage } from '../../helpers/data_setup';
describe('Mark as unread', () => {
const user = data.users.alternate.username;
let user: ITestUser;
let otherUser: ITestUser;
let textMatcher: TTextMatcher;
beforeAll(async () => {
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 navigateToRoom(user);
await login(user.username, user.password);
await navigateToRoom(otherUser.username);
});
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}`;
await sendMessage(data.users.alternate, channelName, message);
const message = 'message-mark-as-unread';
await sendMessage(otherUser, `@${user.username}`, message);
await waitFor(element(by[textMatcher](message)).atIndex(0))
.toExist()
.withTimeout(30000);
@ -43,7 +36,7 @@ describe('Mark as unread', () => {
await waitFor(element(by.id('rooms-list-view')))
.toExist()
.withTimeout(5000);
await expect(element(by.id(`rooms-list-view-item-${data.users.alternate.username}`))).toExist();
await expect(element(by.id(`rooms-list-view-item-${otherUser.username}`))).toExist();
});
});
});

View File

@ -1,22 +1,10 @@
import { expect } from 'detox';
import data from '../../data';
import { navigateToLogin, login, tapBack, sleep, searchRoom, platformTypes, TTextMatcher } from '../../helpers/app';
import { navigateToLogin, login, tapBack, sleep, platformTypes, TTextMatcher, navigateToRoom } from '../../helpers/app';
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
const privateRoomName = data.groups.private.name;
async function navigateToRoomInfo(type: string) {
let room;
if (type === 'd') {
room = 'rocket.cat';
} else {
room = privateRoomName;
}
await searchRoom(room);
await element(by.id(`rooms-list-view-item-${room}`)).tap();
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(2000);
async function navigateToRoomInfo(room: string) {
await navigateToRoom(room);
await element(by.id('room-header')).tap();
await waitFor(element(by.id('room-actions-view')))
.toExist()
@ -38,33 +26,20 @@ async function waitForToast() {
describe('Room info screen', () => {
let alertButtonType: string;
let textMatcher: TTextMatcher;
let room: string;
let user: ITestUser;
beforeAll(async () => {
user = await createRandomUser();
({ name: room } = await createRandomRoom(user, 'p'));
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);
});
describe('Direct', () => {
beforeAll(async () => {
await navigateToRoomInfo('d');
});
it('should navigate to room info', async () => {
await expect(element(by.id('room-info-view'))).toExist();
await expect(element(by.id('room-info-view-name'))).toExist();
});
afterAll(async () => {
await tapBack();
await tapBack();
await tapBack();
});
await login(user.username, user.password);
});
describe('Channel/Group', () => {
beforeAll(async () => {
await navigateToRoomInfo('c');
await navigateToRoomInfo(room);
});
describe('Render', () => {
@ -175,7 +150,7 @@ describe('Room info screen', () => {
await element(by.id('room-info-edit-view-react-when-ro')).tap();
await element(by.id('room-info-edit-view-reset')).tap();
// after reset
await expect(element(by.id('room-info-edit-view-name'))).toHaveText(privateRoomName);
await expect(element(by.id('room-info-edit-view-name'))).toHaveText(room);
await expect(element(by.id('room-info-edit-view-description'))).toHaveText('');
await expect(element(by.id('room-info-edit-view-topic'))).toHaveText('');
await expect(element(by.id('room-info-edit-view-announcement'))).toHaveText('');
@ -187,7 +162,7 @@ describe('Room info screen', () => {
});
it('should change room name', async () => {
await element(by.id('room-info-edit-view-name')).replaceText(`${privateRoomName}new`);
await element(by.id('room-info-edit-view-name')).replaceText(`${room}new`);
await swipe('down'); // dismiss keyboard
await swipe('up');
await element(by.id('room-info-edit-view-submit')).tap();
@ -198,7 +173,7 @@ describe('Room info screen', () => {
.withTimeout(2000);
const matcher = device.getPlatform() === 'android' ? 'toHaveText' : 'toHaveLabel';
await waitFor(element(by.id('room-info-view-name')))
[matcher](`${privateRoomName}new`)
[matcher](`${room}new`)
.withTimeout(10000);
await element(by.id('room-info-view-edit-button')).tap();
await waitFor(element(by.id('room-info-edit-view')))
@ -207,7 +182,7 @@ describe('Room info screen', () => {
});
it('should change room description, topic, announcement', async () => {
await sleep(3000); // wait for changes to be applied from socket
await sleep(5000); // wait for changes to be applied from socket
await element(by.id('room-info-edit-view-description')).replaceText('new description');
await element(by.id('room-info-edit-view-topic')).replaceText('new topic');
await element(by.id('room-info-edit-view-announcement')).replaceText('new announcement');
@ -273,7 +248,7 @@ describe('Room info screen', () => {
.toExist()
.withTimeout(5000);
await element(by[textMatcher]('Yes, delete it!').and(by.type(alertButtonType))).tap();
await waitFor(element(by.id(`rooms-list-view-item-${privateRoomName}new`)))
await waitFor(element(by.id(`rooms-list-view-item-${room}new`)))
.not.toBeVisible()
.withTimeout(60000);
});

View File

@ -1,18 +1,7 @@
import { expect } from 'detox';
import data from '../../data';
import { navigateToLogin, tapBack, login, searchRoom, sleep, platformTypes, TTextMatcher } from '../../helpers/app';
async function navigateToRoom(roomName: string) {
await searchRoom(`${roomName}`);
await element(by.id(`rooms-list-view-item-${roomName}`)).tap();
await waitFor(element(by.id('room-view')))
.toBeVisible()
.withTimeout(5000);
await waitFor(element(by.id(`room-view-title-${roomName}`)))
.toExist()
.withTimeout(5000);
}
import { navigateToLogin, tapBack, login, sleep, platformTypes, TTextMatcher, navigateToRoom } from '../../helpers/app';
let textMatcher: TTextMatcher;
let alertButtonType: string;

View File

@ -4,23 +4,15 @@ import data from '../../data';
import {
navigateToLogin,
login,
searchRoom,
sleep,
platformTypes,
TTextMatcher,
tapBack,
tapAndWaitFor,
checkRoomTitle
checkRoomTitle,
navigateToRoom
} from '../../helpers/app';
import { sendMessage } from '../../helpers/data_setup';
async function navigateToRoom(user: string) {
await searchRoom(`${user}`);
await element(by.id(`rooms-list-view-item-${user}`)).tap();
await waitFor(element(by.id('room-view')))
.toBeVisible()
.withTimeout(5000);
}
import { createRandomRoom, createRandomUser, ITestUser, sendMessage } from '../../helpers/data_setup';
async function navigateToInfoView() {
await element(by.id('room-header')).tap();
@ -34,20 +26,25 @@ async function navigateToInfoView() {
}
describe('Ignore/Block User', () => {
const user = data.users.alternate.username;
let user: ITestUser;
let otherUser: ITestUser;
let room: 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 });
({ textMatcher } = platformTypes[device.getPlatform()]);
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
await login(user.username, user.password);
});
describe('Usage', () => {
describe('Block user from DM', () => {
it('should go to user info view', async () => {
await navigateToRoom(user);
await navigateToRoom(otherUser.username);
await navigateToInfoView();
});
it('should block user', async () => {
@ -86,15 +83,14 @@ describe('Ignore/Block User', () => {
});
});
describe('Ignore user from Message', () => {
const channelName = data.userRegularChannels.detoxpublic.name;
it('should ignore user from message', async () => {
await navigateToRoom(channelName);
await sendMessage(data.users.alternate, channelName, 'message-01');
await sendMessage(data.users.alternate, channelName, 'message-02');
await waitFor(element(by[textMatcher](user)).atIndex(0))
await navigateToRoom(room);
await sendMessage(otherUser, room, 'message-01');
await sendMessage(otherUser, room, 'message-02');
await waitFor(element(by[textMatcher](otherUser.username)).atIndex(0))
.toExist()
.withTimeout(30000);
await element(by[textMatcher](user)).atIndex(0).tap();
await element(by[textMatcher](otherUser.username)).atIndex(0).tap();
await sleep(300); // wait for navigation animation
await waitFor(element(by.id('room-info-view-ignore').withDescendant(by[textMatcher]('Ignore'))))
.toExist()
@ -107,16 +103,16 @@ describe('Ignore/Block User', () => {
});
it('should tap to display message', async () => {
await checkRoomTitle(channelName);
await checkRoomTitle(room);
await waitFor(element(by[textMatcher]('Message ignored. Tap to display it.')).atIndex(0))
.toBeVisible()
.withTimeout(2000);
await tapAndWaitFor(
element(by[textMatcher]('Message ignored. Tap to display it.')).atIndex(0),
element(by[textMatcher](user)),
element(by[textMatcher](otherUser.username)),
2000
);
await element(by[textMatcher](user)).atIndex(0).tap();
await element(by[textMatcher](otherUser.username)).atIndex(0).tap();
await sleep(300); // wait for navigation animation
await expect(element(by.id('room-info-view-ignore').withDescendant(by[textMatcher]('Unignore')))).toBeVisible();
await element(by.id('room-info-view-ignore')).tap();

View File

@ -1,18 +1,20 @@
import { expect } from 'detox';
import data from '../../data';
import { navigateToLogin, login, platformTypes, TTextMatcher } from '../../helpers/app';
const teamName = `team-${data.random}`;
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
describe('Create team screen', () => {
let alertButtonType: string;
let textMatcher: TTextMatcher;
let user: ITestUser;
const teamName = `team${random()}`;
beforeAll(async () => {
user = await createRandomUser();
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 login(user.username, user.password);
});
describe('New Message', () => {
@ -48,20 +50,7 @@ describe('Create team screen', () => {
describe('Create Team', () => {
describe('Usage', () => {
it('should get invalid team name', async () => {
await element(by.id('create-channel-name')).replaceText(`${data.teams.private.name}`);
await waitFor(element(by.id('create-channel-submit')))
.toExist()
.withTimeout(2000);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by[textMatcher]('OK').and(by.type(alertButtonType))))
.toBeVisible()
.withTimeout(5000);
await element(by[textMatcher]('OK').and(by.type(alertButtonType))).tap();
});
it('should create private team', async () => {
await element(by.id('create-channel-name')).replaceText('');
await element(by.id('create-channel-name')).replaceText(teamName);
await waitFor(element(by.id('create-channel-submit')))
.toExist()

View File

@ -1,25 +1,18 @@
import { expect } from 'detox';
import data from '../../data';
import {
navigateToLogin,
login,
tapBack,
sleep,
searchRoom,
platformTypes,
TTextMatcher,
checkRoomTitle,
tapAndWaitFor
tapAndWaitFor,
navigateToRoom
} from '../../helpers/app';
async function navigateToRoom(roomName: string) {
await searchRoom(`${roomName}`);
await element(by.id(`rooms-list-view-item-${roomName}`)).tap();
await waitFor(element(by.id('room-view')))
.toBeVisible()
.withTimeout(5000);
}
import { createRandomRoom, createRandomTeam, createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
async function openActionSheet(username: string) {
await waitFor(element(by.id(`room-members-view-item-${username}`)))
@ -79,18 +72,23 @@ async function swipeTillVisible(
}
describe('Team', () => {
const team = data.teams.private.name;
const user = data.users.alternate;
const room = `private${data.random}-channel-team`;
const existingRoom = data.groups.alternate.name;
const room = `private${random()}-channel-team`;
let alertButtonType: string;
let textMatcher: TTextMatcher;
let user: ITestUser;
let otherUser: ITestUser;
let team: string;
let existingRoom: string;
beforeAll(async () => {
user = await createRandomUser();
otherUser = await createRandomUser();
team = await createRandomTeam(user);
({ name: existingRoom } = 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 login(user.username, user.password);
await navigateToRoom(team);
});
@ -174,8 +172,8 @@ describe('Team', () => {
await waitFor(element(by.id('create-channel-view')))
.toExist()
.withTimeout(10000);
await element(by.id('create-channel-name')).replaceText('');
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-name')).tapReturnKey();
await waitFor(element(by.id('create-channel-submit')))
.toExist()
.withTimeout(10000);
@ -312,12 +310,12 @@ describe('Team', () => {
.toExist()
.withTimeout(4000);
await element(by.id('select-users-view-search')).tap();
await element(by.id('select-users-view-search')).replaceText(user.username);
await waitFor(element(by.id(`select-users-view-item-${user.username}`)))
await element(by.id('select-users-view-search')).replaceText(otherUser.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);
@ -334,7 +332,7 @@ describe('Team', () => {
.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 backToActions();
@ -397,22 +395,22 @@ describe('Team', () => {
.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);
});
it('should filter user', async () => {
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);
});
@ -441,11 +439,11 @@ describe('Team', () => {
});
it('should set member 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);
@ -488,9 +486,12 @@ describe('Team', () => {
.toExist()
.withTimeout(2000);
await element(by.id('select-list-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view')))
.toBeVisible()
.withTimeout(10000);
await waitFor(element(by.id(`rooms-list-view-item-${team}`)))
.toBeNotVisible()
.withTimeout(60000);
.withTimeout(10000);
});
});
});

View File

@ -1,17 +1,9 @@
import data from '../../data';
import {
navigateToLogin,
login,
tapBack,
searchRoom,
platformTypes,
TTextMatcher,
tapAndWaitFor,
sleep
} from '../../helpers/app';
import { navigateToLogin, login, tapBack, platformTypes, TTextMatcher, sleep, navigateToRoom } from '../../helpers/app';
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
const toBeConverted = `to-be-converted-${data.random}`;
const toBeMoved = `to-be-moved-${data.random}`;
const toBeConverted = `to-be-converted-${random()}`;
const toBeMoved = `to-be-moved-${random()}`;
const createChannel = async (room: string) => {
await waitFor(element(by.id('rooms-list-view-create-channel')))
@ -50,14 +42,6 @@ const createChannel = async (room: string) => {
.withTimeout(60000);
};
async function navigateToRoom(room: string) {
await searchRoom(`${room}`);
await element(by.id(`rooms-list-view-item-${room}`)).tap();
await waitFor(element(by.id('room-view')))
.toBeVisible()
.withTimeout(5000);
}
async function navigateToRoomActions(room: string) {
await navigateToRoom(room);
await element(by.id('room-header')).tap();
@ -69,11 +53,13 @@ async function navigateToRoomActions(room: string) {
describe('Move/Convert Team', () => {
let alertButtonType: string;
let textMatcher: TTextMatcher;
let user: ITestUser;
beforeAll(async () => {
user = await createRandomUser();
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 login(user.username, user.password);
});
describe('Convert', () => {