mattermost-mobile/detox/e2e/test/channels/direct_messages.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

100 lines
3.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 {
Preference,
Setup,
Team,
User,
} from '@support/server_api';
import {MainSidebar} from '@support/ui/component';
import {
ChannelInfoScreen,
ChannelScreen,
MoreDirectMessagesScreen,
} from '@support/ui/screen';
describe('Direct Messages', () => {
const {
closeMainSidebar,
goToChannel,
openMainSidebar,
} = ChannelScreen;
const {
closeMoreDirectMessagesButton,
getUserAtIndex,
searchInput,
startButton,
} = MoreDirectMessagesScreen;
const {getChannelByDisplayName} = MainSidebar;
let testUser;
let testOtherUser;
beforeAll(async () => {
const {user, team} = await Setup.apiInit();
testUser = user;
({user: testOtherUser} = await User.apiCreateUser());
await Team.apiAddUserToTeam(testOtherUser.id, team.id);
// # Open channel screen
await ChannelScreen.open(user);
});
afterAll(async () => {
await ChannelScreen.logout();
});
it('MM-T1800 should remove closed DMs from main sidebar', async () => {
// # Create a DM with the other user
await openMainSidebar();
await MoreDirectMessagesScreen.open();
await searchInput.typeText(testOtherUser.username);
await getUserAtIndex(0).tap();
await startButton.tap();
// # Close DM channel
await goToChannel(testOtherUser.username);
await ChannelInfoScreen.open();
await ChannelInfoScreen.closeDirectOrGroupMessage();
// * Verify DM channel is removed
await openMainSidebar();
await expect(getChannelByDisplayName(testOtherUser.username)).not.toBeVisible();
// # Go back to channel
await closeMainSidebar();
});
it('MM-T442 should display full name / nickname on DM search result', async () => {
// # Set teammate name display to full name
await Preference.apiSaveTeammateNameDisplayPreference(testUser.id, 'full_name');
// # DM search other user
await openMainSidebar();
await MoreDirectMessagesScreen.open();
await searchInput.typeText(testOtherUser.username);
// * Verify search result contains other user's full name
await expect(element(by.text(`${testOtherUser.first_name} ${testOtherUser.last_name}`))).toBeVisible();
// # Set teammate name display to nickname
await Preference.apiSaveTeammateNameDisplayPreference(testUser.id, 'nickname_full_name');
// # DM search other user again
await searchInput.clearText();
await searchInput.typeText(testOtherUser.username);
// * Verify search result contains other user's nickname
await expect(element(by.text(testOtherUser.nickname))).toBeVisible();
// # Go back to channel
await closeMoreDirectMessagesButton.tap();
});
});