From 1912e1715fbda37b51cf26a23be5a974425eb8d4 Mon Sep 17 00:00:00 2001 From: boubkerbribri Date: Thu, 18 Jan 2024 09:22:10 +0100 Subject: [PATCH 1/5] test: commonjs build --- src/common/BO/loginBO.ts | 15 ++-- src/pages/BO/dashboard/index.ts | 13 ++-- src/pages/BO/login/index.ts | 13 ++-- .../8.0.0/pages/BO/dashboard/index.ts | 4 +- src/versions/8.0.0/pages/BO/login/index.ts | 4 +- tsconfig.json | 71 +++++++++++++------ 6 files changed, 70 insertions(+), 50 deletions(-) diff --git a/src/common/BO/loginBO.ts b/src/common/BO/loginBO.ts index 6919dad5..7a6e624f 100644 --- a/src/common/BO/loginBO.ts +++ b/src/common/BO/loginBO.ts @@ -1,11 +1,10 @@ -import testContext from '@utils/testContext'; +//import testContext from '@utils/testContext'; import loginPage from '@pages/BO/login'; import dashboardPage from '@pages/BO/dashboard'; import {expect} from '@playwright/test'; -import type {Page} from 'playwright'; -import type {TestInfo} from '@playwright/test'; +import type {Page, TestInfo} from '@playwright/test'; export default { async loginBO( @@ -14,9 +13,9 @@ export default { email: string = global.BO.EMAIL, password: string = global.BO.PASSWD, ): Promise { - await testContext.addContextItem(testInfo, 'testIdentifier', 'loginBO'); + //await testContext.addContextItem(testInfo, 'testIdentifier', 'loginBO'); - await loginPage.goTo(page, global.BO.URL); + //await loginPage.goTo(page, global.BO.URL); await loginPage.successLogin(page, email, password); const pageTitle = await dashboardPage.getPageTitle(page); @@ -24,11 +23,11 @@ export default { }, async logoutBO(testInfo: TestInfo, page: Page): Promise { - await testContext.addContextItem(testInfo, 'testIdentifier', 'logoutBO'); + //await testContext.addContextItem(testInfo, 'testIdentifier', 'logoutBO'); await dashboardPage.logoutBO(page); - const pageTitle = await loginPage.getPageTitle(page); - expect(pageTitle).toContain(loginPage.pageTitle); + //const pageTitle = await loginPage.getPageTitle(page); + //expect(pageTitle).toContain(loginPage.pageTitle); }, }; diff --git a/src/pages/BO/dashboard/index.ts b/src/pages/BO/dashboard/index.ts index 0c4a9fa6..063aa5e6 100644 --- a/src/pages/BO/dashboard/index.ts +++ b/src/pages/BO/dashboard/index.ts @@ -1,12 +1,11 @@ import semver from 'semver'; -let file: string; +const psVersion = process.env.PS_VERSION ?? '99.99.99'; -if (semver.gte(process.env.PS_VERSION as string, '8.0.0')) { - file = '@versions/8.0.0/pages/BO/dashboard'; +let Dashboard: any; +if (semver.gte(psVersion, '8.0.0')) { + Dashboard = require('@versions/8.0.0/pages/BO/dashboard'); } else { - file = '@versions/8.0.0/pages/BO/dashboard'; + Dashboard = require('@versions/8.0.0/pages/BO/dashboard'); } - -const Dashboard = await import(file); -export default Dashboard; +export default Dashboard.constructor(); diff --git a/src/pages/BO/login/index.ts b/src/pages/BO/login/index.ts index 6f8dc815..b9c935cc 100644 --- a/src/pages/BO/login/index.ts +++ b/src/pages/BO/login/index.ts @@ -1,12 +1,11 @@ import semver from 'semver'; -let file: string; +const psVersion = process.env.PS_VERSION ?? '99.99.99'; -if (semver.gte(process.env.PS_VERSION as string, '8.0.0')) { - file = '@versions/8.0.0/pages/BO/login'; +let Login: any; +if (semver.gte(psVersion, '8.0.0')) {= + Login = require('@versions/8.0.0/pages/BO/login'); } else { - file = '@versions/8.0.0/pages/BO/login'; + Login = require('@versions/8.0.0/pages/BO/login'); } - -const Login = await import(file); -export default Login; +export default Login.constructor(); diff --git a/src/versions/8.0.0/pages/BO/dashboard/index.ts b/src/versions/8.0.0/pages/BO/dashboard/index.ts index 664f0deb..6ec14568 100644 --- a/src/versions/8.0.0/pages/BO/dashboard/index.ts +++ b/src/versions/8.0.0/pages/BO/dashboard/index.ts @@ -9,7 +9,7 @@ import {DashboardPageInterface} from '@interfaces/BO/dashboard'; * @class * @extends BOBasePage */ -class Dashboard extends BOBasePage implements DashboardPageInterface { +export default class Dashboard extends BOBasePage implements DashboardPageInterface { public readonly pageTitle: string; private readonly demoModeButton: string; @@ -624,5 +624,3 @@ class Dashboard extends BOBasePage implements DashboardPageInterface { return this.getTextContent(page, this.helpCardDocumentTitle); } } - -export default new Dashboard(); diff --git a/src/versions/8.0.0/pages/BO/login/index.ts b/src/versions/8.0.0/pages/BO/login/index.ts index 415e46f1..d81ff221 100644 --- a/src/versions/8.0.0/pages/BO/login/index.ts +++ b/src/versions/8.0.0/pages/BO/login/index.ts @@ -9,7 +9,7 @@ import type {Page} from 'playwright'; * @class * @extends BOBasePage */ -class Login extends BOBasePage implements LoginPageInterface { +export default class Login extends BOBasePage implements LoginPageInterface { public readonly pageTitle: string; public readonly loginErrorText: string; @@ -183,5 +183,3 @@ class Login extends BOBasePage implements LoginPageInterface { return this.getTextContent(page, this.resetPasswordSuccessConfirmationText); } } - -export default new Login(); diff --git a/tsconfig.json b/tsconfig.json index e58dffa6..28649ec4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,31 +1,58 @@ { "compilerOptions": { - "noImplicitAny": true, - "noImplicitThis": true, - "module": "es2022", - "target": "es2022", - "strict": true, - "moduleResolution": "node", + "listEmittedFiles": true, "allowSyntheticDefaultImports": true, - "resolveJsonModule": true, "esModuleInterop": true, - "allowJs": true, - "downlevelIteration": true, - "baseUrl": "./", - "outDir": "dist", + "target": "es6", + "module": "commonjs", + "skipDefaultLibCheck": true, + "skipLibCheck": true, + "moduleResolution": "node", + "noImplicitAny": true, + "noImplicitThis": false, + "strict": true, + "strictFunctionTypes": true, + "isolatedModules": true, "declaration": true, + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "baseUrl": "./", + "outDir": "./dist", "paths": { - "@interfaces/*": ["src/interfaces/*"], - "@pages/*": ["src/pages/*"], - "@common/*": ["src/common/*"], - "@data/*": ["src/data/*"], - "@types/*": ["src/types/*"], - "@utils/*": ["src/utils/*"], - "@versions/*": ["src/versions/*"] + "@interfaces/*": [ + "src/interfaces/*" + ], + "@pages/*": [ + "src/pages/*" + ], + "@common/*": [ + "src/common/*" + ], + "@data/*": [ + "src/data/*" + ], + "@types/*": [ + "src/types/*" + ], + "@utils/*": [ + "src/utils/*" + ], + "@versions/*": [ + "src/versions/*" + ] }, - "typeRoots": ["types", "node_modules/@types"], - "skipLibCheck": true + "typeRoots": [ + "types", + "node_modules/@types" + ], }, - "include": ["src/**/*"], - "exclude": ["node_modules"] + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules" + ] } From a558af6dae8d10e679a68c7fc7ecb113c711b75b Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 18 Jan 2024 12:51:24 +0100 Subject: [PATCH 2/5] Improved interfaces --- src/common/BO/loginBO.ts | 7 +++++-- src/interfaces/BO/dashboard/index.ts | 4 +++- src/interfaces/BO/index.ts | 6 ++++++ src/interfaces/BO/login/index.ts | 5 ++++- src/interfaces/index.ts | 7 +++++++ src/pages/BO/dashboard/index.ts | 5 +++-- src/pages/BO/login/index.ts | 7 ++++--- src/versions/8.0.0/pages/BO/dashboard/index.ts | 4 +++- src/versions/8.0.0/pages/BO/login/index.ts | 4 +++- 9 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 src/interfaces/BO/index.ts create mode 100644 src/interfaces/index.ts diff --git a/src/common/BO/loginBO.ts b/src/common/BO/loginBO.ts index 7a6e624f..fb105c85 100644 --- a/src/common/BO/loginBO.ts +++ b/src/common/BO/loginBO.ts @@ -1,6 +1,6 @@ //import testContext from '@utils/testContext'; -import loginPage from '@pages/BO/login'; +let loginPage = require('@pages/BO/login'); import dashboardPage from '@pages/BO/dashboard'; import {expect} from '@playwright/test'; @@ -15,7 +15,10 @@ export default { ): Promise { //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); diff --git a/src/interfaces/BO/dashboard/index.ts b/src/interfaces/BO/dashboard/index.ts index e4670ea4..66070005 100644 --- a/src/interfaces/BO/dashboard/index.ts +++ b/src/interfaces/BO/dashboard/index.ts @@ -1,3 +1,5 @@ -export interface DashboardPageInterface { +import { BOBasePagePageInterface } from "@interfaces/BO"; + +export interface DashboardPageInterface extends BOBasePagePageInterface { readonly pageTitle: string; } diff --git a/src/interfaces/BO/index.ts b/src/interfaces/BO/index.ts new file mode 100644 index 00000000..e204130e --- /dev/null +++ b/src/interfaces/BO/index.ts @@ -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; +} \ No newline at end of file diff --git a/src/interfaces/BO/login/index.ts b/src/interfaces/BO/login/index.ts index cbcc6764..80631047 100644 --- a/src/interfaces/BO/login/index.ts +++ b/src/interfaces/BO/login/index.ts @@ -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; diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts new file mode 100644 index 00000000..f350d4f4 --- /dev/null +++ b/src/interfaces/index.ts @@ -0,0 +1,7 @@ +import type { Page } from "@playwright/test"; + +export interface CommonPageInterface { + getPageTitle(page: Page): Promise; + + goTo(page: Page, url: string): Promise; +} \ No newline at end of file diff --git a/src/pages/BO/dashboard/index.ts b/src/pages/BO/dashboard/index.ts index 063aa5e6..65205b7e 100644 --- a/src/pages/BO/dashboard/index.ts +++ b/src/pages/BO/dashboard/index.ts @@ -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; diff --git a/src/pages/BO/login/index.ts b/src/pages/BO/login/index.ts index b9c935cc..f62dd6bc 100644 --- a/src/pages/BO/login/index.ts +++ b/src/pages/BO/login/index.ts @@ -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; diff --git a/src/versions/8.0.0/pages/BO/dashboard/index.ts b/src/versions/8.0.0/pages/BO/dashboard/index.ts index 6ec14568..b1ccbfab 100644 --- a/src/versions/8.0.0/pages/BO/dashboard/index.ts +++ b/src/versions/8.0.0/pages/BO/dashboard/index.ts @@ -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; @@ -624,3 +624,5 @@ export default class Dashboard extends BOBasePage implements DashboardPageInterf return this.getTextContent(page, this.helpCardDocumentTitle); } } + +export default new Dashboard(); \ No newline at end of file diff --git a/src/versions/8.0.0/pages/BO/login/index.ts b/src/versions/8.0.0/pages/BO/login/index.ts index d81ff221..2d6154a8 100644 --- a/src/versions/8.0.0/pages/BO/login/index.ts +++ b/src/versions/8.0.0/pages/BO/login/index.ts @@ -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; @@ -183,3 +183,5 @@ export default class Login extends BOBasePage implements LoginPageInterface { return this.getTextContent(page, this.resetPasswordSuccessConfirmationText); } } + +export default new Login(); \ No newline at end of file From 2a15b1ee2398ad55a8840252c1366a53870283ee Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 18 Jan 2024 14:57:58 +0100 Subject: [PATCH 3/5] Changed export default to module.exports --- src/common/BO/loginBO.ts | 36 ------------------- src/pages/BO/dashboard/index.ts | 10 +++--- src/pages/BO/login/index.ts | 10 +++--- .../8.0.0/pages/BO/dashboard/index.ts | 2 +- src/versions/8.0.0/pages/BO/login/index.ts | 2 +- tsconfig.json | 3 -- 6 files changed, 12 insertions(+), 51 deletions(-) delete mode 100644 src/common/BO/loginBO.ts diff --git a/src/common/BO/loginBO.ts b/src/common/BO/loginBO.ts deleted file mode 100644 index fb105c85..00000000 --- a/src/common/BO/loginBO.ts +++ /dev/null @@ -1,36 +0,0 @@ -//import testContext from '@utils/testContext'; - -let loginPage = require('@pages/BO/login'); -import dashboardPage from '@pages/BO/dashboard'; - -import {expect} from '@playwright/test'; -import type {Page, TestInfo} from '@playwright/test'; - -export default { - async loginBO( - testInfo: TestInfo, - page: Page, - email: string = global.BO.EMAIL, - password: string = global.BO.PASSWD, - ): Promise { - //await testContext.addContextItem(testInfo, 'testIdentifier', 'loginBO'); - - 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); - expect(pageTitle).toContain(dashboardPage.pageTitle); - }, - - async logoutBO(testInfo: TestInfo, page: Page): Promise { - //await testContext.addContextItem(testInfo, 'testIdentifier', 'logoutBO'); - - await dashboardPage.logoutBO(page); - - //const pageTitle = await loginPage.getPageTitle(page); - //expect(pageTitle).toContain(loginPage.pageTitle); - }, -}; diff --git a/src/pages/BO/dashboard/index.ts b/src/pages/BO/dashboard/index.ts index 65205b7e..29f1a219 100644 --- a/src/pages/BO/dashboard/index.ts +++ b/src/pages/BO/dashboard/index.ts @@ -1,12 +1,12 @@ import type { DashboardPageInterface } from '@interfaces/BO/dashboard'; import semver from 'semver'; -const psVersion = process.env.PS_VERSION ?? '99.99.99'; +const psVersion = process.env.PS_VERSION ?? '0.0.0'; -let Dashboard: DashboardPageInterface; +let dashboardPage: DashboardPageInterface; if (semver.gte(psVersion, '8.0.0')) { - Dashboard = require('@versions/8.0.0/pages/BO/dashboard'); + dashboardPage = require('@versions/8.0.0/pages/BO/dashboard'); } else { - Dashboard = require('@versions/8.0.0/pages/BO/dashboard'); + dashboardPage = require('@versions/8.0.0/pages/BO/dashboard'); } -export default Dashboard; +module.exports = dashboardPage; diff --git a/src/pages/BO/login/index.ts b/src/pages/BO/login/index.ts index f62dd6bc..13c3133e 100644 --- a/src/pages/BO/login/index.ts +++ b/src/pages/BO/login/index.ts @@ -1,12 +1,12 @@ import type { LoginPageInterface } from '@interfaces/BO/login'; import semver from 'semver'; -const psVersion = process.env.PS_VERSION ?? '99.99.99'; +const psVersion = process.env.PS_VERSION ?? '0.0.0'; -let Login: LoginPageInterface; +let loginPage: LoginPageInterface; if (semver.gte(psVersion, '8.0.0')) { - Login = require('@versions/8.0.0/pages/BO/login'); + loginPage = require('@versions/8.0.0/pages/BO/login'); } else { - Login = require('@versions/8.0.0/pages/BO/login'); + loginPage = require('@versions/8.0.0/pages/BO/login'); } -export default Login; +module.exports = loginPage; diff --git a/src/versions/8.0.0/pages/BO/dashboard/index.ts b/src/versions/8.0.0/pages/BO/dashboard/index.ts index b1ccbfab..75be1b03 100644 --- a/src/versions/8.0.0/pages/BO/dashboard/index.ts +++ b/src/versions/8.0.0/pages/BO/dashboard/index.ts @@ -625,4 +625,4 @@ class Dashboard extends BOBasePage implements DashboardPageInterface { } } -export default new Dashboard(); \ No newline at end of file +module.exports = new Dashboard(); \ No newline at end of file diff --git a/src/versions/8.0.0/pages/BO/login/index.ts b/src/versions/8.0.0/pages/BO/login/index.ts index 2d6154a8..c0834d45 100644 --- a/src/versions/8.0.0/pages/BO/login/index.ts +++ b/src/versions/8.0.0/pages/BO/login/index.ts @@ -184,4 +184,4 @@ class Login extends BOBasePage implements LoginPageInterface { } } -export default new Login(); \ No newline at end of file +module.exports = new Login(); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 28649ec4..f4e72156 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,9 +28,6 @@ "@pages/*": [ "src/pages/*" ], - "@common/*": [ - "src/common/*" - ], "@data/*": [ "src/data/*" ], From 06aa047eb6545de5c178dc3716df93fc7ca52fa2 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 18 Jan 2024 15:22:35 +0100 Subject: [PATCH 4/5] Fixed ESLint --- src/interfaces/BO/dashboard/index.ts | 2 +- src/interfaces/BO/index.ts | 6 +++--- src/interfaces/BO/login/index.ts | 3 +-- src/interfaces/index.ts | 4 ++-- src/pages/BO/dashboard/index.ts | 5 ++++- src/pages/BO/login/index.ts | 5 ++++- src/versions/8.0.0/pages/BO/dashboard/index.ts | 2 +- src/versions/8.0.0/pages/BO/login/index.ts | 2 +- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/interfaces/BO/dashboard/index.ts b/src/interfaces/BO/dashboard/index.ts index 66070005..f41f02df 100644 --- a/src/interfaces/BO/dashboard/index.ts +++ b/src/interfaces/BO/dashboard/index.ts @@ -1,4 +1,4 @@ -import { BOBasePagePageInterface } from "@interfaces/BO"; +import {BOBasePagePageInterface} from '@interfaces/BO'; export interface DashboardPageInterface extends BOBasePagePageInterface { readonly pageTitle: string; diff --git a/src/interfaces/BO/index.ts b/src/interfaces/BO/index.ts index e204130e..b8f06430 100644 --- a/src/interfaces/BO/index.ts +++ b/src/interfaces/BO/index.ts @@ -1,6 +1,6 @@ -import type { CommonPageInterface } from "@interfaces/index"; -import type { Page } from "@playwright/test"; +import type {CommonPageInterface} from '@interfaces/index'; +import type {Page} from '@playwright/test'; export interface BOBasePagePageInterface extends CommonPageInterface { logoutBO(page: Page): Promise; -} \ No newline at end of file +} diff --git a/src/interfaces/BO/login/index.ts b/src/interfaces/BO/login/index.ts index 80631047..b8bee851 100644 --- a/src/interfaces/BO/login/index.ts +++ b/src/interfaces/BO/login/index.ts @@ -1,8 +1,7 @@ -import { BOBasePagePageInterface } from "@interfaces/BO"; +import {BOBasePagePageInterface} from '@interfaces/BO'; import type {Page} from '@playwright/test'; - export interface LoginPageInterface extends BOBasePagePageInterface { readonly pageTitle: string; diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index f350d4f4..0773b635 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,7 +1,7 @@ -import type { Page } from "@playwright/test"; +import type {Page} from '@playwright/test'; export interface CommonPageInterface { getPageTitle(page: Page): Promise; goTo(page: Page, url: string): Promise; -} \ No newline at end of file +} diff --git a/src/pages/BO/dashboard/index.ts b/src/pages/BO/dashboard/index.ts index 29f1a219..1558a057 100644 --- a/src/pages/BO/dashboard/index.ts +++ b/src/pages/BO/dashboard/index.ts @@ -1,12 +1,15 @@ -import type { DashboardPageInterface } from '@interfaces/BO/dashboard'; +import type {DashboardPageInterface} from '@interfaces/BO/dashboard'; import semver from 'semver'; const psVersion = process.env.PS_VERSION ?? '0.0.0'; let dashboardPage: DashboardPageInterface; + +/* eslint-disable global-require */ if (semver.gte(psVersion, '8.0.0')) { dashboardPage = require('@versions/8.0.0/pages/BO/dashboard'); } else { dashboardPage = require('@versions/8.0.0/pages/BO/dashboard'); } +/* eslint-enable global-require */ module.exports = dashboardPage; diff --git a/src/pages/BO/login/index.ts b/src/pages/BO/login/index.ts index 13c3133e..c943c166 100644 --- a/src/pages/BO/login/index.ts +++ b/src/pages/BO/login/index.ts @@ -1,12 +1,15 @@ -import type { LoginPageInterface } from '@interfaces/BO/login'; +import type {LoginPageInterface} from '@interfaces/BO/login'; import semver from 'semver'; const psVersion = process.env.PS_VERSION ?? '0.0.0'; let loginPage: LoginPageInterface; + +/* eslint-disable global-require */ if (semver.gte(psVersion, '8.0.0')) { loginPage = require('@versions/8.0.0/pages/BO/login'); } else { loginPage = require('@versions/8.0.0/pages/BO/login'); } +/* eslint-enable global-require */ module.exports = loginPage; diff --git a/src/versions/8.0.0/pages/BO/dashboard/index.ts b/src/versions/8.0.0/pages/BO/dashboard/index.ts index 75be1b03..46f73df1 100644 --- a/src/versions/8.0.0/pages/BO/dashboard/index.ts +++ b/src/versions/8.0.0/pages/BO/dashboard/index.ts @@ -625,4 +625,4 @@ class Dashboard extends BOBasePage implements DashboardPageInterface { } } -module.exports = new Dashboard(); \ No newline at end of file +module.exports = new Dashboard(); diff --git a/src/versions/8.0.0/pages/BO/login/index.ts b/src/versions/8.0.0/pages/BO/login/index.ts index c0834d45..deb67dce 100644 --- a/src/versions/8.0.0/pages/BO/login/index.ts +++ b/src/versions/8.0.0/pages/BO/login/index.ts @@ -184,4 +184,4 @@ class Login extends BOBasePage implements LoginPageInterface { } } -module.exports = new Login(); \ No newline at end of file +module.exports = new Login(); From e1027abdae6601818fc026d0f62ebc48632d97c5 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 18 Jan 2024 16:03:37 +0100 Subject: [PATCH 5/5] Move pages to export default for declarations --- src/pages/BO/dashboard/index.ts | 14 +++++++------- src/pages/BO/login/index.ts | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/pages/BO/dashboard/index.ts b/src/pages/BO/dashboard/index.ts index 1558a057..431bdfcf 100644 --- a/src/pages/BO/dashboard/index.ts +++ b/src/pages/BO/dashboard/index.ts @@ -3,13 +3,13 @@ import semver from 'semver'; const psVersion = process.env.PS_VERSION ?? '0.0.0'; -let dashboardPage: DashboardPageInterface; - /* eslint-disable global-require */ -if (semver.gte(psVersion, '8.0.0')) { - dashboardPage = require('@versions/8.0.0/pages/BO/dashboard'); -} else { - dashboardPage = require('@versions/8.0.0/pages/BO/dashboard'); +function requirePage(): DashboardPageInterface { + if (semver.gte(psVersion, '8.0.0')) { + return require('@versions/8.0.0/pages/BO/dashboard'); + } + return require('@versions/8.0.0/pages/BO/dashboard'); } /* eslint-enable global-require */ -module.exports = dashboardPage; + +export default requirePage(); diff --git a/src/pages/BO/login/index.ts b/src/pages/BO/login/index.ts index c943c166..7a11aa34 100644 --- a/src/pages/BO/login/index.ts +++ b/src/pages/BO/login/index.ts @@ -3,13 +3,13 @@ import semver from 'semver'; const psVersion = process.env.PS_VERSION ?? '0.0.0'; -let loginPage: LoginPageInterface; - /* eslint-disable global-require */ -if (semver.gte(psVersion, '8.0.0')) { - loginPage = require('@versions/8.0.0/pages/BO/login'); -} else { - loginPage = require('@versions/8.0.0/pages/BO/login'); +function requirePage(): LoginPageInterface { + if (semver.gte(psVersion, '8.0.0')) { + return require('@versions/8.0.0/pages/BO/login'); + } + return require('@versions/8.0.0/pages/BO/login'); } /* eslint-enable global-require */ -module.exports = loginPage; + +export default requirePage();