mattermost-mobile/detox/e2e/support/server_api/setup.js
Joseph Baylon b87cf8358b
MM-41854 Detox/E2E: Setup detox infrastructure in Gekidou (#5979)
* MM-41854 Detox/E2E: Setup detox infrastructure in Gekidou

* Fix lint issues

* Fix lint issues

* Update API to include baseUrl for multiple servers

* Update init.js to have default siteUrl as baseUrl

* Update init.js to have default siteUrl as baseUrl

* Update import of testConfig

* Update import of testConfig

* Update postMessageAs signature

* Update detox/webhook_server.js

Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>
2022-03-01 07:20:59 -08:00

37 lines
1.2 KiB
JavaScript

// 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, {
channelOptions = {type: 'O', prefix: 'channel'},
teamOptions = {type: 'O', prefix: 'team'},
userOptions = {prefix: 'user'},
} = {}) => {
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;