refactoring
This commit is contained in:
parent
ac827ffa07
commit
8d9644c8ac
|
@ -29,14 +29,14 @@ const login = async (username: string, password: string) => {
|
|||
return { authToken, userId };
|
||||
};
|
||||
|
||||
export interface ICreateUser {
|
||||
export interface ITestUser {
|
||||
username: string;
|
||||
password: string;
|
||||
name: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export const createRandomUser = async (): Promise<ICreateUser> => {
|
||||
export const createRandomUser = async (): Promise<ITestUser> => {
|
||||
try {
|
||||
await login(data.adminUser, data.adminPassword);
|
||||
const user = data.randomUser();
|
||||
|
@ -89,15 +89,21 @@ const createChannelIfNotExists = async (channelname: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const createRandomRoom = async (user: { username: string; password: string }, type: 'p' | 'c' = 'c'): Promise<string> => {
|
||||
export const createRandomRoom = async (
|
||||
user: { username: string; password: string },
|
||||
type: 'p' | 'c' = 'c'
|
||||
): Promise<{ _id: string; name: string }> => {
|
||||
try {
|
||||
await login(user.username, user.password);
|
||||
const room = `room${random()}`;
|
||||
console.log(`Creating room ${room}`);
|
||||
await rocketchat.post(type === 'c' ? 'channels.create' : 'groups.create', {
|
||||
const result = await rocketchat.post(type === 'c' ? 'channels.create' : 'groups.create', {
|
||||
name: room
|
||||
});
|
||||
return room;
|
||||
return {
|
||||
_id: type === 'c' ? result.data.channel._id : result.data.group._id,
|
||||
name: type === 'c' ? result.data.channel.name : result.data.group.name
|
||||
};
|
||||
} catch (e) {
|
||||
console.log(JSON.stringify(e));
|
||||
throw new Error('Failed to create room');
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
mockRandomMessage
|
||||
} from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
const checkServer = async (server: string) => {
|
||||
|
@ -71,8 +71,8 @@ async function navigateSecurityPrivacy() {
|
|||
|
||||
describe('E2E Encryption', () => {
|
||||
const room = `encrypted${random()}`;
|
||||
let user: ICreateUser;
|
||||
let otherUser: ICreateUser;
|
||||
let user: ITestUser;
|
||||
let otherUser: ITestUser;
|
||||
let mockedMessageText: string;
|
||||
const newPassword = 'abc';
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@ import {
|
|||
checkRoomTitle,
|
||||
mockRandomMessage
|
||||
} from '../../helpers/app';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
describe('Broadcast room', () => {
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
let otherUser: ICreateUser;
|
||||
let user: ITestUser;
|
||||
let otherUser: ITestUser;
|
||||
let message: string;
|
||||
const room = `broadcast${random()}`;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, sleep, platformTypes, TTextMatcher } from '../../helpers/app';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
const scrollDown = 200;
|
||||
|
@ -13,7 +13,7 @@ async function waitForToast() {
|
|||
describe('Profile screen', () => {
|
||||
let scrollViewType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
let user: ITestUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, platformTypes, TTextMatcher } from '../../helpers/app';
|
||||
import { createRandomRoom, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Settings screen', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
let user: ITestUser;
|
||||
let room: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
room = await createRandomRoom(user);
|
||||
({ name: room } = await createRandomRoom(user));
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
|
|
|
@ -2,7 +2,7 @@ import { expect } from 'detox';
|
|||
|
||||
import data from '../../data';
|
||||
import { navigateToLogin, login, tapBack, searchRoom, platformTypes, TTextMatcher, mockRandomMessage } from '../../helpers/app';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
const room = data.channels.detoxpublic.name;
|
||||
|
||||
|
@ -24,7 +24,7 @@ async function navigateToRoomActions() {
|
|||
describe('Join public room', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
let user: ITestUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, sleep } from '../../helpers/app';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Status screen', () => {
|
||||
let user: ICreateUser;
|
||||
let user: ITestUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import data from '../../data';
|
||||
import { navigateToLogin, login, checkServer, expectValidRegisterOrRetry } from '../../helpers/app';
|
||||
import { createRandomRoom, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
const reopenAndCheckServer = async (server: string) => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true });
|
||||
|
@ -11,12 +11,12 @@ const reopenAndCheckServer = async (server: string) => {
|
|||
};
|
||||
|
||||
describe('Change server', () => {
|
||||
let user: ICreateUser;
|
||||
let user: ITestUser;
|
||||
let room: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
room = await createRandomRoom(user);
|
||||
({ name: room } = await createRandomRoom(user));
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(user.username, user.password);
|
||||
|
|
|
@ -2,7 +2,7 @@ import { expect } from 'detox';
|
|||
|
||||
import data from '../../data';
|
||||
import { navigateToLogin, login, searchRoom, mockRandomMessage } from '../../helpers/app';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
const room = data.channels.detoxpublicprotected.name;
|
||||
const { joinCode } = data.channels.detoxpublicprotected;
|
||||
|
@ -34,7 +34,7 @@ async function openJoinCode() {
|
|||
}
|
||||
|
||||
describe('Join protected room', () => {
|
||||
let user: ICreateUser;
|
||||
let user: ITestUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import data from '../../data';
|
||||
import { navigateToLogin, login, tapBack, sleep } from '../../helpers/app';
|
||||
import { createRandomTeam, createRandomUser, ICreateUser, sendMessage } from '../../helpers/data_setup';
|
||||
import { createRandomTeam, createRandomUser, ITestUser, sendMessage } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
async function navigateToRoom(search: string) {
|
||||
|
@ -19,8 +19,8 @@ async function navigateToRoom(search: string) {
|
|||
}
|
||||
|
||||
describe('Join room from directory', () => {
|
||||
let user: ICreateUser;
|
||||
let otherUser: ICreateUser;
|
||||
let user: ITestUser;
|
||||
let otherUser: ITestUser;
|
||||
let team: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
|
|
|
@ -8,12 +8,12 @@ import {
|
|||
TTextMatcher,
|
||||
expectValidRegisterOrRetry
|
||||
} from '../../helpers/app';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Delete server', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
let user: ITestUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
|
|
|
@ -9,7 +9,8 @@ import {
|
|||
TTextMatcher,
|
||||
expectValidRegisterOrRetry
|
||||
} from '../../helpers/app';
|
||||
import { get, login, sendMessage } from '../../helpers/data_setup';
|
||||
import { createRandomRoom, createRandomUser, get, login, sendMessage } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
const DEEPLINK_METHODS = { AUTH: 'auth', ROOM: 'room' };
|
||||
|
||||
|
@ -24,20 +25,24 @@ const getDeepLink = (method: string, server: string, params?: string) => {
|
|||
describe('Deep linking', () => {
|
||||
let userId: string;
|
||||
let authToken: string;
|
||||
let scrollViewType: string;
|
||||
let threadId: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
const threadMessage = `to-thread-${data.random}`;
|
||||
let rid: string;
|
||||
let room: string;
|
||||
const threadMessage = `to-thread-${random()}`;
|
||||
|
||||
beforeAll(async () => {
|
||||
const loginResult = await login(data.users.regular.username, data.users.regular.password);
|
||||
const user = await createRandomUser();
|
||||
({ _id: rid, name: room } = await createRandomRoom(user, 'p'));
|
||||
const loginResult = await login(user.username, user.password);
|
||||
({ userId, authToken } = loginResult);
|
||||
const deviceType = device.getPlatform();
|
||||
amp = deviceType === 'android' ? '\\&' : '&';
|
||||
({ scrollViewType, textMatcher } = platformTypes[deviceType]);
|
||||
({ textMatcher } = platformTypes[deviceType]);
|
||||
// create a thread with api
|
||||
const result = await sendMessage(data.users.regular, data.groups.alternate2.name, threadMessage);
|
||||
const result = await sendMessage(user, room, threadMessage);
|
||||
threadId = result.message._id;
|
||||
await sendMessage(data.users.regular, result.message.rid, data.random, threadId);
|
||||
await sendMessage(user, result.message.rid, random(), threadId);
|
||||
});
|
||||
|
||||
describe('Authentication', () => {
|
||||
|
@ -56,13 +61,9 @@ describe('Deep linking', () => {
|
|||
await device.launchApp({
|
||||
permissions: { notifications: 'YES' },
|
||||
newInstance: true,
|
||||
url: getDeepLink(
|
||||
DEEPLINK_METHODS.AUTH,
|
||||
data.server,
|
||||
`userId=${userId}${amp}token=${authToken}${amp}path=group/${data.groups.private.name}`
|
||||
)
|
||||
url: getDeepLink(DEEPLINK_METHODS.AUTH, data.server, `userId=${userId}${amp}token=${authToken}${amp}path=group/${room}`)
|
||||
});
|
||||
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`room-view-title-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(30000);
|
||||
await tapBack();
|
||||
|
@ -70,7 +71,7 @@ describe('Deep linking', () => {
|
|||
.toBeVisible()
|
||||
.withTimeout(10000);
|
||||
await checkServer(data.server);
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(2000);
|
||||
};
|
||||
|
@ -82,10 +83,11 @@ describe('Deep linking', () => {
|
|||
it('should authenticate while logged in another server', async () => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToRegister(data.alternateServer);
|
||||
await element(by.id('register-view-name')).replaceText(data.registeringUser4.username);
|
||||
await element(by.id('register-view-username')).replaceText(data.registeringUser4.username);
|
||||
await element(by.id('register-view-email')).replaceText(data.registeringUser4.email);
|
||||
await element(by.id('register-view-password')).replaceText(data.registeringUser4.password);
|
||||
const randomUser = data.randomUser();
|
||||
await element(by.id('register-view-name')).replaceText(randomUser.name);
|
||||
await element(by.id('register-view-username')).replaceText(randomUser.username);
|
||||
await element(by.id('register-view-email')).replaceText(randomUser.email);
|
||||
await element(by.id('register-view-password')).replaceText(randomUser.password);
|
||||
await element(by.id('register-view-password')).tapReturnKey();
|
||||
await expectValidRegisterOrRetry(device.getPlatform());
|
||||
await authAndNavigate();
|
||||
|
@ -98,9 +100,9 @@ describe('Deep linking', () => {
|
|||
await device.launchApp({
|
||||
permissions: { notifications: 'YES' },
|
||||
newInstance: true,
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${data.groups.private.name}`)
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${room}`)
|
||||
});
|
||||
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`room-view-title-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(30000);
|
||||
});
|
||||
|
@ -109,7 +111,7 @@ describe('Deep linking', () => {
|
|||
await device.launchApp({
|
||||
permissions: { notifications: 'YES' },
|
||||
newInstance: true,
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${data.groups.alternate2.name}/thread/${threadId}`)
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${room}/thread/${threadId}`)
|
||||
});
|
||||
await waitFor(element(by.id(`room-view-title-${threadMessage}`)))
|
||||
.toExist()
|
||||
|
@ -117,13 +119,12 @@ describe('Deep linking', () => {
|
|||
});
|
||||
|
||||
it('should navigate to the room using rid', async () => {
|
||||
const roomResult = await get(`groups.info?roomName=${data.groups.private.name}`);
|
||||
await device.launchApp({
|
||||
permissions: { notifications: 'YES' },
|
||||
newInstance: true,
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `rid=${roomResult.data.group._id}`)
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `rid=${rid}`)
|
||||
});
|
||||
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`room-view-title-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(30000);
|
||||
await tapBack();
|
||||
|
@ -137,9 +138,9 @@ describe('Deep linking', () => {
|
|||
await device.launchApp({
|
||||
permissions: { notifications: 'YES' },
|
||||
newInstance: false,
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${data.groups.private.name}`)
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${room}`)
|
||||
});
|
||||
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`room-view-title-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(30000);
|
||||
await tapBack();
|
||||
|
@ -168,13 +169,13 @@ describe('Deep linking', () => {
|
|||
ejson: EJSON.stringify({
|
||||
rid: null,
|
||||
host: data.server,
|
||||
name: data.groups.private.name,
|
||||
name: room,
|
||||
type: 'p'
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`room-view-title-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(30000);
|
||||
await tapBack();
|
||||
|
@ -199,9 +200,9 @@ describe('Deep linking', () => {
|
|||
await device.launchApp({
|
||||
permissions: { notifications: 'YES' },
|
||||
newInstance: true,
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${data.groups.private.name}`)
|
||||
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${room}`)
|
||||
});
|
||||
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`room-view-title-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(30000);
|
||||
});
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, sleep } from '../../helpers/app';
|
||||
import { post } from '../../helpers/data_setup';
|
||||
import data from '../../data';
|
||||
import { navigateToLogin, login } from '../../helpers/app';
|
||||
import { createRandomUser, ITestUser, post } from '../../helpers/data_setup';
|
||||
|
||||
const testuser = data.users.regular;
|
||||
const defaultLaunchArgs = { permissions: { notifications: 'YES' } } as Detox.DeviceLaunchAppConfig;
|
||||
|
||||
const navToLanguage = async () => {
|
||||
|
@ -81,10 +79,12 @@ describe('i18n', () => {
|
|||
});
|
||||
|
||||
describe('Rocket.Chat language', () => {
|
||||
let user: ITestUser;
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
await device.launchApp({ ...defaultLaunchArgs, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(testuser.username, testuser.password);
|
||||
await login(user.username, user.password);
|
||||
});
|
||||
|
||||
it("should select 'en'", async () => {
|
||||
|
@ -119,10 +119,6 @@ describe('i18n', () => {
|
|||
await element(by.id('sidebar-close-drawer')).tap();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await post('users.setPreferences', { data: { language: 'en' } }); // Set back to english
|
||||
});
|
||||
|
||||
// it("should set unsupported language and fallback to 'en'", async () => {
|
||||
// await post('users.setPreferences', { data: { language: 'eo' } }); // Set language to Esperanto
|
||||
// await device.launchApp({ ...defaultLaunchArgs, newInstance: true });
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { login, navigateToLogin } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
import { createRandomUser } from '../../helpers/data_setup';
|
||||
|
||||
const goToDisplayPref = async () => {
|
||||
await expect(element(by.id('rooms-list-view-sidebar'))).toBeVisible();
|
||||
|
@ -18,9 +18,10 @@ const goToRoomList = async () => {
|
|||
|
||||
describe('Display prefs', () => {
|
||||
beforeAll(async () => {
|
||||
const user = await createRandomUser();
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
await login(user.username, user.password);
|
||||
});
|
||||
|
||||
describe('Render', () => {
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
import data from '../../data';
|
||||
import { navigateToLogin, login, sleep, tapBack, navigateToRoom, checkRoomTitle } from '../../helpers/app';
|
||||
import { sendMessage, post } from '../../helpers/data_setup';
|
||||
import { sendMessage, post, ITestUser, createRandomUser, createRandomRoom } from '../../helpers/data_setup';
|
||||
|
||||
const waitForInAppNotificationAnimation = async () => {
|
||||
await sleep(500);
|
||||
};
|
||||
|
||||
const sender = data.users.alternate;
|
||||
const receiver = data.users.inapp;
|
||||
|
||||
describe('InApp Notification', () => {
|
||||
let dmCreatedRid: string;
|
||||
let sender: ITestUser;
|
||||
let receiver: ITestUser;
|
||||
let room: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
sender = await createRandomUser();
|
||||
receiver = await createRandomUser();
|
||||
({ name: room } = await createRandomRoom(sender));
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(receiver.username, receiver.password);
|
||||
|
@ -37,7 +39,7 @@ describe('InApp Notification', () => {
|
|||
describe('receive in another room', () => {
|
||||
const text = 'Another msg';
|
||||
it('should receive and tap InAppNotification while in another room', async () => {
|
||||
await navigateToRoom(data.userRegularChannels.detoxpublic.name);
|
||||
await navigateToRoom(room);
|
||||
await sendMessage(sender, dmCreatedRid, text);
|
||||
await waitFor(element(by.id(`in-app-notification-${text}`)))
|
||||
.toExist()
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import data from '../../data';
|
||||
import { navigateToLogin, platformTypes, TTextMatcher } from '../../helpers/app';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Forgot password screen', () => {
|
||||
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();
|
||||
|
@ -32,7 +34,7 @@ describe('Forgot password screen', () => {
|
|||
|
||||
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-email')).replaceText(user.email);
|
||||
await element(by.id('forgot-password-view-submit')).tap();
|
||||
await waitFor(element(by[textMatcher]('OK')))
|
||||
.toExist()
|
||||
|
|
|
@ -8,13 +8,14 @@ describe('Create user screen', () => {
|
|||
});
|
||||
describe('Usage', () => {
|
||||
it('should register', async () => {
|
||||
await element(by.id('register-view-name')).replaceText(data.registeringUser.username);
|
||||
const user = data.randomUser();
|
||||
await element(by.id('register-view-name')).replaceText(user.username);
|
||||
await element(by.id('register-view-name')).tapReturnKey();
|
||||
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
|
||||
await element(by.id('register-view-username')).replaceText(user.username);
|
||||
await element(by.id('register-view-username')).tapReturnKey();
|
||||
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
|
||||
await element(by.id('register-view-email')).replaceText(user.email);
|
||||
await element(by.id('register-view-email')).tapReturnKey();
|
||||
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
|
||||
await element(by.id('register-view-password')).replaceText(user.password);
|
||||
await element(by.id('register-view-password')).tapReturnKey();
|
||||
|
||||
await expectValidRegisterOrRetry(device.getPlatform());
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { navigateToLogin, tapBack, platformTypes, navigateToWorkspace, login, TTextMatcher } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Login screen', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ITestUser;
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
|
||||
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
|
@ -12,7 +14,7 @@ describe('Login screen', () => {
|
|||
|
||||
describe('Usage', () => {
|
||||
it('should insert wrong password and get error', async () => {
|
||||
await element(by.id('login-view-email')).replaceText(data.users.regular.username);
|
||||
await element(by.id('login-view-email')).replaceText(user.username);
|
||||
await element(by.id('login-view-email')).tapReturnKey();
|
||||
await element(by.id('login-view-password')).replaceText('NotMyActualPassword');
|
||||
await element(by.id('login-view-password')).tapReturnKey();
|
||||
|
@ -23,7 +25,7 @@ describe('Login screen', () => {
|
|||
});
|
||||
|
||||
it('should login with success', async () => {
|
||||
await element(by.id('login-view-password')).replaceText(data.users.regular.password);
|
||||
await element(by.id('login-view-password')).replaceText(user.password);
|
||||
await element(by.id('login-view-password')).tapReturnKey();
|
||||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toBeVisible()
|
||||
|
@ -35,7 +37,7 @@ describe('Login screen', () => {
|
|||
await navigateToWorkspace();
|
||||
await tapBack();
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
await login(user.username, user.password);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { login, navigateToLogin, logout, tapBack, searchRoom } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
import { createRandomUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Rooms list screen', () => {
|
||||
beforeAll(async () => {
|
||||
const user = await createRandomUser();
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
await login(user.username, user.password);
|
||||
});
|
||||
|
||||
describe('Render', () => {
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { login, navigateToLogin, logout, tapBack, tryTapping, tapAndWaitFor } from '../../helpers/app';
|
||||
import { login, navigateToLogin, logout, tapBack, tapAndWaitFor } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Server history', () => {
|
||||
let user: ITestUser;
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
});
|
||||
|
||||
describe('Usage', () => {
|
||||
it('should login, save server as history and logout', async () => {
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
await login(user.username, user.password);
|
||||
await logout();
|
||||
await waitFor(element(by.id('new-server-view')))
|
||||
.toBeVisible()
|
||||
|
@ -30,7 +33,7 @@ describe('Server history', () => {
|
|||
await waitFor(element(by.id('login-view-email')))
|
||||
.toBeVisible()
|
||||
.withTimeout(5000);
|
||||
await expect(element(by.label(data.users.regular.username).withAncestor(by.id('login-view-email'))));
|
||||
await expect(element(by.label(user.username).withAncestor(by.id('login-view-email'))));
|
||||
});
|
||||
|
||||
it('should delete server from history', async () => {
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import data from '../../data';
|
||||
import { tapBack, navigateToLogin, login, tryTapping, platformTypes, TTextMatcher, tapAndWaitFor } from '../../helpers/app';
|
||||
import { tapBack, navigateToLogin, login, platformTypes, TTextMatcher, tapAndWaitFor } from '../../helpers/app';
|
||||
import { createRandomUser } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
describe('Create room screen', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
beforeAll(async () => {
|
||||
const 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', () => {
|
||||
|
@ -139,7 +141,7 @@ describe('Create room screen', () => {
|
|||
});
|
||||
|
||||
it('should create public room', async () => {
|
||||
const room = `public${data.random}`;
|
||||
const room = `public${random()}`;
|
||||
await element(by.id('create-channel-name')).replaceText(room);
|
||||
await element(by.id('create-channel-name')).tapReturnKey();
|
||||
await element(by.id('create-channel-type')).tap();
|
||||
|
@ -166,7 +168,7 @@ describe('Create room screen', () => {
|
|||
});
|
||||
|
||||
it('should create private room', async () => {
|
||||
const room = `private${data.random}`;
|
||||
const room = `private${random()}`;
|
||||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toExist()
|
||||
.withTimeout(5000);
|
||||
|
@ -211,7 +213,7 @@ describe('Create room screen', () => {
|
|||
});
|
||||
|
||||
it('should create empty room', async () => {
|
||||
const room = `empty${data.random}`;
|
||||
const room = `empty${random()}`;
|
||||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toExist()
|
||||
.withTimeout(10000);
|
||||
|
|
Loading…
Reference in New Issue