Skip to content

Commit

Permalink
Merge pull request #17 from Progi1984/178x
Browse files Browse the repository at this point in the history
Support for 1.7.8 : Module Manager (Uninstalled modules) & Classic Order Confirmation
  • Loading branch information
Progi1984 authored Mar 19, 2024
2 parents b04bde7 + a084128 commit 0cce5ec
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 7 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.8",
"version": "0.0.9",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export {default as boLoginPage} from '@pages/BO/login';
export {default as boDashboardPage} from '@pages/BO/dashboard';
export {default as boOrdersPage} from '@pages/BO/orders';
export {default as boModuleManagerPage} from '@pages/BO/modules/moduleManager';
export {default as boModuleManagerUninstalledModulesPage} from '@pages/BO/modules/moduleManager/uninstalledModules';
// Export Pages FO
export * as FOBasePage from '@pages/FO/FOBasePage';
// Export Pages FO/Classic
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces/BO/modules/moduleManager/uninstalledModules.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 ModuleManagerUninstalledModulesPageInterface extends BOBasePagePageInterface {
readonly installMessageSuccessful: (moduleTag: string) => string;

goToTabUninstalledModules(page: Page): Promise<void>;
installModule(page: Page, moduleTag: string): Promise<string|null>;
}
22 changes: 19 additions & 3 deletions src/pages/BO/BOBasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import CommonPage from '@pages/commonPage';

import {Frame, Page} from '@playwright/test';
import testContext from '@utils/testContext';
import type {PageFunction} from 'playwright-core/types/structs';
import semver from 'semver';

/**
* BO parent page, contains functions that can be used on all BO page
Expand Down Expand Up @@ -715,10 +717,18 @@ export default class BOBasePage extends CommonPage {
await this.clickSubMenu(page, parentSelector);
await this.scrollTo(page, linkSelector);
await this.clickAndWaitForURL(page, linkSelector);

const psVersion = testContext.getPSVersion();
let linkActiveClass: string = '-active';

if (semver.gte(psVersion, '8.0.0')) {
linkActiveClass = 'link-active';
}

if (await this.isSidebarCollapsed(page)) {
await this.waitForHiddenSelector(page, `${linkSelector}.link-active`);
await this.waitForHiddenSelector(page, `${linkSelector}.${linkActiveClass}`);
} else {
await this.waitForVisibleSelector(page, `${linkSelector}.link-active`);
await this.waitForVisibleSelector(page, `${linkSelector}.${linkActiveClass}`);
}
}

Expand Down Expand Up @@ -1044,7 +1054,13 @@ export default class BOBasePage extends CommonPage {
* @return {Promise<string|null>}
*/
async getGrowlMessageContent(page: Page, timeout: number = 10000): Promise<string | null> {
return page.textContent(this.growlMessageBlock, {timeout});
const psVersion = testContext.getPSVersion();
let {growlMessageBlock} = this;

if (semver.lt(psVersion, '8.0.0')) {
growlMessageBlock = `${this.growlDiv} .growl-message`;
}
return page.textContent(growlMessageBlock, {timeout});
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/pages/BO/modules/moduleManager/uninstalledModules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type {ModuleManagerUninstalledModulesPageInterface} from '@interfaces/BO/modules/moduleManager/uninstalledModules';
import testContext from '@utils/testContext';
import semver from 'semver';

const psVersion = testContext.getPSVersion();

/* eslint-disable global-require, @typescript-eslint/no-var-requires */
function requirePage(): ModuleManagerUninstalledModulesPageInterface {
if (semver.gte(psVersion, '8.0.0')) {
return require('@versions/mock/pages/BO/modules/moduleManager/uninstalledModules');
}
return require('@versions/1.7.8/pages/BO/modules/moduleManager/uninstalledModules');
}
/* eslint-enable global-require, @typescript-eslint/no-var-requires */

export default requirePage();
4 changes: 2 additions & 2 deletions src/pages/FO/classic/checkout/orderConfirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const psVersion = testContext.getPSVersion();

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {ModuleManagerUninstalledModulesPageInterface} from '@interfaces/BO/modules/moduleManager/uninstalledModules';
import BOBasePage from '@pages/BO/BOBasePage';
import {Page} from '@playwright/test';

/**
* Module catalog page, contains selectors and functions for the page
* @class
* @extends BOBasePage
*/
class UninstalledModules extends BOBasePage implements ModuleManagerUninstalledModulesPageInterface {
public readonly installMessageSuccessful: (moduleTag: string) => string;

private readonly subTabUninstalledModules: string;

private readonly installModuleButton: (moduleName: string) => string;

/**
* @constructs
* Setting up titles and selectors to use on module catalog page
*/
constructor() {
super();

this.installMessageSuccessful = (moduleTag: string) => `Install action on module ${moduleTag} succeeded.`;

// Selectors
this.subTabUninstalledModules = '#subtab-AdminPsMboUninstalledModules';
this.installModuleButton = (moduleTag: string) => `div[data-tech-name="${moduleTag}"] button.module_action_menu_install`;
}

/*
Methods
*/
/**
* Go to the "Uninstalled modules" tab
* @param {Page} page
* @returns {Promise<void>}
*/
async goToTabUninstalledModules(page: Page): Promise<void> {
await this.waitForSelectorAndClick(page, this.subTabUninstalledModules);
await this.waitForVisibleSelector(page, `${this.subTabUninstalledModules}.active`, 2000);
}

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

return this.getGrowlMessageContent(page);
}
}

module.exports = new UninstalledModules();
23 changes: 23 additions & 0 deletions src/versions/1.7.8/pages/FO/classic/checkout/orderConfirmation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Import pages
import type {FoCheckoutOrderConfirmationPageInterface} from '@interfaces/FO/checkout/orderConfirmation';
import {OrderConfirmationPage} from '@versions/develop/pages/FO/classic/checkout/orderConfirmation';

/**
* Order confirmation page, contains functions that can be used on the page
* @class
* @extends OrderConfirmationPage
*/
class OrderConfirmation extends OrderConfirmationPage implements FoCheckoutOrderConfirmationPageInterface {
/**
* @constructs
* Setting up texts and selectors to use on order confirmation page
*/
constructor(theme: string = 'classic') {
super(theme);

// Selectors
this.orderReferenceValue = `${this.orderDetailsTable} ul li:nth-child(1)`;
}
}

module.exports = new OrderConfirmation();
2 changes: 1 addition & 1 deletion src/versions/develop/pages/BO/orders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Order extends BOBasePage implements BOOrdersPageInterface {
this.tableEmptyRow = `${this.tableRows}.empty_row`;
this.tableColumn = (row: number, column: string) => `${this.tableRow(row)} td.column-${column}`;
this.tableColumnStatus = (row: number) => `${this.tableRow(row)} td.column-osname`;
this.updateStatusInTableButton = (row: number) => `${this.tableColumnStatus(row)}.choice-type.text-left > div > button`;
this.updateStatusInTableButton = (row: number) => `${this.tableColumnStatus(row)}.choice-type > div > button`;
this.updateStatusInTableDropdown = (row: number) => `${this.tableColumnStatus(row)} div.js-choice-options`;
this.updateStatusInTableDropdownChoice = (row: number, statusId: number) => `${this.updateStatusInTableDropdown(row)}`
+ ` button[data-value='${statusId}']`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {ModuleManagerUninstalledModulesPageInterface} from '@interfaces/BO/modules/moduleManager/uninstalledModules';
import BOBasePage from '@pages/BO/BOBasePage';

/**
* Mock Page for unsupported version
* @class
* @extends BOBasePage
*/
class UninstalledModules extends BOBasePage implements ModuleManagerUninstalledModulesPageInterface {
public readonly installMessageSuccessful: (moduleTag: string) => string;

/**
* @constructs
* Setting up titles and selectors to use on module catalog page
*/
constructor() {
super();

this.installMessageSuccessful = () => '';
}

/*
Methods
*/
/**
* Go to the "Uninstalled modules" tab
* @returns {Promise<void>}
*/
async goToTabUninstalledModules(): Promise<void> {
// do nothing.
}

/**
* Install the module and return the growl message
* @returns {Promise<string|null>}
*/
async installModule(): Promise<string|null> {
return '';
}
}

module.exports = new UninstalledModules();

0 comments on commit 0cce5ec

Please sign in to comment.