until deleteserver
This commit is contained in:
parent
cc121e66f5
commit
c4b60efa50
|
@ -109,7 +109,7 @@ const data = {
|
||||||
const randomVal = random();
|
const randomVal = random();
|
||||||
return {
|
return {
|
||||||
username: `user${randomVal}`,
|
username: `user${randomVal}`,
|
||||||
name: `name${randomVal}`,
|
name: `user${randomVal}`, // FIXME: apply a different name
|
||||||
password: `password${randomVal}`,
|
password: `password${randomVal}`,
|
||||||
email: `mobile+${randomVal}@rocket.chat`
|
email: `mobile+${randomVal}@rocket.chat`
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,8 +43,8 @@ export const createRandomUser = async (): Promise<ICreateUser> => {
|
||||||
console.log(`Creating user ${user.username}`);
|
console.log(`Creating user ${user.username}`);
|
||||||
await rocketchat.post('users.create', {
|
await rocketchat.post('users.create', {
|
||||||
username: user.username,
|
username: user.username,
|
||||||
password: user.password,
|
|
||||||
name: user.name,
|
name: user.name,
|
||||||
|
password: user.password,
|
||||||
email: user.email
|
email: user.email
|
||||||
});
|
});
|
||||||
return user;
|
return user;
|
||||||
|
@ -90,20 +90,36 @@ const createChannelIfNotExists = async (channelname: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createRandomChannel = async (user: { username: string; password: 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 {
|
try {
|
||||||
const result = await rocketchat.post('channels.create', {
|
await login(user.username, user.password);
|
||||||
|
const room = `room${random()}`;
|
||||||
|
console.log(`Creating public channel ${room}`);
|
||||||
|
await rocketchat.post('channels.create', {
|
||||||
name: room
|
name: room
|
||||||
});
|
});
|
||||||
return result.data.channel.name;
|
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 public channel');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const createRandomTeam = async (user: { username: string; password: string }) => {
|
||||||
|
try {
|
||||||
|
await login(user.username, user.password);
|
||||||
|
const team = `team${random()}`;
|
||||||
|
console.log(`Creating team ${team}`);
|
||||||
|
await rocketchat.post('teams.create', {
|
||||||
|
name: team,
|
||||||
|
type: TEAM_TYPE.PRIVATE
|
||||||
|
});
|
||||||
|
return team;
|
||||||
|
} catch (e) {
|
||||||
|
console.log(JSON.stringify(e));
|
||||||
|
throw new Error('Failed create team');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const createTeamIfNotExists = async (teamname: string) => {
|
const createTeamIfNotExists = async (teamname: string) => {
|
||||||
console.log(`Creating private team ${teamname}`);
|
console.log(`Creating private team ${teamname}`);
|
||||||
try {
|
try {
|
||||||
|
@ -158,6 +174,29 @@ const changeChannelJoinCode = async (roomId: string, joinCode: string) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const sendRandomMessage = async ({
|
||||||
|
user,
|
||||||
|
room,
|
||||||
|
messageEnd,
|
||||||
|
tmid
|
||||||
|
}: {
|
||||||
|
user: { username: string; password: string };
|
||||||
|
room: string;
|
||||||
|
messageEnd: string;
|
||||||
|
tmid?: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const msg = `${random()}${messageEnd}`;
|
||||||
|
console.log(`Sending message ${msg} to ${room}`);
|
||||||
|
await login(user.username, user.password);
|
||||||
|
const response = await rocketchat.post('chat.postMessage', { channel: room, msg, tmid });
|
||||||
|
return response.data;
|
||||||
|
} catch (infoError) {
|
||||||
|
console.log(JSON.stringify(infoError));
|
||||||
|
throw new Error('Failed to find or create private group');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const sendMessage = async (user: { username: string; password: string }, channel: string, msg: string, tmid?: string) => {
|
const sendMessage = async (user: { username: string; password: string }, channel: string, msg: string, tmid?: string) => {
|
||||||
console.log(`Sending message to ${channel}`);
|
console.log(`Sending message to ${channel}`);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { expect } from 'detox';
|
import { expect } from 'detox';
|
||||||
|
|
||||||
import data from '../../data';
|
import data from '../../data';
|
||||||
import { navigateToLogin, login, mockMessage, searchRoom } from '../../helpers/app';
|
import { navigateToLogin, login, searchRoom, mockRandomMessage } from '../../helpers/app';
|
||||||
|
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||||
|
|
||||||
const testuser = data.users.regular;
|
|
||||||
const room = data.channels.detoxpublicprotected.name;
|
const room = data.channels.detoxpublicprotected.name;
|
||||||
const { joinCode } = data.channels.detoxpublicprotected;
|
const { joinCode } = data.channels.detoxpublicprotected;
|
||||||
|
|
||||||
|
@ -34,10 +34,13 @@ async function openJoinCode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Join protected room', () => {
|
describe('Join protected room', () => {
|
||||||
|
let user: ICreateUser;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
user = await createRandomUser();
|
||||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
await navigateToLogin();
|
await navigateToLogin();
|
||||||
await login(testuser.username, testuser.password);
|
await login(user.username, user.password);
|
||||||
await navigateToRoom();
|
await navigateToRoom();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,7 +71,7 @@ describe('Join protected room', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send message', async () => {
|
it('should send message', async () => {
|
||||||
await mockMessage('message');
|
await mockRandomMessage('message');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import data from '../../data';
|
import data from '../../data';
|
||||||
import { navigateToLogin, login, tapBack, sleep } from '../../helpers/app';
|
import { navigateToLogin, login, tapBack, sleep } from '../../helpers/app';
|
||||||
import { sendMessage } from '../../helpers/data_setup';
|
import { createRandomTeam, createRandomUser, ICreateUser, sendMessage } from '../../helpers/data_setup';
|
||||||
|
import random from '../../helpers/random';
|
||||||
const testuser = data.users.regular;
|
|
||||||
|
|
||||||
async function navigateToRoom(search: string) {
|
async function navigateToRoom(search: string) {
|
||||||
await element(by.id('directory-view-search')).replaceText(search);
|
await element(by.id('directory-view-search')).replaceText(search);
|
||||||
|
@ -20,18 +19,26 @@ async function navigateToRoom(search: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Join room from directory', () => {
|
describe('Join room from directory', () => {
|
||||||
|
let user: ICreateUser;
|
||||||
|
let otherUser: ICreateUser;
|
||||||
|
let team: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
user = await createRandomUser();
|
||||||
|
otherUser = await createRandomUser();
|
||||||
|
team = await createRandomTeam(user);
|
||||||
|
|
||||||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||||
await navigateToLogin();
|
await navigateToLogin();
|
||||||
await login(testuser.username, testuser.password);
|
await login(user.username, user.password);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Usage', () => {
|
describe('Usage', () => {
|
||||||
const threadMessage = `thread-${data.random}`;
|
const thread = `${random()}thread`;
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const result = await sendMessage(data.users.alternate, data.channels.detoxpublic.name, threadMessage);
|
const result = await sendMessage(user, data.channels.detoxpublic.name, thread);
|
||||||
const threadId = result.message._id;
|
const threadId = result.message._id;
|
||||||
await sendMessage(data.users.alternate, result.message.rid, data.random, threadId);
|
await sendMessage(user, result.message.rid, 'insidethread', threadId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should tap directory', async () => {
|
it('should tap directory', async () => {
|
||||||
|
@ -50,7 +57,7 @@ describe('Join room from directory', () => {
|
||||||
.toBeVisible()
|
.toBeVisible()
|
||||||
.withTimeout(2000);
|
.withTimeout(2000);
|
||||||
await element(by.id('room-view-header-threads')).tap();
|
await element(by.id('room-view-header-threads')).tap();
|
||||||
await waitFor(element(by.id(`thread-messages-view-${threadMessage}`)))
|
await waitFor(element(by.id(`thread-messages-view-${thread}`)))
|
||||||
.toBeVisible()
|
.toBeVisible()
|
||||||
.withTimeout(2000);
|
.withTimeout(2000);
|
||||||
await tapBack();
|
await tapBack();
|
||||||
|
@ -68,7 +75,7 @@ describe('Join room from directory', () => {
|
||||||
await element(by.id('directory-view-dropdown')).tap();
|
await element(by.id('directory-view-dropdown')).tap();
|
||||||
await element(by.label('Users')).atIndex(0).tap();
|
await element(by.label('Users')).atIndex(0).tap();
|
||||||
await element(by.label('Search by')).atIndex(0).tap();
|
await element(by.label('Search by')).atIndex(0).tap();
|
||||||
await navigateToRoom(data.users.alternate.username);
|
await navigateToRoom(otherUser.username);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should search team and navigate', async () => {
|
it('should search team and navigate', async () => {
|
||||||
|
@ -80,7 +87,7 @@ describe('Join room from directory', () => {
|
||||||
await element(by.id('directory-view-dropdown')).tap();
|
await element(by.id('directory-view-dropdown')).tap();
|
||||||
await element(by.label('Teams')).atIndex(0).tap();
|
await element(by.label('Teams')).atIndex(0).tap();
|
||||||
await element(by.label('Search by')).atIndex(0).tap();
|
await element(by.label('Search by')).atIndex(0).tap();
|
||||||
await navigateToRoom(data.teams.private.name);
|
await navigateToRoom(team);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,15 +8,19 @@ import {
|
||||||
TTextMatcher,
|
TTextMatcher,
|
||||||
expectValidRegisterOrRetry
|
expectValidRegisterOrRetry
|
||||||
} from '../../helpers/app';
|
} from '../../helpers/app';
|
||||||
|
import { createRandomUser, ICreateUser } from '../../helpers/data_setup';
|
||||||
|
|
||||||
describe('Delete server', () => {
|
describe('Delete server', () => {
|
||||||
let alertButtonType: string;
|
let alertButtonType: string;
|
||||||
let textMatcher: TTextMatcher;
|
let textMatcher: TTextMatcher;
|
||||||
|
let user: ICreateUser;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
user = await createRandomUser();
|
||||||
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();
|
||||||
await login(data.users.regular.username, data.users.regular.password);
|
await login(user.username, user.password);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be logged in main server', async () => {
|
it('should be logged in main server', async () => {
|
||||||
|
@ -45,10 +49,11 @@ describe('Delete server', () => {
|
||||||
.withTimeout(2000);
|
.withTimeout(2000);
|
||||||
|
|
||||||
// Register new user
|
// Register new user
|
||||||
await element(by.id('register-view-name')).replaceText(data.registeringUser3.username);
|
const randomUser = data.randomUser();
|
||||||
await element(by.id('register-view-username')).replaceText(data.registeringUser3.username);
|
await element(by.id('register-view-name')).replaceText(randomUser.name);
|
||||||
await element(by.id('register-view-email')).replaceText(data.registeringUser3.email);
|
await element(by.id('register-view-username')).replaceText(randomUser.username);
|
||||||
await element(by.id('register-view-password')).replaceText(data.registeringUser3.password);
|
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 element(by.id('register-view-password')).tapReturnKey();
|
||||||
await expectValidRegisterOrRetry(device.getPlatform());
|
await expectValidRegisterOrRetry(device.getPlatform());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue