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/international/locations/states/add from Core #457

Merged
merged 1 commit into from
Mar 3, 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 @@ -321,6 +321,7 @@ export {default as boSqlManagerPage} from '@pages/BO/advancedParameters/database
export {default as boSqlManagerCreatePage} from '@pages/BO/advancedParameters/database/sqlManager/create';
export {default as boSqlManagerViewPage} from '@pages/BO/advancedParameters/database/sqlManager/view';
export {default as boStatesPage} from '@pages/BO/international/locations/states';
export {default as boStatesCreatePage} from '@pages/BO/international/locations/states/create';
export {default as boStatisticsPage} from '@pages/BO/statistics';
export {default as boStockPage} from '@pages/BO/catalog/stock';
export {default as boStockMovementsPage} from '@pages/BO/catalog/stock/movements';
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/BO/international/locations/states/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type FakerState from '@data/faker/state';
import {BOBasePagePageInterface} from '@interfaces/BO';
import {type Page} from '@playwright/test';

export interface BOStatesCreatePageInterface extends BOBasePagePageInterface {
readonly pageTitleCreate: string;
readonly pageTitleEdit: string;

createEditState(page: Page, stateData: FakerState): Promise<string>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/international/locations/states/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {type BOStatesCreatePageInterface} from '@interfaces/BO/international/locations/states/create';

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): BOStatesCreatePageInterface {
return require('@versions/develop/pages/BO/international/locations/states/create');
}
/* eslint-enable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

export default requirePage();
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import type FakerState from '@data/faker/state';
import {type BOStatesCreatePageInterface} from '@interfaces/BO/international/locations/states/create';
import BOBasePage from '@pages/BO/BOBasePage';
import {type Page} from '@playwright/test';

/**
* Add state page, contains functions that can be used on the page
* @class
* @extends BOBasePage
*/
class BOStatesCreatePage extends BOBasePage implements BOStatesCreatePageInterface {
public readonly pageTitleCreate: string;

public readonly pageTitleEdit: string;

private readonly nameInput: string;

private readonly isoCodeInput: string;

private readonly countrySelect: string;

private readonly zoneSelect: string;

private readonly statusToggle: (toggle: number) => string;

private readonly saveStateButton: string;

/**
* @constructs
* Setting up texts and selectors to use on add state page
*/
constructor() {
super();

this.pageTitleCreate = `New state • ${global.INSTALL.SHOP_NAME}`;
this.pageTitleEdit = 'Editing state';

// Selectors
this.nameInput = '#state_name';
this.isoCodeInput = '#state_iso_code';
this.countrySelect = '#state_id_country';
this.zoneSelect = '#state_id_zone';
this.statusToggle = (toggle: number) => `#state_active_${toggle}`;
this.saveStateButton = '#save-button';
}

/*
Methods
*/
/**
* Fill form for add/edit state
* @param page {Page} Browser tab
* @param stateData {FakerState} Data to set on new/edit state form
* @returns {Promise<string>}
*/
async createEditState(page: Page, stateData: FakerState): Promise<string> {
// Fill form
await this.setValue(page, this.nameInput, stateData.name);
await this.setValue(page, this.isoCodeInput, stateData.isoCode);
await this.selectByVisibleText(page, this.countrySelect, stateData.country);
await this.selectByVisibleText(page, this.zoneSelect, stateData.zone);
await this.setChecked(page, this.statusToggle(stateData.status ? 1 : 0));

// Save zone
await this.clickAndWaitForURL(page, this.saveStateButton);

// Return successful message
return this.getAlertSuccessBlockParagraphContent(page);
}
}

module.exports = new BOStatesCreatePage();