mattermost-mobile/detox/e2e/test/messaging/permalink.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

97 lines
3.7 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,
Post,
Setup,
User,
} from '@support/server_api';
import {
ChannelScreen,
PermalinkScreen,
} from '@support/ui/screen';
import {
timeouts,
wait,
} from '@support/utils';
describe('Permalink', () => {
let testUser;
let testChannel;
let townSquareChannel;
beforeAll(async () => {
const {user, team, channel} = await Setup.apiInit();
testUser = user;
testChannel = channel;
({channel: townSquareChannel} = await Channel.apiGetChannelByName(team.id, 'town-square'));
// # Open channel screen
await ChannelScreen.open(user);
});
afterAll(async () => {
await ChannelScreen.logout();
});
const expectPermalinkTargetMessage = async (permalinkTargetPost, permalinkTargetChannel) => {
// # Post a message in the test channel referencing the given permalink.
const permalinkLabel = `permalink-${Date.now().toString()}`;
const permalinkMessage = `[${permalinkLabel}](/_redirect/pl/${permalinkTargetPost.id})`;
await Post.apiCreatePost({
channelId: testChannel.id,
message: permalinkMessage,
});
// # Go to test channel
await ChannelScreen.goToChannel(testChannel.display_name);
// # Tap the channel permalink
await element(by.text(permalinkLabel)).tap({x: 5, y: 10});
await wait(timeouts.ONE_SEC);
// * Verify permalink post list has the expected target message
await PermalinkScreen.toBeVisible();
const {postListPostItem: permalinkPostItem} = await PermalinkScreen.getPostListPostItem(permalinkTargetPost.id, permalinkTargetPost.message);
await expect(permalinkPostItem).toBeVisible();
// # Dismiss the permalink screen by jumping to recent messages
await PermalinkScreen.jumpToRecentMessages();
// * Verify user is on channel where message is posted
await expect(ChannelScreen.channelNavBarTitle).toHaveText(permalinkTargetChannel.display_name);
const {postListPostItem: channelPostItem} = await ChannelScreen.getPostListPostItem(permalinkTargetPost.id, permalinkTargetPost.message);
await expect(channelPostItem).toBeVisible();
};
it('MM-T3805_1 should support _redirect to public channel post', async () => {
// # Post a test message in a public channel
const permalinkTargetMessage = 'post in Town Square';
const permalinkTargetPost = await Post.apiCreatePost({
channelId: townSquareChannel.id,
message: permalinkTargetMessage,
});
await expectPermalinkTargetMessage(permalinkTargetPost.post, townSquareChannel);
});
it('MM-T3805_2 should support _redirect to DM post', async () => {
// # Post a test message in a DM
const {user: dmOtherUser} = await User.apiCreateUser({prefix: 'testchannel-1'});
const {channel: directMessageChannel} = await Channel.apiCreateDirectChannel([testUser.id, dmOtherUser.id]);
const permalinkTargetMessage = 'post in DM';
const permalinkTargetPost = await Post.apiCreatePost({
channelId: directMessageChannel.id,
message: permalinkTargetMessage,
});
await expectPermalinkTargetMessage(permalinkTargetPost.post, directMessageChannel);
});
});