Skip to content

Commit

Permalink
Merge pull request #305 from nesrineabdmouleh/addMethodsToInstallModule
Browse files Browse the repository at this point in the history
Add methods to install module for all PS versions
  • Loading branch information
Progi1984 authored Dec 27, 2024
2 parents a76f913 + a1189e3 commit 92f687b
Show file tree
Hide file tree
Showing 21 changed files with 770 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ export {default as boLanguagesCreatePage} from '@pages/BO/international/language
export {default as boLocalizationPage} from '@pages/BO/international/localization';
export {default as boLoginPage} from '@pages/BO/login';
export {default as boMaintenancePage} from '@pages/BO/shopParameters/general/maintenance';
export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager';
export {default as boMarketplacePage} from '@pages/BO/modules/marketplace';
export {default as boInstalledModulesPage} from '@pages/BO/modules/modulesAndServices/installedModules';
export {default as boModuleCatalogPage} from '@pages/BO/modules/moduleCatalog';
export {default as boModuleManagerAlertsPage} from '@pages/BO/modules/moduleManager/alerts';
export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager';
export {default as boModuleManagerUninstalledModulesPage} from '@pages/BO/modules/moduleManager/uninstalledModules';
export {default as boModuleManagerUpdatesPage} from '@pages/BO/modules/moduleManager/updates';
export {default as boModuleSelectionPage} from '@pages/BO/modules/modulesAndServices/selection';
export {default as boMyProfilePage} from '@pages/BO/advancedParameters/team/myProfile';
export {default as boNewExperimentalFeaturesPage} from '@pages/BO/advancedParameters/newExperimentalFeatures';
export {default as boOrdersPage} from '@pages/BO/orders';
Expand Down
11 changes: 11 additions & 0 deletions src/interfaces/BO/modules/marketplace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {BOBasePagePageInterface} from '@interfaces/BO';
import type {Page} from '@playwright/test';

export interface MarketplacePageInterface extends BOBasePagePageInterface {
readonly installMessageSuccessful: (moduleTag: string) => string;
readonly pageTitle: string;

goToMarketplacePage(page: Page): Promise<void>;
installModule(page: Page, moduleTag: string): Promise<string|null>;
goToModuleConfigurationPage(page:Page):Promise<void>;
}
9 changes: 9 additions & 0 deletions src/interfaces/BO/modules/moduleCatalog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {BOBasePagePageInterface} from '@interfaces/BO';
import type {Page} from '@playwright/test';

export interface ModuleCatalogPageInterface extends BOBasePagePageInterface {
readonly installMessageSuccessful: (moduleTag: string) => string;
readonly pageTitle: string;

installModule(page: Page, moduleTag: string): Promise<string | null>;
}
12 changes: 12 additions & 0 deletions src/interfaces/BO/modules/modulesAndServices/installedModules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {BOBasePagePageInterface} from '@interfaces/BO';
import type {Page} from '@playwright/test';
import FakerModule from '@data/faker/module';

export interface InstalledModulesPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;

goToSelectionPage(page: Page): Promise<void>;
goToModuleConfigurationPage(page:Page, moduleTag:string):Promise<void>;
isModuleVisible(page: Page, module: FakerModule): Promise<boolean>,
searchModule(page: Page, module: FakerModule): Promise<boolean>;
}
10 changes: 10 additions & 0 deletions src/interfaces/BO/modules/modulesAndServices/selection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {BOBasePagePageInterface} from '@interfaces/BO';
import type {Page} from '@playwright/test';

export interface SelectionPageInterface extends BOBasePagePageInterface {
readonly installMessageSuccessful: (moduleTag: string) => string;
readonly pageTitle: string;

installModule(page: Page, moduleTag: string): Promise<string | null>;
goToInstalledModulesPage(page: Page): Promise<void>;
}
16 changes: 16 additions & 0 deletions src/pages/BO/modules/marketplace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type {MarketplacePageInterface} from '@interfaces/BO/modules/marketplace';
import testContext from '@utils/test';
import semver from 'semver';

