-
Notifications
You must be signed in to change notification settings - Fork 11
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 #430 from Progi1984/boCMSPageCategoriesCreatePage
Migrate `@pages/BO/design/pages/pageCategory/add` from Core
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
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,10 @@ | ||
import type FakerCMSCategory from '@data/faker/cmsCategory'; | ||
import {BOBasePagePageInterface} from '@interfaces/BO'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
export interface BOCMSPageCategoriesCreatePageInterface extends BOBasePagePageInterface { | ||
readonly pageTitleCreate: string; | ||
readonly pageTitleEdit: string; | ||
|
||
createEditPageCategory(page: Page, pageCategoryData: FakerCMSCategory): Promise<string>; | ||
} |
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 {BOCMSPageCategoriesCreatePageInterface} from '@interfaces/BO/design/pages/category/create'; | ||
|
||
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
function requirePage(): BOCMSPageCategoriesCreatePageInterface { | ||
return require('@versions/develop/pages/BO/design/pages/category/create'); | ||
} | ||
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
|
||
export default requirePage(); |
69 changes: 69 additions & 0 deletions
69
src/versions/develop/pages/BO/design/pages/category/create.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,69 @@ | ||
import type FakerCMSCategory from '@data/faker/cmsCategory'; | ||
import {type BOCMSPageCategoriesCreatePageInterface} from '@interfaces/BO/design/pages/category/create'; | ||
import BOBasePage from '@pages/BO/BOBasePage'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
/** | ||
* Add page category page, contains functions that can be used on the page | ||
* @class | ||
* @extends BOBasePage | ||
*/ | ||
class BOCMSPageCategoriesCreatePage extends BOBasePage implements BOCMSPageCategoriesCreatePageInterface { | ||
public readonly pageTitleCreate: string; | ||
|
||
public readonly pageTitleEdit: string; | ||
|
||
private readonly nameInput: string; | ||
|
||
private readonly displayedToggleInput: (toggle: number) => string; | ||
|
||
private readonly descriptionIframe: string; | ||
|
||
private readonly metaTitleInput: string; | ||
|
||
private readonly metaDescriptionInput: string; | ||
|
||
private readonly saveCategoryButton: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up texts and selectors to use on add page category page | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.pageTitleCreate = `New category • ${global.INSTALL.SHOP_NAME}`; | ||
this.pageTitleEdit = 'Editing category'; | ||
|
||
// Selectors | ||
this.nameInput = '#cms_page_category_name_1'; | ||
this.displayedToggleInput = (toggle: number) => `#cms_page_category_is_displayed_${toggle}`; | ||
this.descriptionIframe = '#cms_page_category_description_1'; | ||
this.metaTitleInput = '#cms_page_category_meta_title_1'; | ||
this.metaDescriptionInput = '#cms_page_category_meta_description_1'; | ||
this.saveCategoryButton = '#save-button'; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Fill form for add/edit page category | ||
* @param page {Page} Browser tab | ||
* @param pageCategoryData {FakerCMSCategory} Data to set on page category form | ||
* @returns {Promise<string>} | ||
*/ | ||
async createEditPageCategory(page: Page, pageCategoryData: FakerCMSCategory): Promise<string> { | ||
await this.setValue(page, this.nameInput, pageCategoryData.name); | ||
await this.setChecked(page, this.displayedToggleInput(pageCategoryData.displayed ? 1 : 0)); | ||
await this.setValue(page, this.descriptionIframe, pageCategoryData.description); | ||
await this.setValue(page, this.metaTitleInput, pageCategoryData.metaTitle); | ||
await this.setValue(page, this.metaDescriptionInput, pageCategoryData.metaDescription); | ||
await this.clickAndWaitForURL(page, this.saveCategoryButton); | ||
|
||
return this.getAlertSuccessBlockParagraphContent(page); | ||
} | ||
} | ||
|
||
module.exports = new BOCMSPageCategoriesCreatePage(); |