-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from nesrineabdmouleh/addMethodsToInstallModule
Add methods to install module for all PS versions
- Loading branch information
Showing
21 changed files
with
770 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
src/interfaces/BO/modules/modulesAndServices/installedModules.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
src/pages/BO/modules/modulesAndServices/installedModules.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
39 changes: 39 additions & 0 deletions
39
src/versions/1.7.0/pages/BO/modules/modulesAndServices/selection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
38 changes: 38 additions & 0 deletions
38
src/versions/1.7.1/pages/BO/modules/modulesAndServices/installedModules.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
38 changes: 38 additions & 0 deletions
38
src/versions/1.7.1/pages/BO/modules/modulesAndServices/selection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
39 changes: 39 additions & 0 deletions
39
src/versions/1.7.2/pages/BO/modules/modulesAndServices/installedModules.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
40 changes: 40 additions & 0 deletions
40
src/versions/1.7.2/pages/BO/modules/modulesAndServices/selection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
Oops, something went wrong.