const psVersion = testContext.getPSVersion();

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): MarketplacePageInterface {
if (semver.gte(psVersion, '7.6.0')) {
return require('@versions/mock/pages/BO/modules/marketplace');
}
return require('@versions/1.7.5/pages/BO/modules/marketplace');
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

export default requirePage();
9 changes: 9 additions & 0 deletions src/pages/BO/modules/moduleCatalog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {ModuleCatalogPageInterface} from '@interfaces/BO/modules/moduleCatalog';

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): ModuleCatalogPageInterface {
return require('@versions/1.7.6/pages/BO/modules/moduleCatalog');
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

export default requirePage();
22 changes: 22 additions & 0 deletions src/pages/BO/modules/modulesAndServices/installedModules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules';
import testContext from '@utils/test';
import semver from 'semver';

const psVersion = testContext.getPSVersion();

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): InstalledModulesPageInterface {
if (semver.gte(psVersion, '7.5.0')) {
return require('@versions/mock/pages/BO/modules/modulesAndServices/installedModules');
}
if (semver.lt(psVersion, '7.2.0')) {
return require('@versions/1.7.1/pages/BO/modules/modulesAndServices/installedModules').installedModulesPage;
}
if (semver.lt(psVersion, '7.3.0')) {
return require('@versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules').installedModulesPage;
}
return require('@versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules').installedModulesPage;
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

export default requirePage();
25 changes: 25 additions & 0 deletions src/pages/BO/modules/modulesAndServices/selection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection';
import testContext from '@utils/test';
import semver from 'semver';

const psVersion = testContext.getPSVersion();

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): SelectionPageInterface {
if (semver.gte(psVersion, '7.5.0')) {
return require('@versions/mock/pages/BO/modules/modulesAndServices/selection');
}
if (semver.lt(psVersion, '7.1.0')) {
return require('@versions/1.7.0/pages/BO/modules/modulesAndServices/selection').selectionPage;
}
if (semver.lt(psVersion, '7.2.0')) {
return require('@versions/1.7.1/pages/BO/modules/modulesAndServices/selection').selectionPage;
}
if (semver.lt(psVersion, '7.3.0')) {
return require('@versions/1.7.2/pages/BO/modules/modulesAndServices/selection').selectionPage;
}
return require('@versions/1.7.4/pages/BO/modules/modulesAndServices/selection').selectionPage;
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

export default requirePage();
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Import pages
import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection';
import {SelectionPage} from '@versions/1.7.1/pages/BO/modules/modulesAndServices/selection';
import {Page} from '@playwright/test';

/**
* Bo selection page, contains functions that can be used on the page
* @class
* @extends ProductsPage
*/
class SelectionVersion extends SelectionPage implements SelectionPageInterface {
/**
* @constructs
* Setting up texts and selectors to use on selection page
*/
constructor() {
super();

// Selectors
this.alertSuccessBlock = '#main-div div.flash-message-list.alert.alert-success';
}

/**
* Install the module and return success message
* @param {Page} page
* @param {string} moduleTag
* @returns {Promise<string|null>}
*/
async installModule(page: Page, moduleTag: string): Promise<string | null> {
await page.locator(this.searchModuleInput).fill(moduleTag);
await page.keyboard.press('Enter');
await page.locator(this.installModuleButton).click();

return this.getAlertSuccessBlockContent(page);
}
}

const selectionPage = new SelectionVersion();
export {selectionPage, SelectionVersion as SelectionPage};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Import pages
import type {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules';
import {InstalledModulesPage} from '@versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules';
import {Page} from '@playwright/test';

/**
* Bo installed Modules page, contains functions that can be used on the page
* @class
* @extends ProductsPage
*/
class InstalledModulesVersion extends InstalledModulesPage implements InstalledModulesPageInterface {
private readonly pageTitleSelector: string;

/**
* @constructs
* Setting up texts and selectors to use on InstalledModules page
*/
constructor() {
super();

this.pageTitle = 'Manage installed modules';

// Selectors
this.pageTitleSelector = '#main-div div.header-toolbar h2';
}

/**
* Get page title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getPageTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.pageTitleSelector);
}
}

const installedModulesPage = new InstalledModulesVersion();
export {installedModulesPage, InstalledModulesVersion as InstalledModulesPage};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Import pages
import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection';
import {SelectionPage} from '@versions/1.7.2/pages/BO/modules/modulesAndServices/selection';
import {Page} from '@playwright/test';

/**
* Bo selection page, contains functions that can be used on the page
* @class
* @extends ProductsPage
*/
class SelectionVersion extends SelectionPage implements SelectionPageInterface {
private readonly pageTitleSelector: string;

/**
* @constructs
* Setting up texts and selectors to use on selection page
*/
constructor() {
super();

this.pageTitle = 'Module selection';

// Selectors
this.pageTitleSelector = '#main-div div.header-toolbar h2';
}

/**
* Get page title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getPageTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.pageTitleSelector);
}
}

const selectionPage = new SelectionVersion();
export {selectionPage, SelectionVersion as SelectionPage};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Import pages
import type {InstalledModulesPageInterface} from '@interfaces/BO/modules/modulesAndServices/installedModules';
import {InstalledModulesPage} from '@versions/1.7.4/pages/BO/modules/modulesAndServices/installedModules';
import {Page} from '@playwright/test';
import FakerModule from '@data/faker/module';

/**
* Bo installed modules page, contains functions that can be used on the page
* @class
* @extends ProductsPage
*/
class InstalledModulesVersion extends InstalledModulesPage implements InstalledModulesPageInterface {
/**
* @constructs
* Setting up texts and selectors to use on installed modules page
*/
constructor() {
super();

// Selectors
this.searchModuleTagInput = 'div.module-top-menu input.pstaggerAddTagInput';
}

/**
* Search Module in Page module Catalog
* @param page {Page} Browser tab
* @param module {FakerModule} Tag of the Module
* @return {Promise<boolean>}
*/
async searchModule(page: Page, module: FakerModule): Promise<boolean> {
await page.locator(this.searchModuleTagInput).fill(module.tag);
await page.keyboard.press('Enter');

return this.isModuleVisible(page, module);
}
}

const installedModulesPage = new InstalledModulesVersion();
export {installedModulesPage, InstalledModulesVersion as InstalledModulesPage};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Import pages
import type {SelectionPageInterface} from '@interfaces/BO/modules/modulesAndServices/selection';
import {SelectionPage} from '@versions/1.7.4/pages/BO/modules/modulesAndServices/selection';
import {Page} from '@playwright/test';

/**
* Bo selection page, contains functions that can be used on the page
* @class
* @extends ProductsPage
*/
class SelectionVersion extends SelectionPage implements SelectionPageInterface {
/**
* @constructs
* Setting up texts and selectors to use on selection page
*/
constructor() {
super();

// Selectors
this.installModuleButton = '.btn-group[action*=\'install\']';
this.installedModulesLink = '.page-head-tabs a[href*=\'module/manage\']';
}

/**
* Install the module and return success message
* @param {Page} page
* @param {string} moduleTag
* @returns {Promise<string|null>}
*/
async installModule(page: Page, moduleTag: string): Promise<string | null> {
await page.locator(this.searchModuleInput).fill(moduleTag);
await page.keyboard.press('Enter');
await page.locator(this.installModuleButton).click();

return this.getGrowlMessageContent(page);
}
}

const selectionPage = new SelectionVersion();
export {selectionPage, SelectionVersion as SelectionPage};
Loading

0 comments on commit 92f687b

Please sign in to comment.