Skip to content

Commit 0cce5ec

Browse files
authored
Merge pull request #17 from Progi1984/178x
Support for 1.7.8 : Module Manager (Uninstalled modules) & Classic Order Confirmation
2 parents b04bde7 + a084128 commit 0cce5ec

File tree

10 files changed

+171
-7
lines changed

10 files changed

+171
-7
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.8",
3+
"version": "0.0.9",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export {default as boLoginPage} from '@pages/BO/login';
5555
export {default as boDashboardPage} from '@pages/BO/dashboard';
5656
export {default as boOrdersPage} from '@pages/BO/orders';
5757
export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager';
58+
export {default as boModuleManagerUninstalledModulesPage} from '@pages/BO/modules/moduleManager/uninstalledModules';
5859
// Export Pages FO
5960
export * as FOBasePage from '@pages/FO/FOBasePage';
6061
// Export Pages FO/Classic
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {BOBasePagePageInterface} from '@interfaces/BO';
2+
import type {Page} from '@playwright/test';
3+
4+
export interface ModuleManagerUninstalledModulesPageInterface extends BOBasePagePageInterface {
5+
readonly installMessageSuccessful: (moduleTag: string) => string;
6+
7+
goToTabUninstalledModules(page: Page): Promise<void>;
8+
installModule(page: Page, moduleTag: string): Promise<string|null>;
9+
}

src/pages/BO/BOBasePage.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import CommonPage from '@pages/commonPage';
33

44
import {Frame, Page} from '@playwright/test';
5+
import testContext from '@utils/testContext';
56
import type {PageFunction} from 'playwright-core/types/structs';
7+
import semver from 'semver';
68

79
/**
810
* BO parent page, contains functions that can be used on all BO page
@@ -715,10 +717,18 @@ export default class BOBasePage extends CommonPage {
715717
await this.clickSubMenu(page, parentSelector);
716718
await this.scrollTo(page, linkSelector);
717719
await this.clickAndWaitForURL(page, linkSelector);
720+
721+
const psVersion = testContext.getPSVersion();
722+
let linkActiveClass: string = '-active';
723+
724+
if (semver.gte(psVersion, '8.0.0')) {
725+
linkActiveClass = 'link-active';
726+
}
727+
718728
if (await this.isSidebarCollapsed(page)) {
719-
await this.waitForHiddenSelector(page, `${linkSelector}.link-active`);
729+
await this.waitForHiddenSelector(page, `${linkSelector}.${linkActiveClass}`);
720730
} else {
721-
await this.waitForVisibleSelector(page, `${linkSelector}.link-active`);
731+
await this.waitForVisibleSelector(page, `${linkSelector}.${linkActiveClass}`);
722732
}
723733
}
724734

@@ -1044,7 +1054,13 @@ export default class BOBasePage extends CommonPage {
10441054
* @return {Promise<string|null>}
10451055
*/
10461056
async getGrowlMessageContent(page: Page, timeout: number = 10000): Promise<string | null> {
1047-
return page.textContent(this.growlMessageBlock, {timeout});
1057+
const psVersion = testContext.getPSVersion();
1058+
let {growlMessageBlock} = this;
1059+
1060+
if (semver.lt(psVersion, '8.0.0')) {
1061+
growlMessageBlock = `${this.growlDiv} .growl-message`;
1062+
}
1063+
return page.textContent(growlMessageBlock, {timeout});
10481064
}
10491065

10501066
/**
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type {ModuleManagerUninstalledModulesPageInterface} from '@interfaces/BO/modules/moduleManager/uninstalledModules';
2+
import testContext from '@utils/testContext';
3+
import semver from 'semver';
4+
5+
const psVersion = testContext.getPSVersion();
6+
7+
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
8+
function requirePage(): ModuleManagerUninstalledModulesPageInterface {
9+
if (semver.gte(psVersion, '8.0.0')) {
10+
return require('@versions/mock/pages/BO/modules/moduleManager/uninstalledModules');
11+
}
12+
return require('@versions/1.7.8/pages/BO/modules/moduleManager/uninstalledModules');
13+
}
14+
/* eslint-enable global-require, @typescript-eslint/no-var-requires */
15+
16+
export default requirePage();

src/pages/FO/classic/checkout/orderConfirmation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const psVersion = testContext.getPSVersion();
66

