Skip to content

Commit

Permalink
Merge pull request #27 from Progi1984/test971
Browse files Browse the repository at this point in the history
Support for TEST-971
  • Loading branch information
Progi1984 authored May 16, 2024
2 parents 3eca284 + bee7fb7 commit 507ff38
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/interfaces/FO/checkout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import type {Page} from '@playwright/test';

export interface FoCheckoutPageInterface extends FOBasePagePageInterface {
personalInformationStepForm: string;
readonly noCarriersMessage: string;

choosePaymentAndOrder(page: Page, paymentModuleName: string): Promise<void>;
clickOnSignIn(page: Page): Promise<void>;
customerLogin(page: Page, customer: any): Promise<boolean>;
getAllCarriersNames(page: Page): Promise<(string | null)[]>;
getCarrierErrorMessage(page: Page): Promise<string|null>;
goToDeliveryStep(page: Page): Promise<boolean>;
goToPaymentStep(page: Page): Promise<boolean>;
isCheckoutPage(page: Page): Promise<boolean>;
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {BrowserContext, Page} from '@playwright/test';

export interface CommonPageInterface {
changePage(browserContext: BrowserContext, tabId?: number): Promise<Page>;
closePage(browserContext: BrowserContext, page: Page, tabId?: number): Promise<Page>;
getPageTitle(page: Page): Promise<string>;
goTo(page: Page, url: string): Promise<void>;
Expand Down
19 changes: 17 additions & 2 deletions src/versions/develop/pages/FO/classic/checkout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import type {Page} from 'playwright';
class CheckoutPage extends FOBasePage implements FoCheckoutPageInterface {
public readonly deleteAddressSuccessMessage: string;

public readonly noCarriersMessage: string;

private readonly successAlert: string;

private readonly checkoutPageBody: string;
Expand Down Expand Up @@ -187,6 +189,8 @@ class CheckoutPage extends FOBasePage implements FoCheckoutPageInterface {

private readonly deliveryStepCarriersList: string;

private readonly deliveryStepCarriersListError: string;

protected deliveryOptions: string;

private readonly deliveryOptionsRadioButton: string;
Expand Down Expand Up @@ -251,6 +255,7 @@ class CheckoutPage extends FOBasePage implements FoCheckoutPageInterface {
super(theme);
this.cartRuleAlertMessageText = 'You cannot use this voucher with this carrier';
this.deleteAddressSuccessMessage = 'Address successfully deleted.';
this.noCarriersMessage = 'Unfortunately, there are no carriers available for your delivery address.';
this.noPaymentNeededText = 'No payment needed for this order';
this.messageIfYouSignOut = 'If you sign out now, your cart will be emptied.';
this.authenticationErrorMessage = 'Authentication failed.';
Expand Down Expand Up @@ -328,6 +333,7 @@ class CheckoutPage extends FOBasePage implements FoCheckoutPageInterface {
this.deliveryStepSection = '#checkout-delivery-step';
this.deliveryStepEditButton = `${this.deliveryStepSection} span.step-edit`;
this.deliveryStepCarriersList = `${this.deliveryStepSection} .delivery-options-list`;
this.deliveryStepCarriersListError = `${this.deliveryStepCarriersList} .alert-danger`;
this.deliveryOptions = '#js-delivery div.delivery-options';
this.deliveryOptionsRadioButton = 'input[id*=\'delivery_option_\']';
this.deliveryOptionLabel = (id: number) => `${this.deliveryStepSection} label[for='delivery_option_${id}']`;
Expand Down Expand Up @@ -564,7 +570,7 @@ class CheckoutPage extends FOBasePage implements FoCheckoutPageInterface {
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
getActiveLinkFromPersonalInformationBlock(page: Page): Promise<string> {
async getActiveLinkFromPersonalInformationBlock(page: Page): Promise<string> {
return this.getTextContent(page, this.activeLink);
}

Expand All @@ -573,7 +579,7 @@ class CheckoutPage extends FOBasePage implements FoCheckoutPageInterface {
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
isPasswordRequired(page: Page): Promise<boolean> {
async isPasswordRequired(page: Page): Promise<boolean> {
return this.elementVisible(page, `${this.checkoutGuestPasswordInput}:required`, 1000);
}

Expand Down Expand Up @@ -974,6 +980,15 @@ class CheckoutPage extends FOBasePage implements FoCheckoutPageInterface {
return this.getTextContent(page, this.shippingValueSpan);
}

/**
* Get errror carrier
* @param page {Page} Browser tab
* @returns {Promise<string|null>}
*/
async getCarrierErrorMessage(page: Page): Promise<string|null> {
return page.locator(this.deliveryStepCarriersListError).textContent();
}

/**
* Get all carriers names
* @param page {Page} Browser tab
Expand Down

0 comments on commit 507ff38

Please sign in to comment.