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/advancedParameters/multistore/url/addURL from Core #373

Merged
merged 1 commit into from
Jan 28, 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 @@ -255,6 +255,7 @@ export {default as boMonitoringPage} from '@pages/BO/catalog/monitoring';
export {default as boMultistorePage} from '@pages/BO/advancedParameters/multistore';
export {default as boMultistoreShopPage} from '@pages/BO/advancedParameters/multistore/shop';
export {default as boMultistoreShopCreatePage} from '@pages/BO/advancedParameters/multistore/shop/create';
export {default as boMultistoreShopUrlCreatePage} from '@pages/BO/advancedParameters/multistore/url/create';
export {default as boMyProfilePage} from '@pages/BO/advancedParameters/team/myProfile';
export {default as boNewExperimentalFeaturesPage} from '@pages/BO/advancedParameters/newExperimentalFeatures';
export {default as boOrdersPage} from '@pages/BO/orders';
Expand Down
13 changes: 13 additions & 0 deletions src/interfaces/BO/advancedParameters/multistore/url/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {type BOBasePagePageInterface} from '@interfaces/BO';
import {type Page} from '@playwright/test';

export interface BOMultistoreShopUrlCreatePageInterface extends BOBasePagePageInterface {
readonly errorDisableMainURLMessage: string;
readonly errorDisableShopMessage: string;
readonly pageTitleCreate: string;
readonly pageTitleEdit: string;

setMainURL(page: Page, status: string): Promise<string>;
setShopStatus(page: Page, status: string): Promise<string>;
setVirtualUrl(page: Page, url: string): Promise<string>;
}
9 changes: 9 additions & 0 deletions src/pages/BO/advancedParameters/multistore/url/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {type BOMultistoreShopUrlCreatePageInterface} from '@interfaces/BO/advancedParameters/multistore/url/create';

/* eslint-disable global-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
function requirePage(): BOMultistoreShopUrlCreatePageInterface {
return require('@versions/develop/pages/BO/advancedParameters/multistore/url/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,94 @@
import {type BOMultistoreShopUrlCreatePageInterface} from '@interfaces/BO/advancedParameters/multistore/url/create';
import BOBasePage from '@pages/BO/BOBasePage';
import {type Page} from '@playwright/test';

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

public readonly pageTitleEdit: string;

public readonly errorDisableMainURLMessage: string;

public readonly errorDisableShopMessage: string;

private readonly domainInput: string;

private readonly virtualUrlInput: string;

private readonly mainURLButton: (status: string) => string;

private readonly enabledButton: (status: string) => string;

private readonly saveButton: string;

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

this.pageTitleCreate = 'Add new •';
this.pageTitleEdit = 'Multistore > Edit';
this.errorDisableMainURLMessage = 'You cannot change a main URL to a non-main URL. You have to set another URL'
+ ' as your Main URL for the selected shop.';
this.errorDisableShopMessage = 'You cannot disable the Main URL.';

// Selectors
this.domainInput = '#domain';
this.virtualUrlInput = '#virtual_uri';
this.mainURLButton = (status: string) => `#main_${status}`;
this.enabledButton = (status: string) => `#active_${status}`;
this.saveButton = '#shop_url_form_submit_btn_1';
}

/*
Methods
*/

/**
* Add shop URL
* @param page {Page} Browser tab
* @param url {string} url to set on edit/add shop form
* @returns {Promise<string>}
*/
async setVirtualUrl(page: Page, url: string): Promise<string> {
await this.setValue(page, this.virtualUrlInput, url);

await this.clickAndWaitForURL(page, this.saveButton, 'networkidle', 60000);
return this.getTextContent(page, this.alertSuccessBlock);
}

/**
* Set main URL
* @param page {Page} Browser tab
* @param status {string} Main url status
* @returns {Promise<string>}
*/
async setMainURL(page: Page, status: string): Promise<string> {
await this.setChecked(page, this.mainURLButton(status));
await this.clickAndWaitForURL(page, this.saveButton);

return this.getTextContent(page, this.alertBlock);
}

/**
* Set shop url status
* @param page {Page} Browser tab
* @param status {string} shop url status
* @returns {Promise<string>}
*/
async setShopStatus(page: Page, status: string): Promise<string> {
await this.setChecked(page, this.enabledButton(status));
await this.waitForSelectorAndClick(page, this.saveButton);

return this.getTextContent(page, this.alertBlock);
}
}

module.exports = new BOMultistoreShopUrlCreatePage();
Loading