77
/* eslint-disable global-require, @typescript-eslint/no-var-requires */
88
function requirePage(): FoCheckoutOrderConfirmationPageInterface {
9-
if (semver.gte(psVersion, '0.0.0')) {
9+
if (semver.gte(psVersion, '8.0.0')) {
1010
return require('@versions/develop/pages/FO/classic/checkout/orderConfirmation').orderConfirmationPage;
1111
}
12-
return require('@versions/develop/pages/FO/classic/checkout/orderConfirmation').orderConfirmationPage;
12+
return require('@versions/1.7.8/pages/FO/classic/checkout/orderConfirmation');
1313
}
1414
/* eslint-enable global-require, @typescript-eslint/no-var-requires */
1515

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {ModuleManagerUninstalledModulesPageInterface} from '@interfaces/BO/modules/moduleManager/uninstalledModules';
2+
import BOBasePage from '@pages/BO/BOBasePage';
3+
import {Page} from '@playwright/test';
4+
5+
/**
6+
* Module catalog page, contains selectors and functions for the page
7+
* @class
8+
* @extends BOBasePage
9+
*/
10+
class UninstalledModules extends BOBasePage implements ModuleManagerUninstalledModulesPageInterface {
11+
public readonly installMessageSuccessful: (moduleTag: string) => string;
12+
13+
private readonly subTabUninstalledModules: string;
14+
15+
private readonly installModuleButton: (moduleName: string) => string;
16+
17+
/**
18+
* @constructs
19+
* Setting up titles and selectors to use on module catalog page
20+
*/
21+
constructor() {
22+
super();
23+
24+
this.installMessageSuccessful = (moduleTag: string) => `Install action on module ${moduleTag} succeeded.`;
25+
26+
// Selectors
27+
this.subTabUninstalledModules = '#subtab-AdminPsMboUninstalledModules';
28+
this.installModuleButton = (moduleTag: string) => `div[data-tech-name="${moduleTag}"] button.module_action_menu_install`;
29+
}
30+
31+
/*
32+
Methods
33+
*/
34+
/**
35+
* Go to the "Uninstalled modules" tab
36+
* @param {Page} page
37+
* @returns {Promise<void>}
38+
*/
39+
async goToTabUninstalledModules(page: Page): Promise<void> {
40+
await this.waitForSelectorAndClick(page, this.subTabUninstalledModules);
41+
await this.waitForVisibleSelector(page, `${this.subTabUninstalledModules}.active`, 2000);
42+
}
43+
44+
/**
45+
* Install the module and return the growl message
46+
* @param {Page} page
47+
* @param {string} moduleTag
48+
* @returns {Promise<string|null>}
49+
*/
50+
async installModule(page: Page, moduleTag: string): Promise<string|null> {
51+
await page.locator(this.installModuleButton(moduleTag)).click();
52+
53+
return this.getGrowlMessageContent(page);
54+
}
55+
}
56+
57+
module.exports = new UninstalledModules();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Import pages
2+
import type {FoCheckoutOrderConfirmationPageInterface} from '@interfaces/FO/checkout/orderConfirmation';
3+
import {OrderConfirmationPage} from '@versions/develop/pages/FO/classic/checkout/orderConfirmation';
4+
5+
/**
6+
* Order confirmation page, contains functions that can be used on the page
7+
* @class
8+
* @extends OrderConfirmationPage
9+
*/
10+
class OrderConfirmation extends OrderConfirmationPage implements FoCheckoutOrderConfirmationPageInterface {
11+
/**
12+
* @constructs
13+
* Setting up texts and selectors to use on order confirmation page
14+
*/
15+
constructor(theme: string = 'classic') {
16+
super(theme);
17+
18+
// Selectors
19+
this.orderReferenceValue = `${this.orderDetailsTable} ul li:nth-child(1)`;
20+
}
21+
}
22+
23+
module.exports = new OrderConfirmation();

src/versions/develop/pages/BO/orders/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Order extends BOBasePage implements BOOrdersPageInterface {
147147
this.tableEmptyRow = `${this.tableRows}.empty_row`;
148148
this.tableColumn = (row: number, column: string) => `${this.tableRow(row)} td.column-${column}`;
149149
this.tableColumnStatus = (row: number) => `${this.tableRow(row)} td.column-osname`;
150-
this.updateStatusInTableButton = (row: number) => `${this.tableColumnStatus(row)}.choice-type.text-left > div > button`;
150+
this.updateStatusInTableButton = (row: number) => `${this.tableColumnStatus(row)}.choice-type > div > button`;
151151
this.updateStatusInTableDropdown = (row: number) => `${this.tableColumnStatus(row)} div.js-choice-options`;
152152
this.updateStatusInTableDropdownChoice = (row: number, statusId: number) => `${this.updateStatusInTableDropdown(row)}`
153153
+ ` button[data-value='${statusId}']`;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {ModuleManagerUninstalledModulesPageInterface} from '@interfaces/BO/modules/moduleManager/uninstalledModules';
2+
import BOBasePage from '@pages/BO/BOBasePage';
3+
4+
/**
5+
* Mock Page for unsupported version
6+
* @class
7+
* @extends BOBasePage
8+
*/
9+
class UninstalledModules extends BOBasePage implements ModuleManagerUninstalledModulesPageInterface {
10+
public readonly installMessageSuccessful: (moduleTag: string) => string;
11+
12+
/**
13+
* @constructs
14+
* Setting up titles and selectors to use on module catalog page
15+
*/
16+
constructor() {
17+
super();
18+
19+
this.installMessageSuccessful = () => '';
20+
}
21+
22+
/*
23+
Methods
24+
*/
25+
/**
26+
* Go to the "Uninstalled modules" tab
27+
* @returns {Promise<void>}
28+
*/
29+
async goToTabUninstalledModules(): Promise<void> {
30+
// do nothing.
31+
}
32+
33+
/**
34+
* Install the module and return the growl message
35+
* @returns {Promise<string|null>}
36+
*/
37+
async installModule(): Promise<string|null> {
38+
return '';
39+
}
40+
}
41+
42+
module.exports = new UninstalledModules();

0 commit comments

Comments
 (0)