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