|
| 1 | +// Import pages |
| 2 | +import type {BOMaintenancePageInterface} from '@interfaces/BO/shopParameters/general/maintenance'; |
| 3 | +import {BOMaintenancePage} from '@versions/develop/pages/BO/shopParameters/general/maintenance'; |
| 4 | + |
| 5 | +import type {Page} from 'playwright'; |
| 6 | + |
| 7 | +/** |
| 8 | + * Maintenance page, contains selectors and functions for the page |
| 9 | + * @class |
| 10 | + * @extends BOBasePage |
| 11 | + */ |
| 12 | +class BOMaintenanceVersion extends BOMaintenancePage implements BOMaintenancePageInterface { |
| 13 | + /** |
| 14 | + * @constructs |
| 15 | + * Setting up texts and selectors to use on products page |
| 16 | + */ |
| 17 | + constructor() { |
| 18 | + super(); |
| 19 | + |
| 20 | + this.shopStatusToggleInput = (toggle: number) => `label[for='PS_SHOP_ENABLE_${toggle ? 'on' : 'off'}']`; |
| 21 | + this.saveFormButton = '#configuration_fieldset_general div.panel-footer button'; |
| 22 | + this.addMyIPAddressButton = '#conf_id_PS_MAINTENANCE_IP button'; |
| 23 | + this.alertSuccessBlock = 'div.alert.alert-success[style*=\'display\']'; |
| 24 | + this.successfulUpdateMessage = 'The settings have been successfully updated.'; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Enable/Disable shop |
| 29 | + * @param page {Page} Browser tab |
| 30 | + * @param toEnable {boolean} Status to set to enable/disable the shop |
| 31 | + * @return {Promise<string>} |
| 32 | + */ |
| 33 | + async changeShopStatus(page: Page, toEnable: boolean = true): Promise<string> { |
| 34 | + await this.setChecked(page, this.shopStatusToggleInput(toEnable ? 1 : 0)); |
| 35 | + await this.clickAndWaitForLoadState(page, this.saveFormButton); |
| 36 | + await this.elementNotVisible(page, this.shopStatusToggleInput(!toEnable ? 1 : 0), 2000); |
| 37 | + |
| 38 | + return this.getTextContent(page, this.alertSuccessBlock); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Add my IP address in maintenance IP input |
| 43 | + * @param page {Page} Browser tab |
| 44 | + * @return {Promise<string>} |
| 45 | + */ |
| 46 | + async addMyIpAddress(page: Page): Promise<string> { |
| 47 | + await page.locator(this.addMyIPAddressButton).click(); |
| 48 | + await page.locator(this.saveFormButton).click(); |
| 49 | + |
| 50 | + return this.getTextContent(page, this.alertSuccessBlock); |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +const maintenancePage = new BOMaintenanceVersion(); |
| 55 | +export {maintenancePage, BOMaintenanceVersion as MaintenancePage}; |
0 commit comments