til changeserver
This commit is contained in:
parent
e9721c8743
commit
cc121e66f5
|
@ -105,11 +105,12 @@ const data = {
|
|||
email: `mobile+registeringfour${value}@rocket.chat`
|
||||
},
|
||||
random: value,
|
||||
randomUser: (): { username: string; password: string; email: string } => {
|
||||
randomUser: (): { username: string; name: string; password: string; email: string } => {
|
||||
const randomVal = random();
|
||||
return {
|
||||
username: `user${randomVal}`,
|
||||
password: '123',
|
||||
name: `name${randomVal}`,
|
||||
password: `password${randomVal}`,
|
||||
email: `mobile+${randomVal}@rocket.chat`
|
||||
};
|
||||
}
|
||||
|
|
|
@ -95,6 +95,9 @@ async function logout() {
|
|||
await expect(element(by.id('new-server-view'))).toBeVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use mockRandomMessage
|
||||
*/
|
||||
async function mockMessage(message: string, isThread = false) {
|
||||
const deviceType = device.getPlatform();
|
||||
const { textMatcher } = platformTypes[deviceType];
|
||||
|
|
|
@ -37,22 +37,17 @@ export interface ICreateUser {
|
|||
}
|
||||
|
||||
export const createRandomUser = async (): Promise<ICreateUser> => {
|
||||
await login(data.adminUser, data.adminPassword);
|
||||
const val = random(5);
|
||||
console.log(`Creating user user${val}`);
|
||||
|
||||
try {
|
||||
const username = `user${val}`;
|
||||
const password = `pass${val}`;
|
||||
const name = `name${val}`;
|
||||
const email = `mobile+${val}@rocket.chat`;
|
||||
await login(data.adminUser, data.adminPassword);
|
||||
const user = data.randomUser();
|
||||
console.log(`Creating user ${user.username}`);
|
||||
await rocketchat.post('users.create', {
|
||||
username,
|
||||
password,
|
||||
name,
|
||||
email
|
||||
username: user.username,
|
||||
password: user.password,
|
||||
name: user.name,
|
||||
email: user.email
|
||||
});
|
||||
return { username, password, name, email } as const;
|
||||
return user;
|
||||
} catch (error) {
|
||||
console.log(JSON.stringify(error));
|
||||
throw new Error('Failed to create user');
|
||||
|
@ -94,6 +89,21 @@ const createChannelIfNotExists = async (channelname: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const createRandomChannel = async (user: { username: string; password: string }) => {
|
||||
await login(user.username, user.password);
|
||||
const room = `room${random()}`;
|
||||
console.log(`Creating public channel ${room}`);
|
||||
try {
|
||||
const result = await rocketchat.post('channels.create', {
|
||||
name: room
|
||||
});
|
||||
return result.data.channel.name;
|
||||
} catch (e) {
|
||||
console.log(JSON.stringify(e));
|
||||
throw new Error('Failed to create public channel');
|
||||
}
|
||||
};
|
||||
|
||||
const createTeamIfNotExists = async (teamname: string) => {
|
||||
console.log(`Creating private team ${teamname}`);
|
||||
try {
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
checkRoomTitle,
|
||||
mockRandomMessage
|
||||
} from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, sleep, platformTypes, TTextMatcher } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
|
||||
const profileChangeUser = data.users.profileChanges;
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
import random from '../../helpers/random';
|
||||
|
||||
const scrollDown = 200;
|
||||
|
||||
async function waitForToast() {
|
||||
// await waitFor(element(by.id('toast'))).toBeVisible().withTimeout(1000);
|
||||
// await expect(element(by.id('toast'))).toBeVisible();
|
||||
// await waitFor(element(by.id('toast'))).not.toBeNotVisible().withTimeout(1000);
|
||||
// await expect(element(by.id('toast'))).not.toBeVisible();
|
||||
await sleep(600);
|
||||
}
|
||||
|
||||
describe('Profile screen', () => {
|
||||
let scrollViewType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
({ scrollViewType, textMatcher } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
await login(profileChangeUser.username, profileChangeUser.password);
|
||||
await login(user.username, user.password);
|
||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||
await waitFor(element(by.id('sidebar-view')))
|
||||
.toBeVisible()
|
||||
|
@ -97,8 +94,8 @@ describe('Profile screen', () => {
|
|||
|
||||
describe('Usage', () => {
|
||||
it('should change name and username', async () => {
|
||||
await element(by.id('profile-view-name')).replaceText(`${profileChangeUser.username}new`);
|
||||
await element(by.id('profile-view-username')).replaceText(`${profileChangeUser.username}new`);
|
||||
await element(by.id('profile-view-name')).replaceText(`${user.username}new`);
|
||||
await element(by.id('profile-view-username')).replaceText(`${user.username}new`);
|
||||
await element(by.id('profile-view-list')).swipe('down');
|
||||
await element(by.id('profile-view-submit')).tap();
|
||||
await waitForToast();
|
||||
|
@ -108,8 +105,8 @@ describe('Profile screen', () => {
|
|||
await waitFor(element(by.id('profile-view-email')))
|
||||
.toBeVisible()
|
||||
.withTimeout(2000);
|
||||
await element(by.id('profile-view-email')).replaceText(`mobile+profileChangesNew${data.random}@rocket.chat`);
|
||||
await element(by.id('profile-view-new-password')).replaceText(`${profileChangeUser.password}new`);
|
||||
await element(by.id('profile-view-email')).replaceText(`mobile+profileChangesNew${random()}@rocket.chat`);
|
||||
await element(by.id('profile-view-new-password')).replaceText(`${user.password}new`);
|
||||
await waitFor(element(by.id('profile-view-submit')))
|
||||
.toExist()
|
||||
.withTimeout(2000);
|
||||
|
@ -117,7 +114,7 @@ describe('Profile screen', () => {
|
|||
await waitFor(element(by.id('profile-view-enter-password-sheet')))
|
||||
.toBeVisible()
|
||||
.withTimeout(2000);
|
||||
await element(by.id('profile-view-enter-password-sheet')).replaceText(`${profileChangeUser.password}`);
|
||||
await element(by.id('profile-view-enter-password-sheet')).replaceText(`${user.password}`);
|
||||
await element(by[textMatcher]('Save').withAncestor(by.id('action-sheet-content-with-input-and-submit')))
|
||||
.atIndex(0)
|
||||
.tap();
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, platformTypes, TTextMatcher } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
|
||||
const testuser = data.users.regular;
|
||||
import { createRandomChannel, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Settings screen', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
let channel: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
channel = await createRandomChannel(user);
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
await login(testuser.username, testuser.password);
|
||||
await login(user.username, user.password);
|
||||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(10000);
|
||||
|
@ -84,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-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${channel}`)))
|
||||
.toExist()
|
||||
.withTimeout(10000);
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import data from '../../data';
|
||||
import { navigateToLogin, login, mockMessage, tapBack, searchRoom, platformTypes, TTextMatcher, sleep } from '../../helpers/app';
|
||||
import { navigateToLogin, login, tapBack, searchRoom, platformTypes, TTextMatcher, mockRandomMessage } from '../../helpers/app';
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
|
||||
const testuser = data.users.regular;
|
||||
const room = data.channels.detoxpublic.name;
|
||||
|
||||
async function navigateToRoom() {
|
||||
|
@ -24,11 +24,14 @@ async function navigateToRoomActions() {
|
|||
describe('Join public room', () => {
|
||||
let alertButtonType: string;
|
||||
let textMatcher: TTextMatcher;
|
||||
let user: ICreateUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
||||
await navigateToLogin();
|
||||
await login(testuser.username, testuser.password);
|
||||
await login(user.username, user.password);
|
||||
await navigateToRoom();
|
||||
});
|
||||
|
||||
|
@ -141,7 +144,7 @@ describe('Join public room', () => {
|
|||
});
|
||||
|
||||
it('should send message', async () => {
|
||||
await mockMessage('message');
|
||||
await mockRandomMessage('message');
|
||||
});
|
||||
|
||||
it('should have notifications and leave channel', async () => {
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { navigateToLogin, login, sleep } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
|
||||
const testuser = data.users.regular;
|
||||
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
|
||||
describe('Status screen', () => {
|
||||
let user: ICreateUser;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(testuser.username, testuser.password);
|
||||
await login(user.username, user.password);
|
||||
|
||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||
await waitFor(element(by.id('sidebar-view')))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import data from '../../data';
|
||||
import { navigateToLogin, login, checkServer, sleep, expectValidRegisterOrRetry } from '../../helpers/app';
|
||||
import { navigateToLogin, login, checkServer, expectValidRegisterOrRetry } from '../../helpers/app';
|
||||
import { createRandomChannel, createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||
|
||||
const reopenAndCheckServer = async (server: string) => {
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true });
|
||||
|
@ -10,13 +11,15 @@ const reopenAndCheckServer = async (server: string) => {
|
|||
};
|
||||
|
||||
describe('Change server', () => {
|
||||
let user: ICreateUser;
|
||||
let channel: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
user = await createRandomUser();
|
||||
channel = await createRandomChannel(user);
|
||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(10000);
|
||||
await login(user.username, user.password);
|
||||
});
|
||||
|
||||
it('should open the dropdown button, have the server add button and create workspace button', async () => {
|
||||
|
@ -37,7 +40,7 @@ describe('Change server', () => {
|
|||
await waitFor(element(by.id('new-server-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(6000);
|
||||
await element(by.id('new-server-view-input')).replaceText(`${data.alternateServer}`);
|
||||
await element(by.id('new-server-view-input')).replaceText(data.alternateServer);
|
||||
await element(by.id('new-server-view-input')).tapReturnKey();
|
||||
await waitFor(element(by.id('workspace-view')))
|
||||
.toBeVisible()
|
||||
|
@ -60,15 +63,15 @@ describe('Change server', () => {
|
|||
.withTimeout(2000);
|
||||
|
||||
// Register new user
|
||||
await sleep(5000);
|
||||
await element(by.id('register-view-name')).replaceText(data.registeringUser2.username);
|
||||
await element(by.id('register-view-username')).replaceText(data.registeringUser2.username);
|
||||
await element(by.id('register-view-email')).replaceText(data.registeringUser2.email);
|
||||
await element(by.id('register-view-password')).replaceText(data.registeringUser2.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 waitFor(element(by.id(`rooms-list-view-item-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${channel}`)))
|
||||
.toBeNotVisible()
|
||||
.withTimeout(60000);
|
||||
await checkServer(data.alternateServer);
|
||||
|
@ -87,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-${data.groups.private.name}`)))
|
||||
await waitFor(element(by.id(`rooms-list-view-item-${channel}`)))
|
||||
.toBeVisible()
|
||||
.withTimeout(60000);
|
||||
await checkServer(data.server);
|
||||
|
|
Loading…
Reference in New Issue