Skip to content

Commit

Permalink
Improved interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jan 18, 2024
1 parent 1912e17 commit a558af6
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/common/BO/loginBO.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//import testContext from '@utils/testContext';

import loginPage from '@pages/BO/login';
let loginPage = require('@pages/BO/login');

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Expected 1 empty line after require statement not followed by another require

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

'loginPage' is never reassigned. Use 'const' instead

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Require statement not part of import statement

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

`@pages/BO/login` import should occur after type import of `@playwright/test`
import dashboardPage from '@pages/BO/dashboard';

Check failure on line 4 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Import in body of module; reorder to top

import {expect} from '@playwright/test';

Check failure on line 6 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Import in body of module; reorder to top
Expand All @@ -15,7 +15,10 @@ export default {
): Promise<void> {
//await testContext.addContextItem(testInfo, 'testIdentifier', 'loginBO');

//await loginPage.goTo(page, global.BO.URL);
console.log(loginPage);
console.log(loginPage.goTo);

await loginPage.goTo(page, global.BO.URL);
await loginPage.successLogin(page, email, password);

const pageTitle = await dashboardPage.getPageTitle(page);
Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export interface DashboardPageInterface {
import { BOBasePagePageInterface } from "@interfaces/BO";

Check failure on line 1 in src/interfaces/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

There should be no space after '{'

Check failure on line 1 in src/interfaces/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

There should be no space before '}'

Check failure on line 1 in src/interfaces/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

Strings must use singlequote

export interface DashboardPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;
}
6 changes: 6 additions & 0 deletions src/interfaces/BO/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { CommonPageInterface } from "@interfaces/index";
import type { Page } from "@playwright/test";

export interface BOBasePagePageInterface extends CommonPageInterface {
logoutBO(page: Page): Promise<void>;
}
5 changes: 4 additions & 1 deletion src/interfaces/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { BOBasePagePageInterface } from "@interfaces/BO";

import type {Page} from '@playwright/test';

export interface LoginPageInterface {

export interface LoginPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;

successLogin(page: Page, email: string, password: string): Promise<void>;
Expand Down
7 changes: 7 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Page } from "@playwright/test";

export interface CommonPageInterface {
getPageTitle(page: Page): Promise<string>;

goTo(page: Page, url: string): Promise<void>;
}
5 changes: 3 additions & 2 deletions src/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { DashboardPageInterface } from '@interfaces/BO/dashboard';
import semver from 'semver';

const psVersion = process.env.PS_VERSION ?? '99.99.99';

let Dashboard: any;
let Dashboard: DashboardPageInterface;
if (semver.gte(psVersion, '8.0.0')) {
Dashboard = require('@versions/8.0.0/pages/BO/dashboard');
} else {
Dashboard = require('@versions/8.0.0/pages/BO/dashboard');
}
export default Dashboard.constructor();
export default Dashboard;
7 changes: 4 additions & 3 deletions src/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { LoginPageInterface } from '@interfaces/BO/login';
import semver from 'semver';

const psVersion = process.env.PS_VERSION ?? '99.99.99';

let Login: any;
if (semver.gte(psVersion, '8.0.0')) {=
let Login: LoginPageInterface;
if (semver.gte(psVersion, '8.0.0')) {
Login = require('@versions/8.0.0/pages/BO/login');
} else {
Login = require('@versions/8.0.0/pages/BO/login');
}
export default Login.constructor();
export default Login;
4 changes: 3 additions & 1 deletion src/versions/8.0.0/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {DashboardPageInterface} from '@interfaces/BO/dashboard';
* @class
* @extends BOBasePage
*/
export default class Dashboard extends BOBasePage implements DashboardPageInterface {
class Dashboard extends BOBasePage implements DashboardPageInterface {
public readonly pageTitle: string;

private readonly demoModeButton: string;
Expand Down Expand Up @@ -624,3 +624,5 @@ export default class Dashboard extends BOBasePage implements DashboardPageInterf
return this.getTextContent(page, this.helpCardDocumentTitle);
}
}

export default new Dashboard();
4 changes: 3 additions & 1 deletion src/versions/8.0.0/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {Page} from 'playwright';
* @class
* @extends BOBasePage
*/
export default class Login extends BOBasePage implements LoginPageInterface {
class Login extends BOBasePage implements LoginPageInterface {
public readonly pageTitle: string;

public readonly loginErrorText: string;
Expand Down Expand Up @@ -183,3 +183,5 @@ export default class Login extends BOBasePage implements LoginPageInterface {
return this.getTextContent(page, this.resetPasswordSuccessConfirmationText);
}
}

export default new Login();

0 comments on commit a558af6

Please sign in to comment.