Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed use of getPSVersion #13

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
},
};