UNPKG

qe-fe-automation

Version:
78 lines (66 loc) 2.75 kB
import { Timeouts } from '@utility-lib/index'; import { flightSearchSelector } from './search'; const flightChangeSelector = { selectDepartureFlightButton: 'input[name="flightChange"]', changeFlightButton: 'button[qaid="changeFlightAction"]', checkPriceButton: '.flight-change-result__content__price-block button', selectFareOption: 'button[qaid="selectExchangeFlightOption"]', changeNow: 'button[qaid="changeNowButton"]', successBookingInfo: '.information__content__subject', exchangeDepartureFlightCard: '[qaid="flightExchangeDepartureCard"]', openSearchForm: '[qaid="flightExchangeNextButton"]', mainFareCard: '[qaid="flightFareCard"]', selectFareButton: '[qaid="selectFlightButton"]' }; export class FlightChange { static selectDepartureFlight(): void { cy.allure().logStep('pick the departure card'); cy.get(flightChangeSelector.exchangeDepartureFlightCard).click(); } static proceedToExchangeForm(): void { cy.allure().logStep('proceed to search form'); cy.get(flightChangeSelector.openSearchForm).click(); } static selectDepartureFlightButton(): void { cy.allure().logStep('select departure flight button'); cy.get(flightChangeSelector.selectDepartureFlightButton).click(); } static waitAndSelectFirstFare(): void { cy.allure().logStep('waiting for exchange search result'); cy.wait('@waitForFlightSearch'); cy.allure().logStep('select first fare'); cy.get(flightChangeSelector.mainFareCard).click(); cy.wait('@waitForFlightSearch'); cy.get(flightChangeSelector.selectFareButton).click(); cy.wait('@waitForFlightSearch'); } static clickChangeFlightButton(): void { cy.allure().logStep('click change flight button'); cy.get(flightChangeSelector.changeFlightButton).click(); } static searchChangeFlight(): void { cy.allure().logStep('search flight'); cy.get(flightSearchSelector.flightSearchButton).click(); cy.wait('@waitForFlightSearch'); } static selectFareToChange(): void { cy.allure().logStep('select fare to change'); cy.get(flightChangeSelector.checkPriceButton).eq(0).click(); cy.wait('@waitForFlightSearch'); cy.get(flightChangeSelector.selectFareOption).click(); cy.wait('@waitForFlightSearch'); } static clickChangeNow(): void { cy.allure().logStep('click change now button'); cy.get(flightChangeSelector.changeNow).click(); this.expectFlightSuccessfullyChanged(); } static expectFlightSuccessfullyChanged() { const successMsg = 'Flight successfully changed!'; cy.get(flightChangeSelector.successBookingInfo, Timeouts.MAX_TIMEOUT_120_SEC).should( 'be.contain', `${successMsg}` ); cy.allure().logStep('Flight is successfully changed'); } }