Detox android fix smoke tests (#7193)

* Detox: Android - fix smoke tests.

* Detox: Android - Fix latency related tests.

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Elisabeth Kulzer
2023-03-11 13:08:17 +01:00
committed by GitHub
parent bdaba41df1
commit fcb1db660c
15 changed files with 124 additions and 36 deletions

Binary file not shown.

View File

@@ -81,6 +81,7 @@ class AccountScreen {
open = async () => {
// # Open account screen
await waitFor(HomeScreen.accountTab).toBeVisible().withTimeout(timeouts.TWO_SEC);
await HomeScreen.accountTab.tap();
return this.toBeVisible();
@@ -92,7 +93,7 @@ class AccountScreen {
await expect(Alert.logoutTitle(serverDisplayName)).toBeVisible();
}
await Alert.logoutButton.tap();
await expect(this.accountScreen).not.toBeVisible();
await waitFor(this.accountScreen).not.toBeVisible().withTimeout(timeouts.TEN_SEC);
};
}

View File

@@ -6,7 +6,7 @@ import {
ProfilePicture,
} from '@support/ui/component';
import {ChannelScreen} from '@support/ui/screen';
import {timeouts, wait} from '@support/utils';
import {isAndroid, timeouts, wait} from '@support/utils';
import {expect} from 'detox';
class ChannelInfoScreen {
@@ -98,6 +98,7 @@ class ChannelInfoScreen {
open = async () => {
// # Open channel info screen
await waitFor(ChannelScreen.headerTitle).toBeVisible().withTimeout(timeouts.TEN_SEC);
await ChannelScreen.headerTitle.tap();
return this.toBeVisible();
@@ -165,6 +166,9 @@ class ChannelInfoScreen {
leaveChannel = async ({confirm = true} = {}) => {
await waitFor(this.leaveChannelOption).toExist().withTimeout(timeouts.TWO_SEC);
if (isAndroid()) {
await this.scrollView.scrollTo('bottom');
}
await this.leaveChannelOption.tap({x: 1, y: 1});
const {
leaveChannelTitle,

View File

@@ -58,6 +58,7 @@ describe('Channels - Archive Channel', () => {
// # Open a public channel screen, open channel info screen, and tap on archive channel option and confirm
const {channel: publicChannel} = await Channel.apiCreateChannel(siteOneUrl, {type: 'O', teamId: testTeam.id});
await Channel.apiAddUserToChannel(siteOneUrl, testUser.id, publicChannel.id);
await wait(timeouts.TWO_SEC);
await device.reloadReactNative();
await ChannelScreen.open(channelsCategory, publicChannel.name);
await ChannelInfoScreen.open();
@@ -88,6 +89,7 @@ describe('Channels - Archive Channel', () => {
// # Open a public channel screen, open channel info screen, and tap on archive channel option and cancel
const {channel: publicChannel} = await Channel.apiCreateChannel(siteOneUrl, {type: 'O', teamId: testTeam.id});
await Channel.apiAddUserToChannel(siteOneUrl, testUser.id, publicChannel.id);
await wait(timeouts.TWO_SEC);
await device.reloadReactNative();
await ChannelScreen.open(channelsCategory, publicChannel.name);
await ChannelInfoScreen.open();
@@ -105,6 +107,7 @@ describe('Channels - Archive Channel', () => {
// # Open a private channel screen, open channel info screen, and tap on archive channel option and confirm
const {channel: privateChannel} = await Channel.apiCreateChannel(siteOneUrl, {type: 'P', teamId: testTeam.id});
await Channel.apiAddUserToChannel(siteOneUrl, testUser.id, privateChannel.id);
await wait(timeouts.TWO_SEC);
await device.reloadReactNative();
await ChannelScreen.open(channelsCategory, privateChannel.name);
await ChannelInfoScreen.open();

View File

@@ -64,6 +64,7 @@ describe('Channels - Channel Info', () => {
await expect(ChannelInfoScreen.pinnedMessagesOption).toBeVisible();
await expect(ChannelInfoScreen.copyChannelLinkOption).toBeVisible();
await expect(ChannelInfoScreen.editChannelOption).toBeVisible();
await ChannelInfoScreen.scrollView.scrollTo('bottom');
await expect(ChannelInfoScreen.leaveChannelOption).toBeVisible();
await waitFor(ChannelInfoScreen.archiveChannelOption).toBeVisible().whileElement(by.id(ChannelInfoScreen.testID.scrollView)).scroll(50, 'down');
await expect(ChannelInfoScreen.archiveChannelOption).toBeVisible();

View File

@@ -23,7 +23,7 @@ import {
PostOptionsScreen,
ServerScreen,
} from '@support/ui/screen';
import {getRandomId} from '@support/utils';
import {getRandomId, isAndroid} from '@support/utils';
import {expect} from 'detox';
describe('Channels - Channel Post List', () => {
@@ -52,6 +52,10 @@ describe('Channels - Channel Post List', () => {
it('MM-T4773_1 - should match elements on channel screen', async () => {
// # Open a channel screen
await ChannelScreen.open('channels', testChannel.name);
if (isAndroid()) {
await ChannelScreen.back();
await ChannelScreen.open('channels', testChannel.name);
}
// * Verify basic elements on channel screen
await expect(ChannelScreen.backButton).toBeVisible();
@@ -77,6 +81,10 @@ describe('Channels - Channel Post List', () => {
// # Open a channel screen and post a message
const message = `Message ${getRandomId()}`;
await ChannelScreen.open('channels', testChannel.name);
if (isAndroid()) {
await ChannelScreen.back();
await ChannelScreen.open('channels', testChannel.name);
}
await ChannelScreen.postMessage(message);
// * Verify message is added to post list

View File

@@ -7,7 +7,7 @@
// - Use element testID when selecting an element. Create one if none.
// *******************************************************************
import {serverOneUrl} from '@support/test_config';
import {siteOneUrl} from '@support/test_config';
import {
ChannelScreen,
ChannelListScreen,
@@ -17,21 +17,21 @@ import {
ServerScreen,
ChannelInfoScreen,
} from '@support/ui/screen';
import {getAdminAccount, getRandomId} from '@support/utils';
import {getAdminAccount, getRandomId, timeouts} from '@support/utils';
import {expect} from 'detox';
describe('Channels - Convert to Private Channel', () => {
const serverOneDisplayName = 'Server 1';
const siteOneDisplayName = 'Server 1';
beforeAll(async () => {
// # Log in to server as admin
await ServerScreen.connectToServer(serverOneUrl, serverOneDisplayName);
await ServerScreen.connectToServer(siteOneUrl, siteOneDisplayName);
await LoginScreen.login(getAdminAccount());
});
beforeEach(async () => {
// * Verify on channel list screen
await ChannelListScreen.toBeVisible();
await waitFor(ChannelListScreen.channelListScreen).toBeVisible().withTimeout(timeouts.TWO_MIN);
});
afterAll(async () => {

View File

@@ -81,9 +81,10 @@ describe('Channels - Mute and Unmute Channel', () => {
// * Verify channel is muted
await expect(ChannelInfoScreen.unmuteAction).toBeVisible();
await wait(timeouts.FOUR_SEC);
// # Tap on muted action to unmute the channel
await ChannelInfoScreen.unmuteAction.tap();
await ChannelInfoScreen.unmuteAction.longPress();
// * Verify channel is unmuted
await expect(ChannelInfoScreen.muteAction).toBeVisible();

View File

@@ -17,7 +17,7 @@ import {
ServerScreen,
ChannelInfoScreen,
} from '@support/ui/screen';
import {getAdminAccount, getRandomId} from '@support/utils';
import {getAdminAccount, getRandomId, timeouts} from '@support/utils';
import {expect} from 'detox';
describe('Channels - Unarchive Channel', () => {
@@ -32,7 +32,7 @@ describe('Channels - Unarchive Channel', () => {
beforeEach(async () => {
// * Verify on channel list screen
await ChannelListScreen.toBeVisible();
await waitFor(ChannelListScreen.channelListScreen).toBeVisible().withTimeout(timeouts.TWO_MIN);
});
afterAll(async () => {

View File

@@ -23,7 +23,7 @@ import {
PostOptionsScreen,
ServerScreen,
} from '@support/ui/screen';
import {getRandomId} from '@support/utils';
import {getRandomId, timeouts} from '@support/utils';
import {expect} from 'detox';
describe('Messaging - Follow and Unfollow Message', () => {
@@ -67,14 +67,14 @@ describe('Messaging - Follow and Unfollow Message', () => {
// * Verify message is followed by user via post footer
const {postListPostItemFooterFollowingButton} = ChannelScreen.getPostListPostItem(post.id, message);
await expect(postListPostItemFooterFollowingButton).toBeVisible();
await waitFor(postListPostItemFooterFollowingButton).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Open post options for message and tap on unfollow message option
await ChannelScreen.openPostOptionsFor(post.id, message);
await PostOptionsScreen.followingThreadOption.tap();
// * Verify message is not followed by user via post footer
await expect(postListPostItemFooterFollowingButton).not.toBeVisible();
await waitFor(postListPostItemFooterFollowingButton).not.toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Go back to channel list screen
await ChannelScreen.back();
@@ -91,13 +91,13 @@ describe('Messaging - Follow and Unfollow Message', () => {
// * Verify message is followed by user via post footer
const {postListPostItemFooterFollowingButton} = ChannelScreen.getPostListPostItem(post.id, message);
await expect(postListPostItemFooterFollowingButton).toBeVisible();
await waitFor(postListPostItemFooterFollowingButton).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Tap on following button via post footer
await postListPostItemFooterFollowingButton.tap();
// * Verify message is not followed by user via post footer
await expect(postListPostItemFooterFollowingButton).not.toBeVisible();
await waitFor(postListPostItemFooterFollowingButton).not.toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Go back to channel list screen
await ChannelScreen.back();

View File

@@ -30,7 +30,7 @@ import {
ServerScreen,
ServerListScreen,
} from '@support/ui/screen';
import {timeouts, wait} from '@support/utils';
import {isAndroid, isIos, timeouts, wait} from '@support/utils';
import {expect} from 'detox';
describe('Server Login - Server List', () => {
@@ -98,7 +98,12 @@ describe('Server Login - Server List', () => {
// # Open server list screen
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
// * Verify second server is active and first server is inactive
await waitFor(ServerListScreen.getServerItemActive(serverTwoDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
@@ -118,7 +123,12 @@ describe('Server Login - Server List', () => {
// # Open server list screen
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
// * Verify third server is active, and first and second servers are inactive
await waitFor(ServerListScreen.getServerItemActive(serverThreeDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
@@ -135,7 +145,12 @@ describe('Server Login - Server List', () => {
// # Open server list screen and tap on third server
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await waitFor(ServerListScreen.getServerItemInactive(serverThreeDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
await ServerListScreen.getServerItemInactive(serverThreeDisplayName).tap();
@@ -145,7 +160,12 @@ describe('Server Login - Server List', () => {
// # Open server list screen and go back to first server
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await waitFor(ServerListScreen.getServerItemInactive(serverOneDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
await ServerListScreen.getServerItemInactive(serverOneDisplayName).tap();
});
@@ -156,7 +176,12 @@ describe('Server Login - Server List', () => {
// # Open server list screen, swipe left on first server and tap on edit option
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await waitFor(ServerListScreen.getServerItemActive(serverOneDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
await ServerListScreen.getServerItemActive(serverOneDisplayName).swipe('left');
await ServerListScreen.getServerItemEditOption(serverOneDisplayName).tap();
@@ -197,7 +222,12 @@ describe('Server Login - Server List', () => {
// # Open server list screen, swipe left on first server and tap on remove option
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await waitFor(ServerListScreen.getServerItemActive(serverOneDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
await ServerListScreen.getServerItemActive(serverOneDisplayName).swipe('left');
await ServerListScreen.getServerItemRemoveOption(serverOneDisplayName).tap();
@@ -209,7 +239,12 @@ describe('Server Login - Server List', () => {
await Alert.removeButton3.tap();
await wait(timeouts.ONE_SEC);
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
// * Verify first server is removed
await expect(ServerListScreen.getServerItemActive(serverOneDisplayName)).not.toExist();
@@ -228,7 +263,12 @@ describe('Server Login - Server List', () => {
// # Open server list screen, swipe left on third server and tap on logout option
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await waitFor(ServerListScreen.getServerItemInactive(serverThreeDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
await ServerListScreen.getServerItemInactive(serverThreeDisplayName).swipe('left');
await ServerListScreen.getServerItemLogoutOption(serverThreeDisplayName).tap();
@@ -253,12 +293,27 @@ describe('Server Login - Server List', () => {
// # Open server list screen, attempt to add a server already logged in and with inactive session
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
// await ServerListScreen.closeTutorial();
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await ServerListScreen.addServerButton.tap();
await expect(ServerScreen.headerTitleAddServer).toBeVisible();
await ServerScreen.serverUrlInput.replaceText(serverTwoUrl);
if (isAndroid()) {
await ServerScreen.serverUrlInput.tapReturnKey();
}
await ServerScreen.serverDisplayNameInput.replaceText(serverTwoDisplayName);
await ServerScreen.tapConnectButton();
if (isAndroid()) {
await ServerScreen.serverDisplayNameInput.tapReturnKey();
}
if (isIos()) {
await ServerScreen.tapConnectButton();
}
// * Verify same name server error
const sameNameServerError = 'You are using this name for another server.';
@@ -266,8 +321,17 @@ describe('Server Login - Server List', () => {
// # Attempt to add a server already logged in and with active session, with the same server display name
await ServerScreen.serverUrlInput.replaceText(serverOneUrl);
if (isAndroid()) {
await ServerScreen.serverUrlInput.tapReturnKey();
}
await ServerScreen.serverDisplayNameInput.replaceText(serverOneDisplayName);
await ServerScreen.tapConnectButton();
if (isAndroid()) {
await ServerScreen.serverDisplayNameInput.tapReturnKey();
}
if (isIos()) {
await ServerScreen.tapConnectButton();
}
// * Verify same name server error
await expect(ServerScreen.serverDisplayNameInputError).toHaveText(sameNameServerError);
@@ -275,7 +339,12 @@ describe('Server Login - Server List', () => {
// # Close server screen, open server list screen, log out of second server, and go back to first server
await ServerScreen.close();
await ServerListScreen.open();
await ServerListScreen.serverListScreen.swipe('up');
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await waitFor(ServerListScreen.getServerItemInactive(serverTwoDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);
await ServerListScreen.getServerItemInactive(serverTwoDisplayName).swipe('left');
await ServerListScreen.getServerItemLogoutOption(serverTwoDisplayName).tap();

View File

@@ -81,7 +81,6 @@ describe('Smoke Test - Channels', () => {
// * Verify on the other channel screen
await ChannelScreen.toBeVisible();
await expect(ChannelScreen.headerTitle).toHaveText(testChannel.display_name);
await expect(ChannelScreen.introDisplayName).toHaveText(testChannel.display_name);
// # Go back to channel list screen
await ChannelScreen.back();
@@ -189,6 +188,7 @@ describe('Smoke Test - Channels', () => {
// # Open a channel screen, open channel info screen, and tap on archive channel option and confirm
const {channel} = await Channel.apiCreateChannel(siteOneUrl, {teamId: testTeam.id});
await Channel.apiAddUserToChannel(siteOneUrl, testUser.id, channel.id);
await wait(timeouts.TWO_SEC);
await device.reloadReactNative();
await ChannelScreen.open(channelsCategory, channel.name);
await ChannelInfoScreen.open();

View File

@@ -144,7 +144,7 @@ describe('Smoke Test - Messaging', () => {
await element(by.text('🤡')).tap();
// * Verify reaction is added to the message
await expect(element(by.text('🤡').withAncestor(by.id(`channel.post_list.post.${post.id}`)))).toBeVisible();
await waitFor(element(by.text('🤡').withAncestor(by.id(`channel.post_list.post.${post.id}`)))).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Go back to channel list screen
await ChannelScreen.back();
@@ -161,7 +161,7 @@ describe('Smoke Test - Messaging', () => {
// * Verify message is followed by user via post footer
const {postListPostItem, postListPostItemFooterFollowingButton} = ChannelScreen.getPostListPostItem(post.id, message);
await expect(postListPostItemFooterFollowingButton).toBeVisible();
await waitFor(postListPostItemFooterFollowingButton).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Tap on following button via post footer
await postListPostItemFooterFollowingButton.tap();

View File

@@ -90,6 +90,7 @@ describe('Smoke Test - Server Login', () => {
if (isIos()) {
await ServerListScreen.serverListTitle.swipe('up');
} else if (isAndroid()) {
await waitFor(ServerListScreen.serverListTitle).toBeVisible().withTimeout(timeouts.TWO_SEC);
await ServerListScreen.serverListTitle.swipe('up', 'fast', 0.1, 0.5, 0.3);
}
await waitFor(ServerListScreen.getServerItemInactive(serverTwoDisplayName)).toBeVisible().withTimeout(timeouts.TEN_SEC);

View File

@@ -131,7 +131,7 @@ describe('Threads - Follow and Unfollow Thread', () => {
// * Verify thread is not followed by user via post footer
const {postListPostItemFooterFollowButton, postListPostItemFooterFollowingButton} = ChannelScreen.getPostListPostItem(parentPost.id, parentMessage);
await expect(postListPostItemFooterFollowButton).toBeVisible();
await waitFor(postListPostItemFooterFollowButton).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Open post options for thread
await ChannelScreen.openPostOptionsFor(parentPost.id, parentMessage);
@@ -143,13 +143,13 @@ describe('Threads - Follow and Unfollow Thread', () => {
await PostOptionsScreen.followThreadOption.tap();
// * Verify thread is followed by user via post footer
await expect(postListPostItemFooterFollowingButton).toBeVisible();
await waitFor(postListPostItemFooterFollowingButton).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Open post options for thread
await ChannelScreen.openPostOptionsFor(parentPost.id, parentMessage);
// * Verify thread is followed by user via post options
await expect(PostOptionsScreen.followingThreadOption).toBeVisible();
await waitFor(PostOptionsScreen.followingThreadOption).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Go back to channel list screen
await PostOptionsScreen.close();
@@ -177,7 +177,7 @@ describe('Threads - Follow and Unfollow Thread', () => {
await GlobalThreadsScreen.openThreadOptionsFor(parentPost.id);
// * Verify thread is followed by user via thread options
await expect(ThreadOptionsScreen.followingThreadOption).toBeVisible();
await waitFor(ThreadOptionsScreen.followingThreadOption).toBeVisible().withTimeout(timeouts.TWO_SEC);
// # Tap on unfollow thread option
await ThreadOptionsScreen.followingThreadOption.tap();