Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate @pages/BO/design/imageSettings/add from Core #439

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export {default as boFilesPage} from '@pages/BO/catalog/files';
export {default as boFilesCreatePage} from '@pages/BO/catalog/files/create';
export {default as boInformationPage} from '@pages/BO/advancedParameters/information';
export {default as boImageSettingsPage} from '@pages/BO/design/imageSettings';
export {default as boImageSettingsCreatePage} from '@pages/BO/design/imageSettings/create';
export {default as boImportPage} from '@pages/BO/advancedParameters/import';
export {default as boInvoicesPage} from '@pages/BO/orders/invoices';
export {default as boLanguagesPage} from '@pages/BO/international/languages';
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/BO/design/imageSettings/create.ts
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>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/design/imageSettings/create.ts
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 src/versions/develop/pages/BO/design/imageSettings/create.ts
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();