UNPKG

qe-fe-automation

Version:
79 lines (68 loc) 3.12 kB
import { Timeouts } from '@utility-lib/constants'; import { FlightUtility } from '@flight-modal/flight_utility'; import { FlightSearchResults } from '@flight-lib/search_results'; import { FlightBookingParams } from '@flight-modal/flight_booking_utility'; import { FlightItinerary } from '@flight-lib/itinerary'; const FlightUpgradeSelector = { flightUpgradeLink: '[data-testid="event-action-upgrade-flight"]', flightUpgradeModal: '[class="flight-upgrade-modal"]', flightUpgradeOptions: '[class^="flight-class-upgrade-rates"]', selectFare: '.ta-button__content', infoBannerCheckbox: '.info-banner__checkbox', flightClassValue: '[class^="trip-event-card-flight__flight-details__value"]' }; export class FlightUpgrade { static flightUpgradeLinkVisible(): void { cy.allure().logStep('upgrade flight link shown'); cy.get(FlightUpgradeSelector.flightUpgradeLink).should('be.visible'); } static clickFlightUpgradeLink(): void { cy.allure().logStep('upgrade flight link shown'); cy.get(FlightUpgradeSelector.flightUpgradeLink).click(); } static flightUpgradeModalVisible(): void { cy.allure().logStep('flight upgrade modal shown'); cy.get(FlightUpgradeSelector.flightUpgradeModal).should('be.visible'); } static flightUpgradeOptionsAvailable(): void { cy.allure().logStep('flight upgrade options available'); cy.get(FlightUpgradeSelector.flightUpgradeOptions).should('be.visible'); } static clickSelectButton(text: string): void { cy.allure().logStep('select fare to upgrade'); cy.get(FlightUpgradeSelector.selectFare).contains(text).click(); } static clickAcknowledgeButton(): void { cy.get(FlightUpgradeSelector.infoBannerCheckbox).eq(0).click(); } static checkFlightClassAfterUpgrade(flightClass: string[], item: number): void { cy.allure().logStep('verify itinerary shows the correct flight class after successful upgrade'); cy.get(FlightUpgradeSelector.flightClassValue).contains(flightClass[item]); } static reloadPage() { cy.wait(Timeouts.MEDIUM_TIMEOUT_10_SEC.timeout); cy.reload(); } static runFlightBookingFlow(flightBookingParams: FlightBookingParams, airline: string): void { FlightUtility.runSearchFlow(flightBookingParams); FlightSearchResults.filterByAirLine(airline); FlightUtility.runChooseResultFlow(flightBookingParams); FlightUtility.runCheckoutFlow(flightBookingParams); FlightUtility.runItineraryFlow(); } static runRoundTripFlightUpgradeFlow(): void { cy.wait(Timeouts.MEDIUM_TIMEOUT_30_SEC.timeout); FlightItinerary.goToItineraryPage(); FlightItinerary.waitToBeLoaded(); FlightUpgrade.clickFlightUpgradeLink(); FlightUpgrade.flightUpgradeModalVisible(); FlightUpgrade.flightUpgradeOptionsAvailable(); FlightUpgrade.clickSelectButton('Select'); FlightUpgrade.clickAcknowledgeButton(); FlightUpgrade.clickSelectButton(' Confirm upgrade '); FlightItinerary.goToItineraryPage(); FlightItinerary.waitToBeLoaded(); FlightUpgrade.reloadPage(); FlightUpgrade.checkFlightClassAfterUpgrade(['First', 'Business'], 0); } }