Skip to content

Commit

Permalink
upgrade detox and e2e dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
saturninoabril committed Sep 22, 2023
1 parent f246429 commit 5d8b762
Show file tree
Hide file tree
Showing 5 changed files with 1,851 additions and 1,582 deletions.
3 changes: 3 additions & 0 deletions detox/e2e/support/ui/component/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Alert {
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);
invalidSslCertTitle = isAndroid() ? element(by.text('Invalid SSL certificate')) : element(by.label('Invalid SSL certificate')).atIndex(0);
leaveChannelTitle = isAndroid() ? element(by.text('Leave channel')) : element(by.label('Leave channel')).atIndex(0);
logoutTitle = (serverDisplayName: string) => {
const title = `Are you sure you want to log out of ${serverDisplayName}?`;
Expand All @@ -27,6 +28,7 @@ class Alert {
};
markAllAsReadTitle = isAndroid() ? element(by.text('Are you sure you want to mark all threads as read?')) : element(by.label('Are you sure you want to mark all threads as read?')).atIndex(0);
messageLengthTitle = isAndroid() ? element(by.text('Message Length')) : element(by.label('Message Length')).atIndex(0);
notificationsCannotBeReceivedTitle = isAndroid() ? element(by.text('Notifications cannot be received from this server')) : element(by.label('Notifications cannot be received from this server')).atIndex(0);
removeServerTitle = (serverDisplayName: string) => {
const title = `Are you sure you want to remove ${serverDisplayName}?`;

Expand All @@ -47,6 +49,7 @@ class Alert {
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);
okayButton = isAndroid() ? element(by.text('Okay')) : element(by.label('Okay')).atIndex(1);
removeButton = isAndroid() ? element(by.text('REMOVE')) : element(by.label('Remove')).atIndex(0);
removeButton1 = isAndroid() ? element(by.text('REMOVE')) : element(by.label('Remove')).atIndex(1);
removeButton2 = isAndroid() ? element(by.text('REMOVE')) : element(by.label('Remove')).atIndex(2);
Expand Down
7 changes: 7 additions & 0 deletions detox/e2e/support/ui/screen/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {Alert} from '@support/ui/component';
import {isAndroid, isIos, timeouts, wait} from '@support/utils';
import {expect} from 'detox';

Expand Down Expand Up @@ -52,6 +53,12 @@ class ServerScreen {
}
if (isIos()) {
await this.tapConnectButton();

if (serverUrl.includes('127.0.0.1')) {
// # Tap alert okay button
await waitFor(Alert.okayButton).toExist().withTimeout(timeouts.TEN_SEC);
await Alert.okayButton.tap();
}
}
};

Expand Down
35 changes: 25 additions & 10 deletions detox/e2e/test/server_login/connect_to_server.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
// *******************************************************************

import {serverOneUrl} from '@support/test_config';
import {Alert} from '@support/ui/component';
import {
LoginScreen,
ServerScreen,
} from '@support/ui/screen';
import {timeouts, wait} from '@support/utils';
import {isIos, timeouts, wait} from '@support/utils';
import {expect} from 'detox';

describe('Server Login - Connect to Server', () => {
Expand All @@ -33,6 +34,8 @@ describe('Server Login - Connect to Server', () => {
await ServerScreen.toBeVisible();

// # Clear fields
await expect(serverUrlInput).toBeVisible();
await expect(serverDisplayNameInput).toBeVisible();
await serverUrlInput.clearText();
await serverDisplayNameInput.clearText();
});
Expand Down Expand Up @@ -67,6 +70,7 @@ describe('Server Login - Connect to Server', () => {
it('MM-T4676_3 - should show invalid url error on invalid server url', async () => {
// # Connect with invalid server url and non-empty server display name
const invalidServerUrl = 'invalid';
await device.setURLBlacklist([invalidServerUrl]);
await serverUrlInput.replaceText(invalidServerUrl);
await serverDisplayNameInput.replaceText('Server 1');
await connectButton.tap();
Expand All @@ -78,27 +82,32 @@ describe('Server Login - Connect to Server', () => {
});

it('MM-T4676_4 - should show connection error on invalid ssl or invalid host', async () => {
await device.reloadReactNative();

// # Connect with invalid ssl and non-empty server display name
const connectionError = 'Cannot connect to the server.';
await serverUrlInput.replaceText('expired.badssl.com');
const expiredServerUrl = 'expired.badssl.com';
const wrongHostServerUrl = 'wrong.host.badssl.com';
await device.setURLBlacklist([expiredServerUrl, wrongHostServerUrl]);

await serverUrlInput.replaceText(expiredServerUrl);
await serverDisplayNameInput.replaceText('Server 1');
await connectButton.tap();
await wait(timeouts.ONE_SEC);

// * Verify connection error
await waitFor(serverUrlInputError).toExist().withTimeout(timeouts.TEN_SEC);
await expect(serverUrlInputError).toHaveText(connectionError);
// * Verify invalid SSL cert error
await waitFor(Alert.invalidSslCertTitle).toExist().withTimeout(timeouts.TEN_SEC);
await Alert.okButton.tap();

// # Connect with invalid host and valid server display name
await device.reloadReactNative();
await serverUrlInput.replaceText('wrong.host.badssl.com');
await serverUrlInput.replaceText(wrongHostServerUrl);
await serverDisplayNameInput.replaceText('Server 1');
await connectButton.tap();
await wait(timeouts.ONE_SEC);

// * Verify connection error
await waitFor(serverUrlInputError).toExist().withTimeout(timeouts.TEN_SEC);
await expect(serverUrlInputError).toHaveText(connectionError);
// * Verify invalid SSL cert error
await waitFor(Alert.invalidSslCertTitle).toExist().withTimeout(timeouts.TEN_SEC);
await Alert.okButton.tap();
});

it('MM-T4676_5 - should show login screen on successful connection to server', async () => {
Expand All @@ -108,6 +117,12 @@ describe('Server Login - Connect to Server', () => {
await connectButton.tap();
await wait(timeouts.ONE_SEC);

if (isIos()) {
// # Tap alert okay button
await waitFor(Alert.okayButton).toExist().withTimeout(timeouts.TEN_SEC);
await Alert.okayButton.tap();
}

// * Verify on login screen
await LoginScreen.toBeVisible();
});
Expand Down
Loading

0 comments on commit 5d8b762

Please sign in to comment.