Skip to content

Commit 9c546e9

Browse files
committed
@pages/BO/modules/moduleManager : Add router to go to the ModuleManager
1 parent 43dbc11 commit 9c546e9

11 files changed

Lines changed: 148 additions & 20 deletions

File tree

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export {default as FakerZone} from '@data/faker/zone';
184184
export * as CommonPage from '@pages/commonPage';
185185
// Export Pages BO
186186
export * as BOBasePage from '@pages/BO/BOBasePage';
187+
export {default as boRouterPage} from '@pages/BO/BORouterPage';
187188
export {default as boLoginPage} from '@pages/BO/login';
188189
export {default as boDashboardPage} from '@pages/BO/dashboard';
189190
export {default as boDesignPositionsPage} from '@pages/BO/design/positions/index';

src/interfaces/BO/modules/moduleManager/selection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import type {Page} from '@playwright/test';
33

44
export interface ModuleManagerSelectionPageInterface extends BOBasePagePageInterface {
55
readonly installMessageSuccessful: (moduleTag: string) => string;
6+
readonly pageTitle: string;
67

78
goToTabSelection(page: Page): Promise<void>;
9+
goToTabInstalledModules(page: Page): Promise<void>;
810
installModule(page: Page, moduleTag: string): Promise<boolean>;
911
}

src/interfaces/BO/router.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type {BOBasePagePageInterface} from '@interfaces/BO/index';
2+
import type {Frame, Page} from '@playwright/test';
3+
4+
export interface BORouterPageInterface extends BOBasePagePageInterface {
5+
goToModuleManagerPage(page: Page): Promise<void>;
6+
}

