Skip to content

Commit

Permalink
MM-30428 Detox/E2E: Add e2e for MM-T3199, MM-T3223, MM-T3224 (#5240)
Browse files Browse the repository at this point in the history
* MM-30428 Detox/E2E: Add e2e for MM-T3199, MM-T3223, MM-T3224

* Updated variables to better names
  • Loading branch information
Joseph Baylon authored Mar 24, 2021
1 parent e75d367 commit 48d4775
Show file tree
Hide file tree
Showing 19 changed files with 235 additions and 18 deletions.
8 changes: 7 additions & 1 deletion app/components/reactions/reaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ export default class Reaction extends PureComponent {
textStyle={{color: 'black', fontWeight: 'bold'}}
customEmojiStyle={{marginHorizontal: 3}}
padding={5}
testID={`reaction.emoji.${emojiName}`}
/>
<Text style={styles.count}>{count}</Text>
<Text
style={styles.count}
testID={`reaction.emoji.${emojiName}.count`}
>
{count}
</Text>
</TouchableWithFeedback>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports[`AddReaction should match snapshot 1`] = `
<Connect(EmojiPicker)
deviceWidth={750}
onEmojiPress={[Function]}
testID="add_reaction.emoji_picker"
/>
</View>
`;
1 change: 1 addition & 0 deletions app/screens/add_reaction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const AddReaction = (props) => {
<EmojiPicker
deviceWidth={width}
onEmojiPress={handleEmojiPress}
testID='add_reaction.emoji_picker'
/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ exports[`channel_info_header should match snapshot 1`] = `
"lineHeight": 20,
}
}
testID="channel_info.header.purpose"
>
Purpose string
</Text>
Expand Down Expand Up @@ -182,6 +183,7 @@ exports[`channel_info_header should match snapshot 1`] = `
disableGallery={true}
onChannelLinkPress={[MockFunction]}
onPermalinkPress={[MockFunction]}
testID="channel_info.header.header"
textStyles={
Object {
"code": Object {
Expand Down Expand Up @@ -453,6 +455,7 @@ exports[`channel_info_header should match snapshot when DM and hasGuests and is
"lineHeight": 20,
}
}
testID="channel_info.header.purpose"
>
Purpose string
</Text>
Expand Down Expand Up @@ -515,6 +518,7 @@ exports[`channel_info_header should match snapshot when DM and hasGuests and is
disableGallery={true}
onChannelLinkPress={[MockFunction]}
onPermalinkPress={[MockFunction]}
testID="channel_info.header.header"
textStyles={
Object {
"code": Object {
Expand Down Expand Up @@ -758,6 +762,7 @@ exports[`channel_info_header should match snapshot when DM and hasGuests but its
"lineHeight": 20,
}
}
testID="channel_info.header.purpose"
>
Purpose string
</Text>
Expand Down Expand Up @@ -820,6 +825,7 @@ exports[`channel_info_header should match snapshot when DM and hasGuests but its
disableGallery={true}
onChannelLinkPress={[MockFunction]}
onPermalinkPress={[MockFunction]}
testID="channel_info.header.header"
textStyles={
Object {
"code": Object {
Expand Down Expand Up @@ -1091,6 +1097,7 @@ exports[`channel_info_header should match snapshot when GM and hasGuests 1`] = `
"lineHeight": 20,
}
}
testID="channel_info.header.purpose"
>
Purpose string
</Text>
Expand Down Expand Up @@ -1153,6 +1160,7 @@ exports[`channel_info_header should match snapshot when GM and hasGuests 1`] = `
disableGallery={true}
onChannelLinkPress={[MockFunction]}
onPermalinkPress={[MockFunction]}
testID="channel_info.header.header"
textStyles={
Object {
"code": Object {
Expand Down Expand Up @@ -1396,6 +1404,7 @@ exports[`channel_info_header should match snapshot when is group constrained 1`]
"lineHeight": 20,
}
}
testID="channel_info.header.purpose"
>
Purpose string
</Text>
Expand Down Expand Up @@ -1458,6 +1467,7 @@ exports[`channel_info_header should match snapshot when is group constrained 1`]
disableGallery={true}
onChannelLinkPress={[MockFunction]}
onPermalinkPress={[MockFunction]}
testID="channel_info.header.header"
textStyles={
Object {
"code": Object {
Expand Down Expand Up @@ -1750,6 +1760,7 @@ exports[`channel_info_header should match snapshot when public channel and hasGu
"lineHeight": 20,
}
}
testID="channel_info.header.purpose"
>
Purpose string
</Text>
Expand Down Expand Up @@ -1812,6 +1823,7 @@ exports[`channel_info_header should match snapshot when public channel and hasGu
disableGallery={true}
onChannelLinkPress={[MockFunction]}
onPermalinkPress={[MockFunction]}
testID="channel_info.header.header"
textStyles={
Object {
"code": Object {
Expand Down
6 changes: 5 additions & 1 deletion app/screens/channel_info/channel_info_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ export default class ChannelInfoHeader extends React.PureComponent {
id='channel_info.purpose'
defaultMessage='Purpose'
/>
<Text style={baseTextStyle}>
<Text
style={baseTextStyle}
testID={`${testID}.purpose`}
>
{purpose}
</Text>
</View>
Expand Down Expand Up @@ -216,6 +219,7 @@ export default class ChannelInfoHeader extends React.PureComponent {
value={header}
onChannelLinkPress={popToRoot}
disableAtChannelMentionHighlight={true}
testID={`${testID}.header`}
/>
</View>
</TouchableHighlight>
Expand Down
2 changes: 1 addition & 1 deletion detox/e2e/support/ui/component/post_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PostOptions {
slideUpPanel = element(by.id(this.testID.slideUpPanel));

toBeVisible = async () => {
await expect(this.postOptions).toBeVisible();
await expect(this.postOptions).toExist();

return postOptions;
}
Expand Down
12 changes: 11 additions & 1 deletion detox/e2e/support/ui/screen/add_reaction.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {PostOptions} from '@support/ui/component';
import {
PostOptions,
SearchBar,
} from '@support/ui/component';

class AddReactionScreen {
testID = {
addReactionScreen: 'add_reaction.screen',
addReactionEmojiPickerPrefix: 'add_reaction.emoji_picker.',
closeAddReactionButton: 'close.add_reaction.button',
}

addReactionScreen = element(by.id(this.testID.addReactionScreen));
closeAddReactionButton = element(by.id(this.testID.closeAddReactionButton));

// convenience props
searchBar = SearchBar.getSearchBar(this.testID.addReactionEmojiPickerPrefix);
searchInput = SearchBar.getSearchInput(this.testID.addReactionEmojiPickerPrefix);
cancelButton = SearchBar.getCancelButton(this.testID.addReactionEmojiPickerPrefix);
clearButton = SearchBar.getClearButton(this.testID.addReactionEmojiPickerPrefix);

toBeVisible = async () => {
await expect(this.addReactionScreen).toBeVisible();

Expand Down
12 changes: 8 additions & 4 deletions detox/e2e/support/ui/screen/channel_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ class ChannelInfoScreen {
channelInfoScreen: 'channel_info.screen',
channelInfoScrollView: 'channel_info.scroll_view',
closeChannelInfoButton: 'close.channel_info.button',
headerChannelIconGMMemberCount: 'channel_info.header.channel_icon.gm_member_count',
headerDisplayName: 'channel_info.header.display_name',
channelIconGMMemberCount: 'channel_info.header.channel_icon.gm_member_count',
channelDisplayName: 'channel_info.header.display_name',
channelHeader: 'channel_info.header.header',
channelPurpose: 'channel_info.header.purpose',
favoritePreferenceAction: 'channel_info.favorite.action',
favoriteSwitchFalse: 'channel_info.favorite.action.switch.false',
favoriteSwitchTrue: 'channel_info.favorite.action.switch.true',
Expand All @@ -34,8 +36,10 @@ class ChannelInfoScreen {
channelInfoScreen = element(by.id(this.testID.channelInfoScreen));
channelInfoScrollView = element(by.id(this.testID.channelInfoScrollView));
closeChannelInfoButton = element(by.id(this.testID.closeChannelInfoButton));
headerChannelIconGMMemberCount = element(by.id(this.testID.headerChannelIconGMMemberCount));
headerDisplayName = element(by.id(this.testID.headerDisplayName));
channelIconGMMemberCount = element(by.id(this.testID.channelIconGMMemberCount));
channelDisplayName = element(by.id(this.testID.channelDisplayName));
channelHeader = element(by.id('markdown_text').withAncestor(by.id(this.testID.channelHeader)));
channelPurpose = element(by.id(this.testID.channelPurpose));
favoritePreferenceAction = element(by.id(this.testID.favoritePreferenceAction));
favoriteSwitchFalse = element(by.id(this.testID.favoriteSwitchFalse));
favoriteSwitchTrue = element(by.id(this.testID.favoriteSwitchTrue));
Expand Down
2 changes: 1 addition & 1 deletion detox/e2e/test/channel_info/header.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Channel Info Header', () => {
await ChannelInfoScreen.open();

// * Verify GM member count is 3
await expect(ChannelInfoScreen.headerChannelIconGMMemberCount).toHaveText('3');
await expect(ChannelInfoScreen.channelIconGMMemberCount).toHaveText('3');

// # Close channel info screen
await ChannelInfoScreen.close();
Expand Down
2 changes: 1 addition & 1 deletion detox/e2e/test/guest_account/guest_experience.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Guest Experience', () => {
await expect(postListPostItemHeaderGuestTag).not.toBeVisible();
});

it('MM-T1397 Guest tag in search in:', async () => {
xit('MM-T1397 Guest tag in search in:', async () => { // Disabled due to https://mattermost.atlassian.net/browse/MM-33854
const {
getSearchResultPostItem,
searchInSection,
Expand Down
17 changes: 15 additions & 2 deletions detox/e2e/test/messaging/permalink.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@
// - Use element testID when selecting an element. Create one if none.
// *******************************************************************

import {ChannelScreen, PermalinkScreen} from '@support/ui/screen';
import {User, Setup, Channel, Post} from '@support/server_api';
import {
ChannelScreen,
PermalinkScreen,
} from '@support/ui/screen';
import {
timeouts,
wait,
} from '@support/utils';
import {
Channel,
Post,
Setup,
User,
} from '@support/server_api';

describe('Permalink', () => {
let testUser;
Expand Down Expand Up @@ -43,6 +55,7 @@ describe('Permalink', () => {

// # 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
import {
getAdminAccount,
getRandomId,
timeouts,
wait,
} from '@support/utils';

describe('Messaging', () => {
Expand Down Expand Up @@ -63,7 +65,7 @@ describe('Messaging', () => {
const channelPermalink = `${serverUrl}/${testTeam.name}/channels/${testChannel.name}`;

// # Post the channel permalink to the test channel in Town Square
await postMessage(channelPermalink, {quickReplace: true});
await postMessage(channelPermalink);
await expect(element(by.text(channelPermalink))).toBeVisible();

// # Create another user in the same team, log in and go to town square
Expand Down Expand Up @@ -114,7 +116,7 @@ describe('Messaging', () => {

// # Post Private Channel 2's POST Permalink
const message2 = `${serverUrl}/${testTeam.name}/pl/${post.id}`;
await postMessage(message2, {quickReplace: true});
await postMessage(message2);

// * Check that message is successfully posted
await expect(element(by.text(message2))).toExist();
Expand Down Expand Up @@ -186,4 +188,5 @@ async function joinPrivateChannel() {
async function tapLink(message) {
const permalinkPost = element(by.text(message));
await permalinkPost.tap({x: 5, y: 10});
await wait(timeouts.ONE_SEC);
}
96 changes: 96 additions & 0 deletions detox/e2e/test/smoke_test/add_reaction.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// 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 {
AddReactionScreen,
ChannelScreen,
} from '@support/ui/screen';
import {
Channel,
Post,
Setup,
Team,
User,
} from '@support/server_api';

describe('Add Reaction', () => {
let testChannel;
let testOtherUser;

beforeAll(async () => {
const {team, user} = await Setup.apiInit();

({channel: testChannel} = await Channel.apiGetChannelByName(team.name, 'town-square'));

({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-T3223 should be able to add a reaction to a post using long press and +:', async () => {
const {
openPostOptionsFor,
postMessage,
} = ChannelScreen;
const {searchInput} = AddReactionScreen;

// # Post a message
const message = Date.now().toString();
await postMessage(message);

// # Add a reaction to the post using long press
const {post} = await Post.apiGetLastPostInChannel(testChannel.id);
await openPostOptionsFor(post.id, message);
await AddReactionScreen.open();
await searchInput.typeText(':fox_face:');
await element(by.text('🦊')).tap();

// # Add a reaction to the post using +:
await postMessage('+:dog:');

// * Verify emojis are added to post
await expect(element(by.text('🦊').withAncestor(by.id(`channel.post_list.post.${post.id}`)))).toExist();
await expect(element(by.text('🐶').withAncestor(by.id(`channel.post_list.post.${post.id}`)))).toExist();

// * Verify emoji exists in recently used section
await openPostOptionsFor(post.id, message);
await AddReactionScreen.open();
await expect(element(by.text('🦊').withAncestor(by.id('RECENTLY USED')))).toExist();
await expect(element(by.text('🐶').withAncestor(by.id('RECENTLY USED')))).toExist();

// # Close add reaction screen
await AddReactionScreen.close();
});

it('MM-T3224 should be able to remove own reaction and add to another user reaction', async () => {
// # Tap on own reaction to remove
await element(by.text('🦊')).tap();

// * Verify own reaction is removed
const {post} = await Post.apiGetLastPostInChannel(testChannel.id);
await expect(element(by.text('🦊').withAncestor(by.id(`channel.post_list.post.${post.id}`)))).not.toExist();

// # Login as new user
await ChannelScreen.logout();
await ChannelScreen.open(testOtherUser);

// # Add the same existing reaction
await expect(element(by.id('reaction.emoji.dog.count'))).toHaveText('1');
await element(by.text('🐶')).tap();

// * Verify count incremented
await expect(element(by.id('reaction.emoji.dog.count'))).toHaveText('2');
});
});
1 change: 1 addition & 0 deletions detox/e2e/test/smoke_test/channels.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe('Channels', () => {
({channel: nonJoinedChannel} = await Channel.apiCreateChannel({type: 'O', prefix: '1-non-joined-channel', teamId: team.id}));

({user: dmOtherUser} = await User.apiCreateUser({prefix: 'testchannel-1'}));
await Team.apiAddUserToTeam(dmOtherUser.id, team.id);
({channel: directMessageChannel} = await Channel.apiCreateDirectChannel([user.id, dmOtherUser.id]));
await Post.apiCreatePost({
channelId: directMessageChannel.id,
Expand Down
Loading

0 comments on commit 48d4775

Please sign in to comment.