mattermost-mobile/detox/e2e/test/smoke_test/teams.e2e.js
Daniel Espino García 4c8594d330
Add linter rules for import order and type member delimiters (#5514)
* Add linter rules for import order and type member delimiters

* Remove unneeded group

* Group all app/* imports before the internal imports

* Move app/ imports before parent imports

* Separate @node_modules imports into a different group

* Substitute app paths by aliases

* Fix @node_modules import order and add test related modules

* Add aliases for types and test, and group import types
2021-07-23 11:06:04 +02:00

96 lines
3 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// *******************************************************************
// - [#] indicates a test step (e.g. # Go to a screen)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element testID when selecting an element. Create one if none.
// *******************************************************************
import {
Channel,
Setup,
Team,
} from '@support/server_api';
import {MainSidebar} from '@support/ui/component';
import {ChannelScreen} from '@support/ui/screen';
describe('Teams', () => {
let testTeam1;
let testTeam1Channel;
let testTeam2;
let testTeam2Channel;
beforeAll(async () => {
const {team, user} = await Setup.apiInit({teamOptions: {prefix: 'team-a'}});
testTeam1 = team;
const {channel} = await Channel.apiGetChannelByName(testTeam1.id, 'town-square');
testTeam1Channel = channel;
({team: testTeam2} = await Team.apiCreateTeam({prefix: 'team-b'}));
await Team.apiAddUserToTeam(user.id, testTeam2.id);
({channel: testTeam2Channel} = await Channel.apiGetChannelByName(testTeam2.id, 'town-square'));
// # Open channel screen
await ChannelScreen.open(user);
});
afterAll(async () => {
await ChannelScreen.logout();
});
it('MM-T3249 should be able to switch between teams', async () => {
const {
channelNavBarTitle,
closeTeamSidebar,
openTeamSidebar,
} = ChannelScreen;
const {getTeamByDisplayName} = MainSidebar;
// * Verify user is on team 1 channel
await expect(channelNavBarTitle).toHaveText(testTeam1Channel.display_name);
// * Verify team 1 in team sidebar
await openTeamSidebar();
await verifyTeamSidebar(testTeam1);
// # Tap on team 1
await getTeamByDisplayName(testTeam1.display_name).tap();
// * Verify user is on team 1 channel
await ChannelScreen.toBeVisible();
await expect(channelNavBarTitle).toHaveText(testTeam1Channel.display_name);
// # Tap on team 2
await openTeamSidebar();
await getTeamByDisplayName(testTeam2.display_name).tap();
// * Verify user is on team 2 channel
await ChannelScreen.toBeVisible();
await expect(channelNavBarTitle).toHaveText(testTeam2Channel.display_name);
// * Verify team 2 in team sidebar
await openTeamSidebar();
await verifyTeamSidebar(testTeam2);
// # Close team sidebar
await closeTeamSidebar();
});
});
async function verifyTeamSidebar(testTeam) {
const {
teamItem,
teamItemCurrent,
teamItemDisplayName,
teamItemIcon,
} = await MainSidebar.getTeam(testTeam.id, testTeam.display_name);
// * Verify team is current
await expect(teamItem).toBeVisible();
await expect(teamItemCurrent).toBeVisible();
await expect(teamItemDisplayName).toBeVisible();
await expect(teamItemIcon).toBeVisible();
}