mattermost-mobile/detox/e2e/support/ui/screen/login.ts
Joseph Baylon 1d9c371bfb
Detox/E2E: Migrate e2e javascript to typescript (#6059)
* Detox/E2E: Migrate to typescript

* Add jest.config.js

* Add moduleMapper to config.json

* Add cookie jar to axios client, fix tsconfig.json and default_config.json

* Take keyboard into consideration; clean test for now for this migration PR

* Revert changes on path_builder

* Attempt to fix dep issues

* Update detox dep

* Added missing @type dev dependencies

* Fix dep order

* Fix unit tests

* Added dynamic year to email.ts
2022-03-17 17:35:26 -07:00

59 lines
2.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {ServerScreen} from '@support/ui/screen';
import {timeouts} from '@support/utils';
import {expect} from 'detox';
class LoginScreen {
testID = {
loginScreen: 'login.screen',
backButton: 'screen.back.button',
usernameInput: 'login_form.username.input',
usernameInputError: 'login_form.username.input.error',
passwordInput: 'login_form.password.input',
passwordInputError: 'login_form.password.input.error',
forgotPasswordButton: 'login_form.forgot_password.button',
signinButton: 'login_form.signin.button',
signinButtonDisabled: 'login_form.signin.button.disabled',
};
loginScreen = element(by.id(this.testID.loginScreen));
backButton = element(by.id(this.testID.backButton));
usernameInput = element(by.id(this.testID.usernameInput));
usernameInputError = element(by.id(this.testID.usernameInputError));
passwordInput = element(by.id(this.testID.passwordInput));
passwordInputError = element(by.id(this.testID.passwordInputError));
forgotPasswordButton = element(by.id(this.testID.forgotPasswordButton));
signinButton = element(by.id(this.testID.signinButton));
signinButtonDisabled = element(by.id(this.testID.signinButtonDisabled));
toBeVisible = async () => {
await waitFor(this.loginScreen).toExist().withTimeout(timeouts.TEN_SEC);
await waitFor(this.usernameInput).toBeVisible().withTimeout(timeouts.TEN_SEC);
return this.loginScreen;
};
open = async (serverUrl: string, serverDisplayName: string) => {
// # Open login screen
await ServerScreen.connectToServer(serverUrl, serverDisplayName);
return this.toBeVisible();
};
back = async () => {
await this.backButton.tap();
await expect(this.loginScreen).not.toBeVisible();
};
login = async (user: any = {}) => {
await this.toBeVisible();
await this.usernameInput.replaceText(user.username);
await this.passwordInput.replaceText(user.password);
await this.signinButton.tap();
};
}
const loginScreen = new LoginScreen();
export default loginScreen;