-
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.
Migrate
@pages/BO/design/imageSettings/add
from Core
- Loading branch information
Showing
4 changed files
with
107 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 FakerImageType from '@data/faker/imageType'; | ||
import {BOBasePagePageInterface} from '@interfaces/BO'; | ||
import type {Page} from '@playwright/test'; | ||
|
||
export interface BOImageSettingsCreatePageInterface extends BOBasePagePageInterface { | ||
readonly pageTitleCreate: string; | ||
readonly pageTitleEdit: (name: string) => string; | ||
|
||
createEditImageType(page: Page, imageTypeData: FakerImageType): 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 {BOImageSettingsCreatePageInterface} from '@interfaces/BO/design/imageSettings/create'; | ||
|
||
/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
function requirePage(): BOImageSettingsCreatePageInterface { | ||
return require('@versions/develop/pages/BO/design/imageSettings/create'); | ||
} | ||
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
|
||
export default requirePage(); |
87 changes: 87 additions & 0 deletions
87
src/versions/develop/pages/BO/design/imageSettings/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,87 @@ | ||
import type FakerImageType from '@data/faker/imageType'; | ||
import {type BOImageSettingsCreatePageInterface} from '@interfaces/BO/design/imageSettings/create'; | ||
import BOBasePage from '@pages/BO/BOBasePage'; | ||
import {type Page} from '@playwright/test'; | ||
|
||
/** | ||
* Add image type page, contains functions that can be used on the page | ||
* @class | ||
* @extends BOBasePage | ||
*/ | ||
class BOImageSettingsCreatePage extends BOBasePage implements BOImageSettingsCreatePageInterface { | ||
public readonly pageTitleCreate: string; | ||
|
||
public readonly pageTitleEdit: (name: string) => string; | ||
|
||
private readonly imageTypeForm: string; | ||
|
||
private readonly nameInput: string; | ||
|
||
private readonly widthInput: string; | ||
|
||
private readonly heightInput: string; | ||
|
||
private readonly productsToggle: (toggle: number) => string; | ||
|
||
private readonly categoriesToggle: (toggle: number) => string; | ||
|
||
private readonly manufacturersToggle: (toggle: number) => string; | ||
|
||
private readonly suppliersToggle: (toggle: number) => string; | ||
|
||
private readonly storesToggle: (toggle: number) => string; | ||
|
||
private readonly saveButton: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up texts and selectors to use on add image type page | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.pageTitleCreate = `Add new • ${global.INSTALL.SHOP_NAME}`; | ||
this.pageTitleEdit = (name: string) => `Edit: ${name} • ${global.INSTALL.SHOP_NAME}`; | ||
|
||
// Form selectors | ||
this.imageTypeForm = 'form[name="image_type"]'; | ||
this.nameInput = `${this.imageTypeForm} #image_type_name`; | ||
this.widthInput = `${this.imageTypeForm} #image_type_width`; | ||
this.heightInput = `${this.imageTypeForm} #image_type_height`; | ||
this.productsToggle = (toggle: number) => `${this.imageTypeForm} #image_type_products_${toggle}`; | ||
this.categoriesToggle = (toggle: number) => `${this.imageTypeForm} #image_type_categories_${toggle}`; | ||
this.manufacturersToggle = (toggle: number) => `${this.imageTypeForm} #image_type_manufacturers_${toggle}`; | ||
this.suppliersToggle = (toggle: number) => `${this.imageTypeForm} #image_type_suppliers_${toggle}`; | ||
this.storesToggle = (toggle: number) => `${this.imageTypeForm} #image_type_stores_${toggle}`; | ||
this.saveButton = `${this.imageTypeForm} #save-button`; | ||
} | ||
|
||
/* Methods */ | ||
|
||
/** | ||
* Fill image type form in create or edit page and save | ||
* @param page {Page} Browser tab | ||
* @param imageTypeData {FakerImageType} Data to set on new/edit image type form | ||
* @return {Promise<string>} | ||
*/ | ||
async createEditImageType(page: Page, imageTypeData: FakerImageType): Promise<string> { | ||
await this.setValue(page, this.nameInput, imageTypeData.name); | ||
await this.setValue(page, this.widthInput, imageTypeData.width.toString()); | ||
await this.setValue(page, this.heightInput, imageTypeData.height.toString()); | ||
|
||
// Set status for image type | ||
await this.setChecked(page, this.productsToggle(imageTypeData.productsStatus ? 1 : 0)); | ||
await this.setChecked(page, this.categoriesToggle(imageTypeData.categoriesStatus ? 1 : 0)); | ||
await this.setChecked(page, this.manufacturersToggle(imageTypeData.manufacturersStatus ? 1 : 0)); | ||
await this.setChecked(page, this.suppliersToggle(imageTypeData.suppliersStatus ? 1 : 0)); | ||
await this.setChecked(page, this.storesToggle(imageTypeData.storesStatus ? 1 : 0)); | ||
|
||
// Save image type | ||
await this.clickAndWaitForURL(page, this.saveButton); | ||
|
||
// Return successful message | ||
return this.getAlertSuccessBlockParagraphContent(page); | ||
} | ||
} | ||
|
||
module.exports = new BOImageSettingsCreatePage(); |