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/pages/pageCategory/add from Core #430

Merged
merged 1 commit into from
Feb 20, 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 @@ -212,6 +212,7 @@ export {default as boCategoriesPage} from '@pages/BO/catalog/categories';
export {default as boCategoriesCreatePage} from '@pages/BO/catalog/categories/create';
export {default as boCountriesPage} from '@pages/BO/international/locations/countries';
export {default as boCountriesCreatePage} from '@pages/BO/international/locations/countries/create';
export {default as boCMSPageCategoriesCreatePage} from '@pages/BO/design/pages/category/create';
export {default as boCMSPagesPage} from '@pages/BO/design/pages';
export {default as boCreditSlipsPage} from '@pages/BO/orders/creditSlips';
export {default as boCustomerGroupsPage} from '@pages/BO/shopParameters/customerSettings/groups';
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/BO/design/pages/category/create.ts
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>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/design/pages/category/create.ts
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 src/versions/develop/pages/BO/design/pages/category/create.ts
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();