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

Support for TEST-971 #27

Merged
merged 1 commit into from
May 16, 2024
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
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
Loading