Skip to content

Commit ebc086e

Browse files
authored
Merge pull request #13 from Progi1984/fixNIghtlyVersion
Fixed use of getPSVersion
2 parents 97acfa7 + 4d9f792 commit ebc086e

File tree

11 files changed

+30
-20
lines changed

11 files changed

+30
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@prestashop-core/ui-testing",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/pages/BO/dashboard/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {DashboardPageInterface} from '@interfaces/BO/dashboard';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require */
78
function requirePage(): DashboardPageInterface {

src/pages/BO/login/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {LoginPageInterface} from '@interfaces/BO/login';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require */
78
function requirePage(): LoginPageInterface {

src/pages/BO/modules/blockwishlist/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {ModuleBlockwishlistMainPageInterface} from '@interfaces/BO/modules/blockwishlist/index';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require */
78
function requirePage(): ModuleBlockwishlistMainPageInterface {

src/pages/BO/modules/blockwishlist/statistics.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {ModuleBlockwishlistStatisticsPageInterface} from '@interfaces/BO/modules/blockwishlist/statistics';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require */
78
function requirePage(): ModuleBlockwishlistStatisticsPageInterface {

src/pages/BO/modules/moduleManager/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {ModuleManagerPageInterface} from '@interfaces/BO/modules/moduleManager';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
78
function requirePage(): ModuleManagerPageInterface {

src/pages/FO/category/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {FoCategoryPageInterface} from '@interfaces/FO/category';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require */
78
function requirePage(): FoCategoryPageInterface {

src/pages/FO/home/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {FoHomePageInterface} from '@interfaces/FO/home';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
78
function requirePage(): FoHomePageInterface {

src/pages/FO/login/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {FoLoginPageInterface} from '@interfaces/FO/login';
2+
import testContext from '@utils/testContext';
23
import semver from 'semver';
34

4-
const psVersion = global.getPSVersion();
5+
const psVersion = testContext.getPSVersion();
56

67
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
78
function requirePage(): FoLoginPageInterface {

src/types/globals.d.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ declare global {
1212
var maildevConfig: GlobalMaildevConfig;
1313
var keycloakConfig: GlobalKeycloakConfig;
1414
var browserErrors: GlobalBrowserErrors;
15-
16-
// eslint-disable-next-line no-inner-declarations
17-
function getPSVersion(): string {
18-
if (!process.env.PS_VERSION) {
19-
return '0.0.0';
20-
}
21-
if (process.env.PS_VERSION === 'nightly') {
22-
return '99.99.99';
23-
}
24-
return process.env.PS_VERSION;
25-
}
2615
}
2716

2817
export {};

src/utils/testContext.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,17 @@ export default {
3030
throw Error('This error is thrown to just generate a report with failed steps');
3131
}
3232
},
33+
/**
34+
* Return the version of current PrestaShop (depending the env value `PS_VERSION`)
35+
* @returns string
36+
*/
37+
getPSVersion(): string {
38+
if (!process.env.PS_VERSION) {
39+
return '0.0.0';
40+
}
41+
if (process.env.PS_VERSION === 'nightly') {
42+
return '99.99.99';
43+
}
44+
return process.env.PS_VERSION;
45+
},
3346
};

0 commit comments

Comments
 (0)