mattermost-mobile/detox/e2e/support/server_api/setup.js
Saturnino Abril f05faaa949
E2E: Initial Detox setup for Mobile UI automation (#4535)
* initial Detox setup for mobile UI automation

* fix iOS allow permission on opening the app, add npm script to root folder, fix test when using longer site URL and add detox dependency to root for android build dependency

* remove detox proguardFile

* update packages and emulator

* change folder build on local and CI

* add test to post a message, ability to have test in isolation, server API commands, server config, dependency updates and update folder structure

* update snapshot

* update detox and do clean up

* update dependencies
2020-08-29 07:18:41 +08:00

41 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';
import {getResponseFromError} from './common';
/**
* Creates new user, channel and team for test isolation.
* @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 ({
channelOptions = {type: 'O', prefix: 'channel'},
teamOptions = {type: 'O', prefix: 'team'},
userOptions = {prefix: 'user'},
} = {}) => {
try {
const {team} = await Team.apiCreateTeam(teamOptions);
const {channel} = await Channel.apiCreateChannel({...channelOptions, teamId: team.id});
const {user} = await User.apiCreateUser(userOptions);
await Team.apiAddUserToTeam(user.id, team.id);
await Channel.apiAddUserToChannel(user.id, channel.id);
return {
channel,
team,
user,
};
} catch (err) {
return getResponseFromError(err);
}
};
export const Setup = {
apiInit,
};
export default Setup;