From 86d257e939dbb8f904f306dc8c8b801c75af3632 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 24 Jan 2024 13:27:50 +0100 Subject: [PATCH 1/3] Fixed use of getPSVersion --- src/pages/BO/dashboard/index.ts | 3 ++- src/pages/BO/login/index.ts | 3 ++- src/pages/BO/modules/blockwishlist/index.ts | 3 ++- src/pages/BO/modules/blockwishlist/statistics.ts | 3 ++- src/pages/BO/modules/moduleManager/index.ts | 3 ++- src/pages/FO/category/index.ts | 3 ++- src/pages/FO/home/index.ts | 3 ++- src/pages/FO/login/index.ts | 3 ++- src/types/globals.d.ts | 11 ----------- src/utils/testContext.ts | 13 +++++++++++++ 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/pages/BO/dashboard/index.ts b/src/pages/BO/dashboard/index.ts index 50212419..434e62bf 100644 --- a/src/pages/BO/dashboard/index.ts +++ b/src/pages/BO/dashboard/index.ts @@ -1,7 +1,8 @@ import type {DashboardPageInterface} from '@interfaces/BO/dashboard'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require */ function requirePage(): DashboardPageInterface { diff --git a/src/pages/BO/login/index.ts b/src/pages/BO/login/index.ts index 5a12e825..b5067223 100644 --- a/src/pages/BO/login/index.ts +++ b/src/pages/BO/login/index.ts @@ -1,7 +1,8 @@ import type {LoginPageInterface} from '@interfaces/BO/login'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require */ function requirePage(): LoginPageInterface { diff --git a/src/pages/BO/modules/blockwishlist/index.ts b/src/pages/BO/modules/blockwishlist/index.ts index baa3b8cb..866468cc 100644 --- a/src/pages/BO/modules/blockwishlist/index.ts +++ b/src/pages/BO/modules/blockwishlist/index.ts @@ -1,7 +1,8 @@ import type {ModuleBlockwishlistMainPageInterface} from '@interfaces/BO/modules/blockwishlist/index'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require */ function requirePage(): ModuleBlockwishlistMainPageInterface { diff --git a/src/pages/BO/modules/blockwishlist/statistics.ts b/src/pages/BO/modules/blockwishlist/statistics.ts index 0dd61663..85b13308 100644 --- a/src/pages/BO/modules/blockwishlist/statistics.ts +++ b/src/pages/BO/modules/blockwishlist/statistics.ts @@ -1,7 +1,8 @@ import type {ModuleBlockwishlistStatisticsPageInterface} from '@interfaces/BO/modules/blockwishlist/statistics'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require */ function requirePage(): ModuleBlockwishlistStatisticsPageInterface { diff --git a/src/pages/BO/modules/moduleManager/index.ts b/src/pages/BO/modules/moduleManager/index.ts index 83127854..111bf214 100644 --- a/src/pages/BO/modules/moduleManager/index.ts +++ b/src/pages/BO/modules/moduleManager/index.ts @@ -1,7 +1,8 @@ import type {ModuleManagerPageInterface} from '@interfaces/BO/modules/moduleManager'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require, @typescript-eslint/no-var-requires */ function requirePage(): ModuleManagerPageInterface { diff --git a/src/pages/FO/category/index.ts b/src/pages/FO/category/index.ts index e06ef5bb..a1aaed91 100644 --- a/src/pages/FO/category/index.ts +++ b/src/pages/FO/category/index.ts @@ -1,7 +1,8 @@ import type {FoCategoryPageInterface} from '@interfaces/FO/category'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require */ function requirePage(): FoCategoryPageInterface { diff --git a/src/pages/FO/home/index.ts b/src/pages/FO/home/index.ts index 9b838438..88a0ba77 100644 --- a/src/pages/FO/home/index.ts +++ b/src/pages/FO/home/index.ts @@ -1,7 +1,8 @@ import type {FoHomePageInterface} from '@interfaces/FO/home'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require, @typescript-eslint/no-var-requires */ function requirePage(): FoHomePageInterface { diff --git a/src/pages/FO/login/index.ts b/src/pages/FO/login/index.ts index ee8167e2..11db7e97 100644 --- a/src/pages/FO/login/index.ts +++ b/src/pages/FO/login/index.ts @@ -1,7 +1,8 @@ import type {FoLoginPageInterface} from '@interfaces/FO/login'; +import testContext from '@utils/testContext'; import semver from 'semver'; -const psVersion = global.getPSVersion(); +const psVersion = testContext.getPSVersion(); /* eslint-disable global-require, @typescript-eslint/no-var-requires */ function requirePage(): FoLoginPageInterface { diff --git a/src/types/globals.d.ts b/src/types/globals.d.ts index 448dc170..54f42cbd 100644 --- a/src/types/globals.d.ts +++ b/src/types/globals.d.ts @@ -12,17 +12,6 @@ declare global { var maildevConfig: GlobalMaildevConfig; var keycloakConfig: GlobalKeycloakConfig; var browserErrors: GlobalBrowserErrors; - - // eslint-disable-next-line no-inner-declarations - function getPSVersion(): string { - if (!process.env.PS_VERSION) { - return '0.0.0'; - } - if (process.env.PS_VERSION === 'nightly') { - return '99.99.99'; - } - return process.env.PS_VERSION; - } } export {}; diff --git a/src/utils/testContext.ts b/src/utils/testContext.ts index 7a9467ae..33b0cc9c 100644 --- a/src/utils/testContext.ts +++ b/src/utils/testContext.ts @@ -30,4 +30,17 @@ export default { throw Error('This error is thrown to just generate a report with failed steps'); } }, + /** + * Return the version of current PrestaShop (depending the env value `PS_VERSION`) + * @returns string + */ + getPSVersion(): string { + if (!process.env.PS_VERSION) { + return '0.0.0'; + } + if (process.env.PS_VERSION === 'nightly') { + return '99.99.99'; + } + return process.env.PS_VERSION; + } }; From 8d9c3caac2c7c002b66104890963909e1f2eded2 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 24 Jan 2024 13:28:10 +0100 Subject: [PATCH 2/3] Bump version to 0.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c2f56a79..e07323cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prestashop-core/ui-testing", - "version": "0.0.5", + "version": "0.0.6", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From 4d9f7929d1c31635547dee72e633426af9ae4c4c Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Wed, 24 Jan 2024 13:30:11 +0100 Subject: [PATCH 3/3] Fixed ESLint error --- src/utils/testContext.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/testContext.ts b/src/utils/testContext.ts index 33b0cc9c..1ead0e61 100644 --- a/src/utils/testContext.ts +++ b/src/utils/testContext.ts @@ -42,5 +42,5 @@ export default { return '99.99.99'; } return process.env.PS_VERSION; - } + }, };