src/pages/BO/BOBasePage.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -731,22 +731,31 @@ export default class BOBasePage extends CommonPage implements BOBasePagePageInte
731731
* @returns {Promise<void>}
732732
*/
733733
async goToSubMenu(page: Page, parentSelector: string, linkSelector: string): Promise<void> {
734-
await this.clickSubMenu(page, parentSelector);
735-
await this.scrollTo(page, linkSelector);
736-
await this.clickAndWaitForURL(page, linkSelector);
734+
const psVersion = testContext.getPSVersion();
737735

738-
const shopVersion = testContext.getPSVersion();
739736
let linkActiveClass: string = '-active';
740737

741-
// >= 1.7.8.0
742-
if (semver.gte(shopVersion, '7.8.0')) {
743-
linkActiveClass = 'link-active';
744-
}
738+
// >= 1.7.4.0
739+
if (semver.gte(psVersion, '7.4.0')) {
740+
await this.clickSubMenu(page, parentSelector);
741+
await this.scrollTo(page, linkSelector);
742+
await this.clickAndWaitForURL(page, linkSelector);
745743

746-
if (await this.isSidebarCollapsed(page)) {
747-
await this.waitForHiddenSelector(page, `${linkSelector}.${linkActiveClass}`);
744+
// >= 1.7.8.0
745+
if (semver.gte(psVersion, '7.8.0')) {
746+
linkActiveClass = 'link-active';
747+
}
748+
749+
if (await this.isSidebarCollapsed(page)) {
750+
await this.waitForHiddenSelector(page, `${linkSelector}.${linkActiveClass}`);
751+
} else {
752+
await this.waitForVisibleSelector(page, `${linkSelector}.${linkActiveClass}`);
753+
}
748754
} else {
749-
await this.waitForVisibleSelector(page, `${linkSelector}.${linkActiveClass}`);
755+
await page.locator(parentSelector).hover();
756+
await this.waitForVisibleSelector(page, linkSelector);
757+
await this.clickAndWaitForURL(page, linkSelector);
758+
await this.waitForVisibleSelector(page, `${parentSelector}.${linkActiveClass}`);
750759
}
751760
}
752761

src/pages/BO/BORouterPage.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {BORouterPageInterface} from '@interfaces/BO/router';
2+
import BOBasePage from '@pages/BO/BOBasePage';
3+
import boDashboardPage from '@pages/BO/dashboard/index';
4+
import boModuleManagerPage from '@pages/BO/modules/moduleManager/index';
5+
import boModuleManagerSelectionPage from '@pages/BO/modules/moduleManager/selection';
6+
import testContext from '@utils/testContext';
7+
import type {Page} from 'playwright-core';
8+
import semver from 'semver';
9+
10+
class BORouterPage extends BOBasePage implements BORouterPageInterface {
11+
async goToModuleManagerPage(page: Page): Promise<void> {
12+
const psVersion = testContext.getPSVersion();
13+
const pageTitle = await this.getPageTitle(page);
14+
const boModuleManagerLinkPageTitle = semver.lt(psVersion, '7.4.0')
15+
? boModuleManagerSelectionPage.pageTitle
16+
: boModuleManagerPage.pageTitle;
17+
18+
// Check if we are not already on the page
19+
if (!pageTitle.includes(boModuleManagerLinkPageTitle)) {
20+
await boDashboardPage.goToSubMenu(
21+
page,
22+
boDashboardPage.modulesParentLink,
23+
boDashboardPage.moduleManagerLink,
24+
);
25+
await boDashboardPage.closeSfToolBar(page);
26+
}
27+
28+
if (semver.lt(psVersion, '7.4.0')) {
29+
console.log('goToTabInstalledModules');
30+
await boModuleManagerSelectionPage.goToTabInstalledModules(page);
31+
}
32+
}
33+
}
34+
35+
export default new BORouterPage();

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ function requirePage(): ModuleManagerSelectionPageInterface {
99
if (semver.gte(psVersion, '7.5.0')) {
1010
return require('@versions/mock/pages/BO/modules/moduleManager/selection');
1111
}
12-
return require('@versions/1.7.4/pages/BO/modules/moduleManager/selection');
12+
if (semver.gte(psVersion, '7.4.0')) {
13+
return require('@versions/1.7.4/pages/BO/modules/moduleManager/selection').selectionPage;
14+
}
15+
return require('@versions/1.7.3/pages/BO/modules/moduleManager/selection');
1316
}
1417
/* eslint-enable global-require, @typescript-eslint/no-var-requires */
1518

src/pages/FO/FOBasePage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Import pages
22
import {FOBasePagePageInterface} from '@interfaces/FO';
33
import CommonPage from '@pages/commonPage';
4-
import testContext from '@utils/testContext';
4+
import utilsTest from '@utils/test';
55
import type {Locator, Page} from 'playwright';
66
import semver from 'semver';
77

@@ -792,7 +792,7 @@ export default class FOBasePage extends CommonPage implements FOBasePagePageInte
792792
}
793793

