mirror of
https://github.com/penpot/penpotqa.git
synced 2024-08-03 09:18:53 +00:00
102 lines
2.9 KiB
JavaScript
102 lines
2.9 KiB
JavaScript
const { expect } = require('@playwright/test');
|
|
const { BasePage } = require('./base-page');
|
|
|
|
exports.LoginPage = class LoginPage extends BasePage {
|
|
/**
|
|
* @param {import('@playwright/test').Page} page
|
|
*/
|
|
constructor(page) {
|
|
super(page);
|
|
|
|
this.pageTitle = page.locator('h1[data-test="login-title"]');
|
|
this.emailInput = page.locator('#email');
|
|
this.pwdInput = page.locator('#password');
|
|
this.loginButton = page.locator('button[data-test="login-submit"]');
|
|
this.emailInputError = page.locator('div[data-test="-error"]');
|
|
this.section = page.locator('section[class="auth-content"]');
|
|
this.loginErrorBanner = page.locator('aside[class*="context_notification__warning"] div:nth-of-type(2)');
|
|
this.createAccountLink = page.locator('a:has-text("Create an account")');
|
|
this.loginHereButton = page.locator('*[data-test="login-here-link"]');
|
|
this.forgotPasswordBtn = page.locator('a[data-test="forgot-password"]');
|
|
this.recoverySubmitBtn = page.locator('button[data-test="recovery-resquest-submit"]');
|
|
this.recoveryPwdInput = page.locator('#password-1');
|
|
this.recoveryPwdConfirmInput = page.locator('#password-2');
|
|
this.changePwdButton = page.locator('button[class*="auth_recovery__submit-btn"]')
|
|
}
|
|
|
|
async checkLoginError(text) {
|
|
return this.page.locator(`//aside[contains(@class,"context_notification__warning")]/div[text()='${text}']`).isVisible()
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/#/auth/login');
|
|
}
|
|
|
|
async enterEmail(loginEmail) {
|
|
await this.emailInput.fill(loginEmail);
|
|
}
|
|
|
|
async enterPwd(loginPwd) {
|
|
await this.pwdInput.fill(loginPwd);
|
|
}
|
|
|
|
async clickLoginButton() {
|
|
await this.loginButton.click();
|
|
}
|
|
|
|
async clickPwdInput() {
|
|
await this.pwdInput.click();
|
|
}
|
|
|
|
async isEmailInputErrorDisplayed(error) {
|
|
await expect(this.emailInputError).toHaveText(error);
|
|
}
|
|
|
|
async isLoginButtonDisplayed() {
|
|
await expect(this.loginButton).toBeVisible();
|
|
}
|
|
|
|
async isLoginButtonDisabled() {
|
|
await expect(this.loginButton).toBeDisabled();
|
|
}
|
|
|
|
async clickHeader() {
|
|
await this.pageTitle.click();
|
|
}
|
|
|
|
async isLoginErrorMessageDisplayed(message) {
|
|
await expect(await this.checkLoginError(message)).toBeTruthy;
|
|
}
|
|
|
|
async clickOnCreateAccount() {
|
|
await this.createAccountLink.click();
|
|
}
|
|
async clickOnLoginHereLinc() {
|
|
await this.loginHereButton.click();
|
|
}
|
|
|
|
async clickOnForgotPasswordButton() {
|
|
await this.forgotPasswordBtn.click();
|
|
}
|
|
|
|
async clickOnRecoverySubmitButton() {
|
|
await this.recoverySubmitBtn.click();
|
|
}
|
|
|
|
async enterNewPwd(loginPwd) {
|
|
await this.recoveryPwdInput.fill(loginPwd);
|
|
}
|
|
|
|
async enterConfirmPwd(loginPwd) {
|
|
await this.recoveryPwdConfirmInput.fill(loginPwd);
|
|
}
|
|
|
|
async clickOnChangePwdButton() {
|
|
await this.changePwdButton.click();
|
|
}
|
|
|
|
async isLoginPageOpened() {
|
|
await expect(this.pageTitle).toHaveText('Log into my account');
|
|
}
|
|
};
|