Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable boLoginPage in the Core #29

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/interfaces/BO/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import type {Page} from '@playwright/test';

export interface LoginPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;
readonly loginErrorText: string;
readonly resetPasswordSuccessText: string;

failedLogin(page: Page, email: string, password: string): Promise<void>;
getLoginError(page: Page): Promise<string>;
getResetPasswordSuccessMessage(page: Page): Promise<string>;
sendResetPasswordLink(page: Page, email: string): Promise<void>;
successLogin(page: Page, email: string, password: string): Promise<void>;
}
3 changes: 3 additions & 0 deletions src/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ function requirePage(): LoginPageInterface {
if (semver.lt(psVersion, '8.0.0')) {
return require('@versions/1.7.8/pages/BO/login');
}
if (semver.lt(psVersion, '9.0.0')) {
return require('@versions/8.1/pages/BO/login').loginPage;
}
return require('@versions/develop/pages/BO/login').loginPage;
}
/* eslint-enable global-require, @typescript-eslint/no-var-requires */
Expand Down
2 changes: 1 addition & 1 deletion src/versions/1.7.8/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Import pages
import type {LoginPageInterface} from '@interfaces/BO/login';
import {Page} from '@playwright/test';
import {LoginPage} from '@versions/develop/pages/BO/login';
import {LoginPage} from '@versions/8.1/pages/BO/login';

/**
* Order confirmation page, contains functions that can be used on the page
Expand Down
26 changes: 26 additions & 0 deletions src/versions/8.1/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Import pages
import type {LoginPageInterface} from '@interfaces/BO/login';
import {LoginPage} from '@versions/develop/pages/BO/login';

/**
* Order confirmation page, contains functions that can be used on the page
* @class
* @extends OrderConfirmationPage
*/
class LoginVersion extends LoginPage implements LoginPageInterface {
/**
* @constructs
* Setting up texts and selectors to use on order confirmation page
*/
constructor() {
super();

this.alertDangerDiv = '#error';
this.resetPasswordEmailFormField = '#email_forgot';
this.resetPasswordButton = '#reset-password-button';
this.resetPasswordSuccessConfirmationText = '#forgot_confirm_name';
}
}

const loginPage = new LoginVersion();
export {loginPage, LoginVersion as LoginPage};
22 changes: 11 additions & 11 deletions src/versions/develop/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ class LoginPage extends BOBasePage implements LoginPageInterface {

private readonly submitLoginButton: string;

private readonly alertDangerDiv: string;
protected alertDangerDiv: string;

private readonly alertDangerTextBlock: string;

private readonly forgotPasswordLink: string;

private readonly resetPasswordEmailFormField: string;
protected resetPasswordEmailFormField: string;

private readonly resetPasswordButton: string;
protected resetPasswordButton: string;

private readonly resetPasswordSuccessConfirmationText: string;
protected resetPasswordSuccessConfirmationText: string;

/**
* @constructs
Expand All @@ -41,20 +41,20 @@ class LoginPage extends BOBasePage implements LoginPageInterface {
constructor() {
super();

this.pageTitle = 'PrestaShop';
this.pageTitle = global.INSTALL.SHOP_NAME;
this.loginErrorText = 'The employee does not exist, or the password provided is incorrect.';
this.resetPasswordSuccessText = 'Please, check your mailbox.';

this.emailInput = '#email';
this.passwordInput = '#passwd';
this.submitLoginButton = '#submit_login';
this.alertDangerDiv = '#error';
this.alertDangerDiv = '.alert-danger .alert-text';
this.alertDangerTextBlock = `${this.alertDangerDiv} p`;
// reset password selectors
this.forgotPasswordLink = '#forgot-password-link';
this.resetPasswordEmailFormField = '#email_forgot';
this.resetPasswordButton = '#reset-password-button';
this.resetPasswordSuccessConfirmationText = '#forgot_confirm_name';
this.resetPasswordEmailFormField = '#request_password_reset_email_forgot';
this.resetPasswordButton = '#request_password_reset_buttons_submit_login';
this.resetPasswordSuccessConfirmationText = '.alert-info .alert-text p';
}

/*
Expand Down Expand Up @@ -137,7 +137,7 @@ class LoginPage extends BOBasePage implements LoginPageInterface {
* @param page {Page} Browser tab
* @return {Promise<string>}
*/
getLoginError(page: Page): Promise<string> {
async getLoginError(page: Page): Promise<string> {
return this.getTextContent(page, this.alertDangerTextBlock);
}

Expand Down Expand Up @@ -179,7 +179,7 @@ class LoginPage extends BOBasePage implements LoginPageInterface {
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
getResetPasswordSuccessMessage(page: Page): Promise<string> {
async getResetPasswordSuccessMessage(page: Page): Promise<string> {
return this.getTextContent(page, this.resetPasswordSuccessConfirmationText);
}
}
Expand Down
Loading