794794
private getLanguageSelector(page: Page, lang: string): string|Locator {
795-
const psVersion = testContext.getPSVersion();
795+
const psVersion = utilsTest.getPSVersion();
796796

797797
// >= 1.7.5.0
798798
if (semver.gte(psVersion, '7.5.0')) {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {ModuleManagerSelectionPageInterface} from '@interfaces/BO/modules/moduleManager/selection';
2+
import {Page} from '@playwright/test';
3+
import {SelectionPage} from '@versions/1.7.4/pages/BO/modules/moduleManager/selection';
4+
5+
/**
6+
* @class
7+
* @extends BOBasePage
8+
*/
9+
class SelectionPageVersion extends SelectionPage implements ModuleManagerSelectionPageInterface {
10+
/**
11+
* @constructs
12+
* Setting up titles and selectors to use on module catalog page
13+
*/
14+
constructor() {
15+
super();
16+
17+
// Selectors
18+
this.subTabSelection = '#head_tabs a.tab:nth-child(1)';
19+
this.subTabInstalledModules = '#head_tabs a.tab:nth-child(2)';
20+
}
21+
22+
/**
23+
* Go to the "Selection" tab
24+
* @param {Page} page
25+
* @returns {Promise<void>}
26+
*/
27+
async goToTabSelection(page: Page): Promise<void> {
28+
await this.waitForSelectorAndClick(page, this.subTabSelection);
29+
await this.waitForVisibleSelector(page, `${this.subTabSelection}.current`, 2000);
30+
}
31+
32+
/**
33+
* Go to the "Installed Modules" tab
34+
* @param {Page} page
35+
* @returns {Promise<void>}
36+
*/
37+
async goToTabInstalledModules(page: Page): Promise<void> {
38+
await this.waitForSelectorAndClick(page, this.subTabInstalledModules);
39+
await this.waitForVisibleSelector(page, `${this.subTabInstalledModules}.current`, 2000);
40+
}
41+
}
42+
43+
module.exports = new SelectionPageVersion();

src/versions/1.7.4/pages/BO/modules/moduleManager/selection.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import {Page} from '@playwright/test';
77
* @extends BOBasePage
88
*/
99
class SelectionPage extends BOBasePage implements ModuleManagerSelectionPageInterface {
10+
public readonly pageTitle: string;
11+
1012
public readonly installMessageSuccessful: (moduleTag: string) => string;
1113

12-
private readonly subTabUninstalledModules: string;
14+
protected subTabSelection: string;
15+
16+
protected subTabInstalledModules: string;
1317

1418
private readonly searchInput: string;
1519

@@ -24,10 +28,13 @@ class SelectionPage extends BOBasePage implements ModuleManagerSelectionPageInte
2428
constructor() {
2529
super();
2630

31+
this.pageTitle = 'Module selection';
32+
2733
this.installMessageSuccessful = (moduleTag: string) => `Install action on module ${moduleTag} succeeded.`;
2834

2935
// Selectors
30-
this.subTabUninstalledModules = '#subtab-AdminModulesCatalog';
36+
this.subTabSelection = '#subtab-AdminModulesCatalog';
37+
this.subTabInstalledModules = '#subtab-AdminModulesManage';
3138
this.searchInput = '#search-input-group input.pstaggerAddTagInput';
3239
this.searchButton = '#module-search-button';
3340
this.installModuleButton = (moduleTag: string) => `div[data-tech-name="${moduleTag}"] button.module_action_menu_install`;
@@ -42,8 +49,18 @@ class SelectionPage extends BOBasePage implements ModuleManagerSelectionPageInte
4249
* @returns {Promise<void>}
4350
*/
4451
async goToTabSelection(page: Page): Promise<void> {
45-
await this.waitForSelectorAndClick(page, this.subTabUninstalledModules);
46-
await this.waitForVisibleSelector(page, `${this.subTabUninstalledModules}.active`, 2000);
52+
await this.waitForSelectorAndClick(page, this.subTabSelection);
53+
await this.waitForVisibleSelector(page, `${this.subTabSelection}.active`, 2000);
54+
}
55+
56+
/**
57+
* Go to the "Selection" tab
58+
* @param {Page} page
59+
* @returns {Promise<void>}
60+
*/
61+
async goToTabInstalledModules(page: Page): Promise<void> {
62+
await this.waitForSelectorAndClick(page, this.subTabInstalledModules);
63+
await this.waitForVisibleSelector(page, `${this.subTabInstalledModules}.active`, 2000);
4764
}
4865

4966
/**
@@ -62,4 +79,5 @@ class SelectionPage extends BOBasePage implements ModuleManagerSelectionPageInte
6279
}
6380
}
6481

65-
module.exports = new SelectionPage();
82+
const selectionPage = new SelectionPage();
83+
export {selectionPage, SelectionPage};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ class ModuleManagerPage extends BOBasePage implements ModuleManagerPageInterface
440440

441441
if (cancel) {
442442
await this.waitForSelectorAndClick(page, this.modalConfirmCancel(module.tag, action));
443-
await this.elementNotVisible(page, this.modalConfirmAction(module.tag, action), 10000);
443+
await this.waitForHiddenSelector(page, this.modalConfirmAction(module.tag, action), 10000);
444444
return '';
445445
}
446446
if (action === 'uninstall' && forceDeletion) {

0 commit comments

Comments
 (0)