forked from Ivasoft/mattermost-mobile
Detox/E2E: Convert to private channel e2e tests in Gekidou (#6563)
* Detox/E2E: Convert to private channel e2e tests in Gekidou * Fix tests * Fix typo Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,16 @@ class Alert {
|
||||
confirmSendingNotificationsTitle = isAndroid() ? element(by.text('Confirm sending notifications to entire channel')) : element(by.label('Confirm sending notifications to entire channel')).atIndex(0);
|
||||
archivePrivateChannelTitle = isAndroid() ? element(by.text('Archive Private Channel')) : element(by.label('Archive Private Channel')).atIndex(0);
|
||||
archivePublicChannelTitle = isAndroid() ? element(by.text('Archive Public Channel')) : element(by.label('Archive Public Channel')).atIndex(0);
|
||||
channelNowPrivateTitle = (channelDisplayName: string) => {
|
||||
const title = `${channelDisplayName} is now a private channel.`;
|
||||
|
||||
return isAndroid() ? element(by.text(title)) : element(by.label(title)).atIndex(0);
|
||||
};
|
||||
convertToPrivateChannelTitle = (channelDisplayName: string) => {
|
||||
const title = `Convert ${channelDisplayName} to a private channel?`;
|
||||
|
||||
return isAndroid() ? element(by.text(title)) : element(by.label(title)).atIndex(0);
|
||||
};
|
||||
deletePostTitle = isAndroid() ? element(by.text('Delete Post')) : element(by.label('Delete Post')).atIndex(0);
|
||||
leaveChannelTitle = isAndroid() ? element(by.text('Leave channel')) : element(by.label('Leave channel')).atIndex(0);
|
||||
logoutTitle = (serverDisplayName: string) => {
|
||||
@@ -33,9 +43,11 @@ class Alert {
|
||||
logoutButton = isAndroid() ? element(by.text('LOG OUT')) : element(by.label('Log out')).atIndex(1);
|
||||
markReadButton = isAndroid() ? element(by.text('MARK READ')) : element(by.label('Mark read')).atIndex(1);
|
||||
noButton = isAndroid() ? element(by.text('NO')) : element(by.label('No')).atIndex(0);
|
||||
noButton2 = isAndroid() ? element(by.text('NO')) : element(by.label('No')).atIndex(1);
|
||||
okButton = isAndroid() ? element(by.text('OK')) : element(by.label('OK')).atIndex(1);
|
||||
removeButton = isAndroid() ? element(by.text('REMOVE')) : element(by.label('Remove')).atIndex(1);
|
||||
yesButton = isAndroid() ? element(by.text('YES')) : element(by.label('Yes')).atIndex(0);
|
||||
yesButton2 = isAndroid() ? element(by.text('YES')) : element(by.label('Yes')).atIndex(1);
|
||||
}
|
||||
|
||||
const alert = new Alert();
|
||||
|
||||
@@ -105,7 +105,6 @@ class ChannelInfoScreen {
|
||||
};
|
||||
|
||||
archiveChannel = async (alertArchiveChannelTitle: Detox.NativeElement, {confirm = true} = {}) => {
|
||||
await this.scrollView.scrollTo('bottom');
|
||||
await waitFor(this.archiveChannelOption).toExist().withTimeout(timeouts.TWO_SEC);
|
||||
await this.archiveChannelOption.tap({x: 1, y: 1});
|
||||
const {
|
||||
@@ -134,8 +133,33 @@ class ChannelInfoScreen {
|
||||
await this.archiveChannel(Alert.archivePublicChannelTitle, {confirm});
|
||||
};
|
||||
|
||||
convertToPrivateChannel = async (channelDisplayName: string, {confirm = true} = {}) => {
|
||||
await waitFor(this.convertPrivateOption).toExist().withTimeout(timeouts.TWO_SEC);
|
||||
await this.convertPrivateOption.tap({x: 1, y: 1});
|
||||
const {
|
||||
channelNowPrivateTitle,
|
||||
convertToPrivateChannelTitle,
|
||||
noButton2,
|
||||
okButton,
|
||||
yesButton2,
|
||||
} = Alert;
|
||||
await expect(convertToPrivateChannelTitle(channelDisplayName)).toBeVisible();
|
||||
await expect(noButton2).toBeVisible();
|
||||
await expect(yesButton2).toBeVisible();
|
||||
if (confirm) {
|
||||
await yesButton2.tap();
|
||||
await expect(channelNowPrivateTitle(channelDisplayName)).toBeVisible();
|
||||
await okButton.tap();
|
||||
await wait(timeouts.ONE_SEC);
|
||||
await expect(this.channelInfoScreen).toExist();
|
||||
} else {
|
||||
await noButton2.tap();
|
||||
await wait(timeouts.ONE_SEC);
|
||||
await expect(this.channelInfoScreen).toExist();
|
||||
}
|
||||
};
|
||||
|
||||
leaveChannel = async ({confirm = true} = {}) => {
|
||||
await this.scrollView.scrollTo('bottom');
|
||||
await waitFor(this.leaveChannelOption).toExist().withTimeout(timeouts.TWO_SEC);
|
||||
await this.leaveChannelOption.tap({x: 1, y: 1});
|
||||
const {
|
||||
@@ -168,7 +192,6 @@ class ChannelInfoScreen {
|
||||
};
|
||||
|
||||
unarchiveChannel = async (alertUnarchiveChannelTitle: Detox.NativeElement, {confirm = true} = {}) => {
|
||||
await this.scrollView.scrollTo('bottom');
|
||||
await waitFor(this.unarchiveChannelOption).toExist().withTimeout(timeouts.TWO_SEC);
|
||||
await this.unarchiveChannelOption.tap({x: 1, y: 1});
|
||||
const {
|
||||
|
||||
77
detox/e2e/test/channels/convert_to_private_channel.e2e.ts
Normal file
77
detox/e2e/test/channels/convert_to_private_channel.e2e.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
// 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 {serverOneUrl} from '@support/test_config';
|
||||
import {
|
||||
ChannelScreen,
|
||||
ChannelListScreen,
|
||||
CreateOrEditChannelScreen,
|
||||
HomeScreen,
|
||||
LoginScreen,
|
||||
ServerScreen,
|
||||
ChannelInfoScreen,
|
||||
} from '@support/ui/screen';
|
||||
import {getAdminAccount, getRandomId} from '@support/utils';
|
||||
import {expect} from 'detox';
|
||||
|
||||
describe('Channels - Convert to Private Channel', () => {
|
||||
const serverOneDisplayName = 'Server 1';
|
||||
|
||||
beforeAll(async () => {
|
||||
// # Log in to server as admin
|
||||
await ServerScreen.connectToServer(serverOneUrl, serverOneDisplayName);
|
||||
await LoginScreen.login(getAdminAccount());
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
// * Verify on channel list screen
|
||||
await ChannelListScreen.toBeVisible();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
// # Log out
|
||||
await HomeScreen.logout();
|
||||
});
|
||||
|
||||
it('MM-T4972_1 - should be able to convert public channel to private and confirm', async () => {
|
||||
// # Create a public channel screen, open channel info screen, and tap on convert to private channel option and confirm
|
||||
const channelDisplayName = `Channel ${getRandomId()}`;
|
||||
await CreateOrEditChannelScreen.openCreateChannel();
|
||||
await CreateOrEditChannelScreen.displayNameInput.replaceText(channelDisplayName);
|
||||
await CreateOrEditChannelScreen.createButton.tap();
|
||||
await ChannelInfoScreen.open();
|
||||
await ChannelInfoScreen.convertToPrivateChannel(channelDisplayName, {confirm: true});
|
||||
|
||||
// * Verify on channel info screen and convert to private channel option does not exist
|
||||
await ChannelInfoScreen.toBeVisible();
|
||||
await expect(ChannelInfoScreen.convertPrivateOption).not.toExist();
|
||||
|
||||
// # Go back to channel list screen
|
||||
await ChannelInfoScreen.close();
|
||||
await ChannelScreen.back();
|
||||
});
|
||||
|
||||
it('MM-T4972_2 - should be able to convert public channel to private and cancel', async () => {
|
||||
// # Create a public channel screen, open channel info screen, and tap on convert to private channel option and cancel
|
||||
const channelDisplayName = `Channel ${getRandomId()}`;
|
||||
await CreateOrEditChannelScreen.openCreateChannel();
|
||||
await CreateOrEditChannelScreen.displayNameInput.replaceText(channelDisplayName);
|
||||
await CreateOrEditChannelScreen.createButton.tap();
|
||||
await ChannelInfoScreen.open();
|
||||
await ChannelInfoScreen.convertToPrivateChannel(channelDisplayName, {confirm: false});
|
||||
|
||||
// * Verify on channel info screen and convert to private channel option still exists
|
||||
await ChannelInfoScreen.toBeVisible();
|
||||
await expect(ChannelInfoScreen.convertPrivateOption).toExist();
|
||||
|
||||
// # Go back to channel list screen
|
||||
await ChannelInfoScreen.close();
|
||||
await ChannelScreen.back();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user