* MM-30289 Detox/E2E - Add e2e tests for MM-T3184 and MM-T3186
* Update detox/e2e/support/server_api/preference.js
Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
* MM-31322: redirect permalink handler (#5136)
* invert loadTeam.error test
* MM-31322: handle _redirect permalinks
In the webapp, [there is support](7c5a2e3bfd/components/root/root.jsx (L345-L352)) for a special `_redirect` team name in certain contexts that simply means, "the current team". It's used in the context of redirecting to the integrations backstage (not relevant for mobile), for also for resolving post permalinks.
This simplifies certain kinds of integrations which no longer have to know a team name to render a permanent link to a post. An example link looks like:
http://localhost:8065/_redirect/pl/e3sxrxtwh78jmxawsaqfemxoew
This PR adds support for same in mobile, unintentionally missed on the first round of implementation.
Fixes: https://mattermost.atlassian.net/browse/MM-31322
* Apply suggestions from code review
Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>
* linting issues
* Apply suggestions from code review
Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>
* revert showPermalink changes
* Revert "invert loadTeam.error test"
This reverts commit accf6c8fb7c56009a393a6e85084d4702deec9ed.
* support _redirect deeplinks
* Apply suggestions from code review
* Update app/components/post_list/index.js
Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>
Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
87 lines
3.7 KiB
JavaScript
87 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 {MainSidebar} from '@support/ui/component';
|
|
import {ChannelScreen, PermalinkScreen} from '@support/ui/screen';
|
|
import {User, Setup, Channel, Post} from '@support/server_api';
|
|
|
|
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.name, '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.openMainSidebar();
|
|
await MainSidebar.getChannelByDisplayName(testChannel.display_name).tap();
|
|
await ChannelScreen.toBeVisible();
|
|
|
|
// # Tap the channel permalink
|
|
await element(by.text(permalinkLabel)).tap({x: 5, y: 10});
|
|
|
|
// * 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);
|
|
});
|
|
});
|