stash
This commit is contained in:
parent
c4b60efa50
commit
ac827ffa07
|
@ -89,18 +89,18 @@ const createChannelIfNotExists = async (channelname: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const createRandomChannel = async (user: { username: string; password: string }) => {
|
||||
export const createRandomRoom = async (user: { username: string; password: string }, type: 'p' | 'c' = 'c'): Promise<string> => {
|
||||
try {
|
||||
await login(user.username, user.password);
|
||||
const room = `room${random()}`;
|
||||
console.log(`Creating public channel ${room}`);
|
||||
await rocketchat.post('channels.create', {
|
||||
console.log(`Creating room ${room}`);
|
||||
await rocketchat.post(type === 'c' ? 'channels.create' : 'groups.create', {
|
||||
name: room
|
||||
});
|
||||
return room;
|
||||
} catch (e) {
|
||||
console.log(JSON.stringify(e));
|
||||
throw new Error('Failed to create public channel');
|
||||
throw new Error('Failed to create room');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, platformTypes, TTextMatcher } from '../../helpers/app';
|
||||
import { createRandomChannel, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomRoom, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Settings screen', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
let channel: string;
|
||||
let room: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
channel = await createRandomChannel(user);
|
||||
room = await createRandomRoom(user);
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
|
@ -87,7 +87,7 @@ describe('Settings screen', () => {
|
|||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(5000);
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${channel}`)))
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
|
||||
.toExist()
|
||||
.withTimeout(10000);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import data from '../../data';
|
||||
import { navigateToLogin, login, checkServer, expectValidRegisterOrRetry } from '../../helpers/app';
|
||||
import { createRandomChannel, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import { createRandomRoom, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
|
||||
const reopenAndCheckServer = async (server: string) => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true });
|
||||
|
@ -12,11 +12,11 @@ const reopenAndCheckServer = async (server: string) => {
|
|||
|
||||
describe('Change server', () => {
|
||||
let user: ICreateUser;
|
||||
let channel: string;
|
||||
let room: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
channel = await createRandomChannel(user);
|
||||
room = await createRandomRoom(user);
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(user.username, user.password);
|
||||
|
@ -71,7 +71,7 @@ describe('Change server', () => {
|
|||
await element(by.id('register-view-password')).tapReturnKey();
|
||||
await expectValidRegisterOrRetry(device.getPlatform());
|
||||
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${channel}`)))
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
|
||||
.toBeNotVisible()
|
||||
.withTimeout(60000);
|
||||
await checkServer(data.alternateServer);
|
||||
|
@ -90,7 +90,7 @@ describe('Change server', () => {
|
|||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(10000);
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${channel}`)))
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
|
||||
.toBeVisible()
|
||||
.withTimeout(60000);
|
||||
await checkServer(data.server);
|
||||
|
|
Loading…
Reference in New Issue