-
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 #327 from Progi1984/boAttributesCreatePage
Migrate `@pages/BO/catalog/attributes/addAttribute` from Core
- Loading branch information
Showing
4 changed files
with
101 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 FakerAttribute from '@data/faker/attribute'; | ||
import {BOBasePagePageInterface} from '@interfaces/BO'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
export interface BOAttributesCreatePageInterface extends BOBasePagePageInterface { | ||
readonly createPageTitle: string; | ||
readonly editPageTitle: (name: string) => string; | ||
|
||
addEditAttribute(page: Page, attributeData: FakerAttribute): 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 type {BOAttributesCreatePageInterface} from '@interfaces/BO/catalog/attributes/createAttribute'; | ||
|
||
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
function requirePage(): BOAttributesCreatePageInterface { | ||
return require('@versions/develop/pages/BO/catalog/attributes/createAttribute'); | ||
} | ||
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
|
||
export default requirePage(); |
81 changes: 81 additions & 0 deletions
81
src/versions/develop/pages/BO/catalog/attributes/createAttribute.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,81 @@ | ||
import type FakerAttribute from '@data/faker/attribute'; | ||
import BOBasePage from '@pages/BO/BOBasePage'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
/** | ||
* Add attribute page, contains functions that can be used on the page | ||
* @class | ||
* @extends BOBasePage | ||
*/ | ||
class BOAttributesCreatePage extends BOBasePage { | ||
public readonly createPageTitle: string; | ||
|
||
public readonly editPageTitle: (name: string) => string; | ||
|
||
private readonly nameInput: string; | ||
|
||
private readonly publicNameInput: string; | ||
|
||
private readonly urlInput: string; | ||
|
||
private readonly metaTitleInput: string; | ||
|
||
private readonly indexableToggle: (toggle: number) => string; | ||
|
||
private readonly attributeTypeSelect: string; | ||
|
||
private readonly saveButton: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up texts and selectors to use on add attribute page | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.createPageTitle = `New attribute • ${global.INSTALL.SHOP_NAME}`; | ||
this.editPageTitle = (name: string) => `Editing attribute ${name} • ${global.INSTALL.SHOP_NAME}`; | ||
|
||
// Form selectors | ||
this.nameInput = '#attribute_group_name_1'; | ||
this.publicNameInput = '#attribute_group_public_name_1'; | ||
this.urlInput = '#attribute_group_url_name_1'; | ||
this.metaTitleInput = '#attribute_group_meta_title_1'; | ||
this.indexableToggle = (toggle: number) => `#attribute_group_is_indexable_${toggle}`; | ||
this.attributeTypeSelect = '#attribute_group_group_type'; | ||
this.saveButton = 'form[name="attribute_group"] div.card-footer button'; | ||
} | ||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Fill attribute form and save it | ||
* @param page {Page} Browser tab | ||
* @param attributeData {FakerAttribute} Data to set on new/edit attribute form | ||
* @return {Promise<string>} | ||
*/ | ||
async addEditAttribute(page: Page, attributeData: FakerAttribute): Promise<string> { | ||
// Set names | ||
await this.setValue(page, this.nameInput, attributeData.name); | ||
await this.setValue(page, this.publicNameInput, attributeData.publicName); | ||
|
||
// Set Url and meta title | ||
await this.setValue(page, this.urlInput, attributeData.url); | ||
await this.setValue(page, this.metaTitleInput, attributeData.metaTitle); | ||
|
||
// Set indexable toggle | ||
await this.setChecked(page, this.indexableToggle(attributeData.indexable ? 1 : 0)); | ||
|
||
// Set attribute type | ||
await this.selectByVisibleText(page, this.attributeTypeSelect, attributeData.attributeType); | ||
|
||
// Save attribute | ||
await this.clickAndWaitForURL(page, this.saveButton); | ||
|
||
// Return successful message | ||
return this.getAlertSuccessBlockParagraphContent(page); | ||
} | ||
} | ||
|
||
module.exports = new BOAttributesCreatePage(); |