forked from Ivasoft/mattermost-mobile
* Detox/E2E: Migrate to typescript * Add jest.config.js * Add moduleMapper to config.json * Add cookie jar to axios client, fix tsconfig.json and default_config.json * Take keyboard into consideration; clean test for now for this migration PR * Revert changes on path_builder * Attempt to fix dep issues * Update detox dep * Added missing @type dev dependencies * Fix dep order * Fix unit tests * Added dynamic year to email.ts
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import Channel from './channel';
|
|
import Team from './team';
|
|
import User from './user';
|
|
|
|
/**
|
|
* Creates new user, channel and team for test isolation.
|
|
* @param {string} baseUrl - the base server URL
|
|
* @param {Object} options - may pass options to predefine channel, team and user creation
|
|
* @return {Object} returns {channel, team, user} on success or {error, status} on error
|
|
*/
|
|
export const apiInit = async (baseUrl: string, {
|
|
channelOptions = {type: 'O', prefix: 'channel'},
|
|
teamOptions = {type: 'O', prefix: 'team'},
|
|
userOptions = {prefix: 'user'},
|
|
}: any = {}): Promise<any> => {
|
|
const {team} = await Team.apiCreateTeam(baseUrl, teamOptions);
|
|
const {channel} = await Channel.apiCreateChannel(baseUrl, {...channelOptions, teamId: team.id});
|
|
const {user} = await User.apiCreateUser(baseUrl, userOptions);
|
|
|
|
await Team.apiAddUserToTeam(baseUrl, user.id, team.id);
|
|
await Channel.apiAddUserToChannel(baseUrl, user.id, channel.id);
|
|
|
|
return {
|
|
channel,
|
|
team,
|
|
user,
|
|
};
|
|
};
|
|
|
|
export const Setup = {
|
|
apiInit,
|
|
};
|
|
|
|
export default Setup;
|