Skip to content

Commit

Permalink
Merge pull request #457 from Progi1984/boStatesCreatePage
Browse files Browse the repository at this point in the history
Migrate `@pages/BO/international/locations/states/add` from Core
  • Loading branch information
Progi1984 authored Mar 3, 2025
2 parents e4ac49a + c378a89 commit 46b83c6
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
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();

0 comments on commit 46b83c6

Please sign in to comment.