qe-fe-automation
Version:
FE test automation framework using cypress
103 lines (89 loc) • 3.69 kB
text/typescript
import { FlightCheckout } from '@flight-lib/checkout';
import { FlightSearchResults } from '@flight-lib/index';
import { Flights } from '@flight-lib/search';
import { FlightBookingParams } from '@flight-modal/index';
import { Timeouts } from '@utility-lib/constants';
import { Utility } from '@utility-lib/utility';
import { FlightTripType } from '@flight-lib/search';
import { FlightUtility } from '@flight-modal/flight_utility';
import { FlightBookingUtility } from '@flight-modal/index';
const affiliateSelectors = {
ppbModalClose: '[data-testid="modal-header-close-button"]',
onePackageModalCta: '.ta-one-package-premium-communication-modal__container__submit',
pointsEarnBadge: '.points-earn-badge',
pointsEarnCheckout: '.flight-checkout-summary__points',
benefitPointsToggle: '[aria-label="BenefitPoints"]',
sidebarBenefitPoints: '.flight-checkout-booking-summary__est-total__points',
ppbOnCreditCardPaymentMethod: '.ta-payment-card__amount-to-pay',
ppbPaymentMethod: '.cover-fees ta-radio-group > :nth-child(2)',
summaryPPBprice: '.flight-checkout-summary__price',
ppbProfile: '[data-qaid="PPB_PROFILE"] > .ta-menu-button'
};
export class Affiliate {
static closePPBModal(): void {
cy.get(affiliateSelectors.ppbModalClose).click();
}
static clickOnOnePackagePremiumModal(): void {
cy.get(affiliateSelectors.onePackageModalCta).click();
}
static verifyEarnTagOnResultsPage(): void {
cy.get(affiliateSelectors.pointsEarnBadge).should('be.visible');
}
static verifyEarnTagOnCheckout(): void {
cy.get(affiliateSelectors.pointsEarnCheckout).should('be.visible');
}
static goToResultsPage(flightParams: FlightBookingParams): void {
Flights.visitFlightSearchPage();
Flights.selectFlightType(flightParams.flightTripType);
Flights.setOrigin(flightParams.locations[0]);
Flights.setDestination(flightParams.locations[1]);
Utility.selectFutureDate();
Flights.searchFlight();
}
static goFromResultsToCheckoutPage(flightParams: FlightBookingParams) {
FlightSearchResults.onewaySearchResult(flightParams);
FlightCheckout.waitToPageBeLoaded();
}
static verifyPPBProfile(): void {
cy.wait('@waitForPpbProfile');
cy.get(affiliateSelectors.ppbProfile).should('contain.text', 'BenefitPoints');
}
static goToCheckoutByPPBFlight(): void {
const flightParams = FlightBookingUtility.initFlightBookingParams({
flightTripType: FlightTripType.ONEWAY,
locations: ['LON London', 'FRA Frankfurt Main']
});
const isPPBFlight = true;
FlightUtility.searchFlowToCheckout(flightParams, isPPBFlight);
}
static fillAllCheckoutForms(): void {
cy.wait(Timeouts.SHORT_TIMEOUT_5_SEC.timeout);
FlightCheckout.setTripInfo();
FlightCheckout.checkCancellationPolicy();
FlightCheckout.acceptOutOfPolicyFlightGuestFlow();
FlightCheckout.updateContactDetails();
FlightCheckout.validateIfPassportAndVisaInfoRequired();
FlightCheckout.checkIn('Skip');
}
static clickOnBenefitPointsToggle(): void {
cy.get(affiliateSelectors.benefitPointsToggle).click();
}
static clickOnPPBPaymentMethod(): void {
cy.get(affiliateSelectors.ppbPaymentMethod).click();
}
static verifyPPBsOnCreditPaymentMethod(): void {
cy.get(affiliateSelectors.ppbOnCreditCardPaymentMethod).should(
'contain.text',
'BenefitPoints'
);
}
static verifyPPBsOnCheckoutElements(): void {
[
affiliateSelectors.sidebarBenefitPoints,
affiliateSelectors.ppbOnCreditCardPaymentMethod,
affiliateSelectors.summaryPPBprice
].forEach((selector) => {
cy.get(selector).should('contain.text', 'BenefitPoints');
});
}
}