Skip to content

Commit

Permalink
Merge pull request #13 from Progi1984/fixNIghtlyVersion
Browse files Browse the repository at this point in the history
Fixed use of getPSVersion
  • Loading branch information
Progi1984 authored Jan 24, 2024
2 parents 97acfa7 + 4d9f792 commit ebc086e
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/BO/modules/blockwishlist/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/BO/modules/blockwishlist/statistics.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/BO/modules/moduleManager/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/FO/category/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/FO/home/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/FO/login/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
11 changes: 0 additions & 11 deletions src/types/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
13 changes: 13 additions & 0 deletions src/utils/testContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
};

0 comments on commit ebc086e

Please sign in to comment.