qe-fe-automation
Version:
FE test automation framework using cypress
810 lines (710 loc) • 33.6 kB
text/typescript
import { AdminDashboardPage } from '@admin-lib/admin_avi/admin_dashboard_section';
import { PolicyPages } from '@growth-lib/policy-page';
import { Timeouts } from '@utility-lib/constants';
const selectors = {
getStartedPolicyWizard: '[data-testid="wizard-landing-page-button-start"] > .ta-button-v2',
allBookingsRadioButton: '[data-testid="radio-control__item--All bookings"]',
outOfPolicyRadioButton: '[data-testid="radio-control__item--Only out-of-policy bookings"]',
yesRadioButton: '[data-testid="radio-control__item--Yes"]',
notRightNowRadioButton: '[data-testid="radio-control__item--Not right now"]',
noneRadioButton: '[data-testid="radio-control__item--None"]',
nextButton: '[data-testid="policy-wizard-footer-next-cta"] > .ta-button-v2',
backButton: '[data-testid="policy-wizard-footer-back-cta"] > .ta-button-v2',
backButtonInSaveAndClosePage: '[data-testid="policy-wizard-summary-footer-back-cta"]',
summaryNextButton: '[data-testid="policy-wizard-summary-footer-next-cta"] > .ta-button-v2',
percentInput: '[data-testid="percentage__input"]',
maxPriceDropdown: '[data-testid="max-price-wrapper-accordion"]',
maxPriceInput: '[data-testid="max-price-accordion__input"]',
bookingLeadTimeInput: '[data-testid="booking-lead-time__input"]',
cabinAndSeatUpgradeDropdown: '[data-testid="upgrades-accordion"]',
cabinUpgradeToggle: '[data-testid="upgrades-accordion__cabin-upgrade-toggle"]',
seatToggle: '[data-testid="upgrades-accordion__seat-toggle"]',
carClassSelect: '[data-testid="other-flight-policy__cabins__select"][value="electric"]',
otherFlightPolicyCabinSelect: '[data-testid="RuleType.FLIGHT-policy__control__cabins__select"]',
otherHotelPolicyClassSelect: '[data-testid="RuleType.HOTEL-policy__control__cabins__select"]',
otherCarPolicyClassSelect: '[data-testid="RuleType.CAR-policy__control__cabins__select"]',
summarySaveAndCloseCta: '[data-testid="policy-wizard-summary-footer-save-and-close-cta"] > .ta-button-v2',
saveAndCloseWholeWizardCta: '[data-testid="policy-wizard-footer-save-and-close-cta"] > .ta-button-v2',
maxAllowedCabinPremiumEconomy: '[data-testid="RuleType.FLIGHT-policy__cabins__select--Premium Economy"]',
skipToTrainPolicyButton: '[data-testid="policy-wizard-footer-go-to-train-cta"]',
summaryTableFlightMedianPrice: '[data-testid="summary-table__price--flight"]',
summaryTableFlightMaxPrice: '[data-testid="summary-table__maxPrice--flight"]',
summaryTableFlightMaxCabin: '[data-testid="summary-table__cabin--flight"]',
summaryTableFlightBookLeadTime: '[data-testid="summary-table__lead-time--flight"]',
summaryTableFlightAvailCabinUpgrades: '[data-testid="summary-table__upgrades--flight"] > :nth-child(1)',
summaryTableFlightAvailSeatUpgrades: '[data-testid="summary-table__upgrades--flight"] > :nth-child(2)',
summaryTableHotelMedianPrice: '[data-testid="summary-table__price--hotel"]',
summaryTableHotelMaxPrice: '[data-testid="summary-table__maxPrice--hotel"]',
summaryTableHotelRoomType: '[data-testid="summary-table__upgrades--hotel"]',
summaryTableHotelBookLeadTime: '[data-testid="summary-table__lead-time--hotel"]',
summaryTableCarMedianPrice: '[data-testid="summary-table__price--car"]',
summaryTableCarBookLeadTime: '[data-testid="summary-table__lead-time--car"]',
summaryTableCarClass: '[data-testid="summary-table__upgrades--car"]',
summaryTableTrainMaxPrice: '[data-testid="summary-table__maxPrice--train"]',
summaryTableTrainBookLeadTime: '[data-testid="summary-table__lead-time--train"]',
summaryTableTrainClass: '[data-testid="summary-table__upgrades--train"]',
validationPageFlightIcon: '[data-testid="polcy-side-navigation__Flights"]',
validationPageTrainIcon: '[data-testid="polcy-side-navigation__Trains"]',
validationPageHotelIcon: '[data-testid="polcy-side-navigation__Hotels"]',
validationPageCarIcon: '[data-testid="polcy-side-navigation__Rental cars"]',
flightValidationPageCost: '[data-testid="flight-cost-per-booking__column-short"]',
flightBookingNotifications: '[data-testid="flight-booking-notifications-long_editable"]',
flightDurationline: '[data-testid="flight-duration-column_editable"]',
flightUpgradesLine: '[data-testid="flight-upgrades-long_editable"]',
flightCabinClassLong: '[data-testid="flight-cabin-long_editable"]',
flightBookingLeadTimeLong: '[data-testid="flight-bookingLeadTime-long_editable"]',
validationPageCost: '[data-testid="ta-co-table__content-cost_editable"]',
hotelValidationPageRoomsCancellation: '[data-testid="hotel-rooms-cancellation_editable"]',
ValidationPageBookLeadTime: '[data-testid="bookingLeadTime-daysBefore_editable"]',
ValidationPageBookingApproval: '[data-testid="bookingNotifications-approvalType_editable"]',
trainBookingNotifications: '[data-testid="train-bookingNotifications_editable"]',
ValidationPageClassAllowed: '[data-testid="ClassAllowedColumn_editable"]',
dismissButtonModalValidationPage: '[data-testid="video-tooltip-dismiss"]',
flightOutOfPolicy: '[data-testid="flight-policy__out-of-policy-dynamic-input-ui"]',
hotelOutOfPolicy: '[data-testid="hotel-out-of-policy"]',
carOutOfPolicy: '[data-testid="car-out-of-policy"]',
trainOutOfPolicy: '[data-testid="train-out-of-policy-title"]',
travelerToggleView: '[data-testid="verticalsTabGroup"] > button:nth-child(1)',
adminToggleView: '[data-testid="verticalsTabGroup"] > button:nth-child(2)',
allowRefundableRoomHotel:
'[data-testid="RuleType.HOTEL-policy__cabins__select--Allow refundable room bookings only"]',
dropModalExitPolicySetup: '[data-testid="discardChanges"]',
dynamicPolicyModal: '[data-testid="option-disclaimer__info"]',
bookingLeadTimeModal: '[data-testid="booking-lead-time__info"]'
};
const viewSelectors = {
fiftyPriceShield: '[data-testid="flight-policy__out-of-policy-fifty-price-currency-shield-icon"]',
oneFiftyPriceShield: '[data-testid="flight-policy__out-of-policy-one-fifty-price-currency-shield-icon"]',
hotelHundrendPriceShield: '[data-testid="hotel-policy__shield-hundred"]',
hotelThreefiftyPriceShield: '[data-testid="hotel-policy__shield-threefifty"]',
policyTitle: '[data-testid="policy"]',
daysBeforeDepartureTitle: '[data-testid="days-booked-before-departure"]',
allFlightsTitle: '[data-testid="all-flights"]',
otherFlightPremiumEconomyShield: '[data-testid="other-flight-lead-icon-premium-business1"]',
otherFlightPremiumShield: '[data-testid="other-flight-shield-icon-premium1"]',
otherHotelRefundableShield1: '[data-testid="other-hotel-refundable-shield-icon1"]',
otherHotelRefundableShield2: '[data-testid="other-hotel-refundable-shield-icon2"]',
carHundrendPriceShield: '[data-testid="car-policy__shield-hundred"]',
carOneTwenyFivePriceShield: '[data-testid="car-policy__shield-one-tweny-five"]'
};
const MEDIAN_PRICE = 100;
const percentInput = '50';
const maxFlightPriceInput = '1,000';
const bookLeadTimeInput = '15';
const maxCarPriceInput = '200';
const maxHotelPriceInput = '500';
const maxTrainPriceInput = '100';
const carClassAllowed = 'Luxury';
const gotItButtonText = 'Got it';
export enum PolicyWizardState {
NOT_STARTED = 'NOT_STARTED',
NOTIFICATIONS_CONFIGURED = 'NOTIFICATIONS_CONFIGURED',
COMPLETED = 'COMPLETED'
}
export enum PolicyWizardToggleView {
TRAVELER = 'TRAVELER',
ADMIN = 'ADMIN'
}
export class PolicyWizardPages {
static goToPolicyWizardPage(): void {
cy.allure().logStep('go to get started policy wizard page');
AdminDashboardPage.visitAdminDashboardPage();
PolicyPages.clickTravelPolicyButtonInMenu();
}
static toggleView(policyWizardToggleView: PolicyWizardToggleView): void {
policyWizardToggleView === PolicyWizardToggleView.TRAVELER
? cy.get(selectors.travelerToggleView).click()
: cy.get(selectors.adminToggleView).click();
}
static clickOnStartedPolicyWizard(): void {
cy.allure().logStep('policy wizard click on get started');
cy.get(selectors.getStartedPolicyWizard).click();
cy.wait('@waitForFlightRule');
cy.wait('@waitForHotelRule');
cy.wait('@waitForCarRule');
cy.wait('@waitForTrainRule');
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
}
static patchPolicyState(policyWizardState: PolicyWizardState, token: string): void {
cy.allure().logStep(`policy wizard update policy ${policyWizardState} state`);
cy.request({
method: 'PATCH',
url: `/api/selfSetup/company/policySetup`,
body: { wizardState: policyWizardState },
headers: {
Authorization: token
}
}).then((response) => {
expect(response.status).to.eq(200);
});
}
static clickNextButton(): void {
cy.allure().logStep('policy wizard click next button');
cy.get(selectors.nextButton).click();
}
static clickOnNoneAnswer(): void {
cy.allure().logStep('policy wizard click on "none" (no notifications) answer');
cy.get(selectors.noneRadioButton).click();
}
static setBookNotificationAll(): void {
cy.allure().logStep('policy wizard choose all bookings notifications');
cy.get(selectors.allBookingsRadioButton).click();
}
static setBookingPolicyYes(): void {
cy.allure().logStep('policy wizard choose yes booking policy');
cy.get(selectors.yesRadioButton).click();
}
static fillEntireWizardFlowAndVerifyAnswers(): void {
PolicyWizardPages.setBookNotificationAll();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.setBookingPolicyYes();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.verifyFlightSpendPolicyPage();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.verifyOtherFlightSpendPolicyPage();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.verifyHotelSpendPolicyPage();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.verifyOtherHotelSpendPolicyPage();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.clickSummaryPageNextButton();
PolicyWizardPages.verifyCarSpendPolicyPage();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.verifyOtherCarSpendPolicyPage();
PolicyWizardPages.clickNextButton();
PolicyWizardPages.clickSummaryPageNextButton();
PolicyWizardPages.verifyTrainSpendPolicyPage();
PolicyWizardPages.clickNextButton();
}
static fillFlightSpendPolicyPage(): void {
cy.allure().logStep('policy wizard flight spend policy');
cy.get(selectors.percentInput).wait(100).clear();
cy.get(selectors.percentInput).type(percentInput);
cy.get(selectors.maxPriceDropdown).click();
cy.get(selectors.maxPriceInput).wait(100).clear();
cy.get(selectors.maxPriceInput).type(maxFlightPriceInput);
}
static verifyFlightSpendPolicyPage(): void {
cy.allure().logStep('verifyFlightSpendPolicyPage');
PolicyWizardPages.fillFlightSpendPolicyPage();
cy.get(selectors.flightOutOfPolicy).contains(`$${+percentInput + MEDIAN_PRICE} and up is out of policy`);
cy.get(viewSelectors.fiftyPriceShield).should('not.exist');
cy.get(viewSelectors.oneFiftyPriceShield).should('be.visible');
PolicyWizardPages.toggleView(PolicyWizardToggleView.ADMIN);
cy.get(viewSelectors.policyTitle).contains(`Median price + ${percentInput}%`);
cy.get(viewSelectors.policyTitle).contains(`Max price per booking: 1000$`);
}
static verifyOtherFlightSpendPolicyPage(): void {
cy.allure().logStep('verifyOtherFlightSpendPolicyPage');
PolicyWizardPages.toggleView(PolicyWizardToggleView.TRAVELER);
cy.get(selectors.otherFlightPolicyCabinSelect).click();
cy.get(selectors.maxAllowedCabinPremiumEconomy).click();
cy.get(viewSelectors.otherFlightPremiumEconomyShield).should('not.exist');
cy.get(viewSelectors.otherFlightPremiumShield).should('exist');
PolicyWizardPages.toggleView(PolicyWizardToggleView.ADMIN);
cy.get(viewSelectors.policyTitle).contains(`Premium Economy`);
cy.get(viewSelectors.daysBeforeDepartureTitle).contains(`7 Days`);
}
static verifyHotelSpendPolicyPage(): void {
cy.allure().logStep('verifyHotelSpendPolicyPage');
PolicyWizardPages.toggleView(PolicyWizardToggleView.TRAVELER);
PolicyWizardPages.fillHotelSpendPolicyPage();
cy.get(selectors.hotelOutOfPolicy).contains(`$${+percentInput + MEDIAN_PRICE} and up is out of policy`);
cy.get(viewSelectors.hotelHundrendPriceShield).should('not.exist');
cy.get(viewSelectors.hotelThreefiftyPriceShield).should('be.visible');
PolicyWizardPages.toggleView(PolicyWizardToggleView.ADMIN);
cy.get(viewSelectors.policyTitle).contains(`Fair market price + ${percentInput}%`);
cy.get(viewSelectors.policyTitle).contains(`Max price per booking: 500$`);
}
static verifyOtherHotelSpendPolicyPage(): void {
cy.allure().logStep('verifyOtherHotelSpendPolicyPage');
PolicyWizardPages.toggleView(PolicyWizardToggleView.TRAVELER);
cy.get(viewSelectors.otherHotelRefundableShield1).should('not.exist');
cy.get(viewSelectors.otherHotelRefundableShield2).should('not.exist');
cy.get(selectors.otherHotelPolicyClassSelect).click();
cy.get(selectors.allowRefundableRoomHotel).click();
cy.get(viewSelectors.otherHotelRefundableShield1).should('be.visible');
cy.get(viewSelectors.otherHotelRefundableShield2).should('be.visible');
PolicyWizardPages.toggleView(PolicyWizardToggleView.ADMIN);
cy.get(viewSelectors.policyTitle).contains(` Allow refundable room bookings only`);
cy.get(viewSelectors.daysBeforeDepartureTitle).contains(`7 Days`);
}
static verifyCarSpendPolicyPage(): void {
cy.allure().logStep('verifyCarSpendPolicyPage');
cy.get(viewSelectors.carHundrendPriceShield).should('not.exist');
cy.get(viewSelectors.carOneTwenyFivePriceShield).should('be.visible');
cy.get(selectors.carOutOfPolicy).contains(`$125 and up is out of policy`);
PolicyWizardPages.fillCarSpendPolicyPage();
cy.get(viewSelectors.carHundrendPriceShield).should('not.exist');
cy.get(viewSelectors.carOneTwenyFivePriceShield).should('not.exist');
PolicyWizardPages.toggleView(PolicyWizardToggleView.ADMIN);
cy.get(viewSelectors.policyTitle).contains(`Fair market price + ${percentInput}%`);
cy.get(viewSelectors.policyTitle).contains(`Max price per booking: 200$`);
}
static verifyOtherCarSpendPolicyPage(): void {
cy.allure().logStep('verifyOtherCarSpendPolicyPage');
PolicyWizardPages.toggleView(PolicyWizardToggleView.TRAVELER);
PolicyWizardPages.fillOtherCarPolicyPage();
PolicyWizardPages.toggleView(PolicyWizardToggleView.ADMIN);
cy.get(viewSelectors.policyTitle).contains(carClassAllowed);
cy.get(viewSelectors.daysBeforeDepartureTitle).contains(`${bookLeadTimeInput} Days`);
}
static verifyTrainSpendPolicyPage(): void {
cy.allure().logStep('verifyTrainSpendPolicyPage');
cy.get(selectors.trainOutOfPolicy).contains(`No pricing limit defined`);
PolicyWizardPages.fillTrainSpendPolicyPage();
cy.get(selectors.trainOutOfPolicy).contains(`$${+maxTrainPriceInput} and up is out of policy`);
PolicyWizardPages.toggleView(PolicyWizardToggleView.ADMIN);
cy.get(viewSelectors.daysBeforeDepartureTitle).contains(`${bookLeadTimeInput} Days`);
}
static fillFlightAndHotelFlow(): void {
this.clickNextButton();
this.fillFlightSpendPolicyPage();
this.clickNextButton();
this.fillOtherFlightPolicyPage();
this.clickNextButton();
this.fillHotelSpendPolicyPage();
this.clickNextButton();
this.fillOtherHotelPolicyPage();
this.clickNextButton();
}
static fillFlightAndHotelWithMoveToCarsFlow(): void {
this.clickNextButton();
this.setBookingPolicyYes();
this.fillFlightAndHotelFlow();
this.clickSummaryPageNextButton();
}
static setBookNotificationOutOfPolicy(): void {
cy.allure().logStep('policy wizard click on out of policy answer');
cy.get(selectors.outOfPolicyRadioButton).click();
}
static fillFlowWithOutOfPolicyAnswer(): void {
this.setBookNotificationOutOfPolicy();
this.fillFlightAndHotelFlow();
}
static fillOtherFlightPolicyPage(): void {
cy.allure().logStep('policy wizard other flight policy');
cy.get(selectors.otherFlightPolicyCabinSelect).click();
cy.get(selectors.maxAllowedCabinPremiumEconomy).click();
cy.get(selectors.bookingLeadTimeInput).clear();
cy.get(selectors.bookingLeadTimeInput).type(bookLeadTimeInput);
cy.get(selectors.cabinAndSeatUpgradeDropdown).click();
cy.get(selectors.cabinUpgradeToggle).click();
cy.get(selectors.seatToggle).click();
}
static fillHotelSpendPolicyPage(): void {
cy.allure().logStep('policy wizard hotel spend policy');
cy.get(selectors.percentInput).wait(100).clear();
cy.get(selectors.percentInput).type(percentInput);
cy.get(selectors.maxPriceDropdown).click();
cy.get(selectors.maxPriceInput).wait(100).clear();
cy.get(selectors.maxPriceInput).type(maxHotelPriceInput);
}
static fillOtherHotelPolicyPage(): void {
cy.allure().logStep('policy wizard other hotel policy');
cy.get(selectors.otherHotelPolicyClassSelect).click();
cy.get(selectors.bookingLeadTimeInput).wait(100).clear();
cy.get(selectors.bookingLeadTimeInput).type(bookLeadTimeInput);
}
static clickSummaryStageSaveAndClose(): void {
cy.allure().logStep('policy wizard summary stage save and close');
cy.get(selectors.summarySaveAndCloseCta).click();
}
static clickSaveAndCloseEndOfWizard(): void {
cy.allure().logStep(' click save and close at the end of the wizard flow');
cy.get(selectors.saveAndCloseWholeWizardCta).click();
}
static clickOnBookingPolicyNotRightNowAnswer(): void {
cy.allure().logStep('policy wizard not right now');
cy.get(selectors.notRightNowRadioButton).click();
}
static clickBackButton(): void {
cy.allure().logStep('policy wizard click 1 time back button');
cy.get(selectors.backButton).click();
}
static clickTwiceBackButton(): void {
cy.allure().logStep('policy wizard click 2 times back button');
cy.get(selectors.backButton).click();
cy.get(selectors.backButton).click();
}
static clickTwiceBackAndOneBackInSaveAndClose(): void {
cy.allure().logStep('policy wizard click 3 times back button');
this.clickTwiceBackButton();
cy.get(selectors.backButtonInSaveAndClosePage).click();
}
static checkDynamicPolicyModal(): void {
cy.allure().logStep('policy wizard check dynamic policy modal');
cy.get(selectors.dynamicPolicyModal).click();
cy.allure().logStep('Click the "Got it" button');
cy.contains('button', gotItButtonText).click();
}
static checkBookingLeadTimeModal(): void {
cy.allure().logStep('policy wizard check booking lead time modal');
cy.get(selectors.bookingLeadTimeModal).click();
cy.allure().logStep('Check Modal');
cy.contains('button', gotItButtonText).click();
}
static verifyDropModal(): void {
cy.allure().logStep('policy wizard verify drop modal');
cy.get(selectors.dropModalExitPolicySetup).should('be.visible');
}
static verifyFlightNotificationsOnlyVisible(): void {
cy.allure().logStep('Verify all flight policy elements are not visible and only notifications is visible');
cy.get(selectors.flightValidationPageCost).should('not.exist');
cy.get(selectors.flightCabinClassLong).should('not.exist');
cy.get(selectors.flightUpgradesLine).should('not.exist');
cy.get(selectors.flightDurationline).should('not.exist');
cy.get(selectors.flightBookingNotifications).should('be.visible');
}
static verifyTrainNotificationsOnlyVisible(): void {
cy.allure().logStep('Click train icon');
cy.get(selectors.validationPageTrainIcon).click();
cy.allure().logStep('Verify all train policy elements are not visible and only notifications is visible');
cy.get(selectors.validationPageCost).should('not.exist');
cy.get(selectors.ValidationPageClassAllowed).should('not.exist');
cy.get(selectors.ValidationPageBookLeadTime).should('not.exist');
cy.get(selectors.trainBookingNotifications).should('be.visible');
}
static verifyHotelNotificationsOnlyVisible(): void {
cy.allure().logStep('Click hotel icon');
cy.get(selectors.validationPageHotelIcon).click();
cy.allure().logStep('Verify all hotel policy elements are not visible and only notifications is visible');
cy.get(selectors.validationPageCost).should('not.exist');
cy.get(selectors.ValidationPageClassAllowed).should('not.exist');
cy.get(selectors.hotelValidationPageRoomsCancellation).should('not.exist');
cy.get(selectors.ValidationPageBookingApproval).should('be.visible');
}
static verifyCarNotificationsOnlyVisible(): void {
cy.allure().logStep('Click car icon');
cy.get(selectors.validationPageCarIcon).click();
cy.allure().logStep('Verify all car policy elements are not visible and only notifications is visible');
cy.get(selectors.validationPageCost).should('not.exist');
cy.get(selectors.ValidationPageClassAllowed).should('not.exist');
cy.get(selectors.hotelValidationPageRoomsCancellation).should('not.exist');
cy.get(selectors.ValidationPageBookingApproval).should('be.visible');
}
static verifyFirstSaveAndCloseNotRightNowFlow(): void {
cy.allure().logStep('policy wizard verify first save and close only notifications');
this.verifyFlightNotificationsOnlyVisible();
this.verifyTrainNotificationsOnlyVisible();
this.verifyHotelNotificationsOnlyVisible();
this.verifyCarNotificationsOnlyVisible();
}
static fillEntireWizardFlow(): void {
this.setBookNotificationAll();
this.fillFlightAndHotelWithMoveToCarsFlow();
this.fillCarSpendPolicyPage();
this.clickNextButton();
this.fillOtherCarPolicyPage();
this.clickNextButton();
this.clickSummaryPageNextButton();
this.fillTrainSpendPolicyPage();
this.clickNextButton();
this.summaryTableDataValidation();
}
static policyWizardFlowWithBackNavigations(): void {
this.fillEntireWizardFlow();
this.clickTwiceBackAndOneBackInSaveAndClose();
this.verifyOtherCarPolicyContent();
this.clickTwiceBackAndOneBackInSaveAndClose();
this.clickBackButton();
this.verifyHotelSpendPolicyContent();
this.clickBackButton();
this.checkBookingLeadTimeModal();
this.clickBackButton();
this.verifyFlightSpendPolicyContent();
this.checkDynamicPolicyModal();
this.clickTwiceBackButton();
this.clickBackButton();
this.verifyDropModal();
}
static fillFlowWithSkipFromCarToTrainPolicy(): void {
this.setBookNotificationAll();
this.fillFlightAndHotelWithMoveToCarsFlow();
this.clickSkipToTrainPolicyButton();
this.fillTrainSpendPolicyPage();
this.clickNextButton();
}
static setNotificationsNotRightNowFlow(): void {
this.clickOnNoneAnswer();
this.clickNextButton();
this.clickOnBookingPolicyNotRightNowAnswer();
this.clickSaveAndCloseEndOfWizard();
}
static clickSummaryPageNextButton(): void {
cy.allure().logStep('policy wizard summary page next button');
cy.get(selectors.summaryNextButton).click();
}
static fillCarSpendPolicyPage(): void {
cy.allure().logStep('policy wizard car spend policy');
cy.get(selectors.percentInput).wait(100).clear();
cy.get(selectors.percentInput).type(percentInput);
cy.get(selectors.maxPriceDropdown).click();
cy.get(selectors.maxPriceInput).wait(100).clear();
cy.get(selectors.maxPriceInput).type(maxCarPriceInput);
}
static verifyOtherCarPolicyContent(): void {
const expectedValues = {
carClass: 'Luxury',
bookingLeadTime: bookLeadTimeInput
};
cy.allure().logStep('Verify car policy content has not changed');
cy.get(selectors.otherCarPolicyClassSelect).should('contain', expectedValues.carClass);
cy.get(selectors.bookingLeadTimeInput).should('have.value', expectedValues.bookingLeadTime);
}
static verifyHotelSpendPolicyContent(): void {
const expectedValues = {
PercentInput: percentInput,
MaxHotelPriceInput: maxHotelPriceInput
};
cy.allure().logStep('Verify hotel spend policy content is correct');
cy.get(selectors.percentInput).should('have.value', expectedValues.PercentInput);
cy.get(selectors.maxPriceInput).should('have.value', expectedValues.MaxHotelPriceInput);
}
static verifyFlightSpendPolicyContent(): void {
const expectedValues = {
PercentInput: percentInput,
MaxFlightPriceInput: 1000
};
cy.allure().logStep('Verify flight spend policy content is correct');
cy.get(selectors.percentInput).should('have.value', expectedValues.PercentInput);
cy.get(selectors.maxPriceInput).should('have.value', expectedValues.MaxFlightPriceInput);
}
static fillOtherCarPolicyPage(): void {
cy.allure().logStep('policy wizard other car policy');
cy.get(selectors.otherCarPolicyClassSelect).click();
cy.contains('div.ta-select-option__label', carClassAllowed).click();
cy.get('body').click();
cy.get(selectors.bookingLeadTimeInput).wait(100).clear();
cy.get(selectors.bookingLeadTimeInput).type(bookLeadTimeInput);
}
static fillTrainSpendPolicyPage(): void {
cy.allure().logStep('policy wizard train spend policy');
cy.get(selectors.maxPriceInput).wait(100).clear();
cy.get(selectors.maxPriceInput).type(maxTrainPriceInput);
cy.get(selectors.bookingLeadTimeInput).wait(100).clear();
cy.get(selectors.bookingLeadTimeInput).type(bookLeadTimeInput);
}
static clickSkipToTrainPolicyButton(): void {
cy.allure().logStep('policy wizard skip to train policy button');
cy.get(selectors.skipToTrainPolicyButton).click();
}
static summaryTableDataValidation(): void {
cy.allure().logStep('policy wizard summary table data validation');
this.checkSummaryTableFlightData();
this.checkSummaryTableHotelData();
this.checkSummaryTableCarData();
this.checkSummaryTableTrainData();
}
static PolicyWizardCheckPageDataValidation(): void {
cy.allure().logStep('policy wizard travel policy page data validation');
this.checkFlightPolicyTable();
this.checkHotelPolicyTable();
this.checkCarPolicyTable();
this.checkTrainPolicyTable();
}
static checkSummaryTableFlightData(): void {
const scenarios = [
{ selector: selectors.summaryTableFlightMedianPrice, expectedValue: percentInput },
{
selector: selectors.summaryTableFlightMaxPrice,
expectedValue: maxFlightPriceInput
},
{
selector: selectors.summaryTableFlightMaxCabin,
expectedValue: 'Premium Economy'
},
{
selector: selectors.summaryTableFlightBookLeadTime,
expectedValue: bookLeadTimeInput
}
];
cy.allure().logStep('policy wizard check summary table flight data');
scenarios.forEach((scenario) => {
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
static checkSummaryTableHotelData(): void {
const scenarios = [
{
step: 'policy wizard check summary table hotel median price',
selector: selectors.summaryTableHotelMedianPrice,
expectedValue: percentInput
},
{
step: 'policy wizard check summary table hotel max price',
selector: selectors.summaryTableHotelMaxPrice,
expectedValue: maxHotelPriceInput
},
{
step: 'policy wizard check summary table hotel book lead time',
selector: selectors.summaryTableHotelBookLeadTime,
expectedValue: bookLeadTimeInput
},
{
step: 'policy wizard check summary table hotel room type',
selector: selectors.summaryTableHotelRoomType,
expectedValue: 'All rooms allowed'
}
];
cy.allure().logStep('policy wizard check summary table hotel data');
scenarios.forEach((scenario) => {
cy.allure().logStep(scenario.step);
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
static checkSummaryTableCarData(): void {
const scenarios = [
{
step: 'policy wizard check summary table car median price',
selector: selectors.summaryTableCarMedianPrice,
expectedValue: percentInput
},
{
step: 'policy wizard check summary table car book lead time',
selector: selectors.summaryTableCarBookLeadTime,
expectedValue: bookLeadTimeInput
},
{
step: 'policy wizard check summary table car max class',
selector: selectors.summaryTableCarClass,
expectedValue: 'Luxury'
}
];
cy.allure().logStep('policy wizard check summary table car data');
scenarios.forEach((scenario) => {
cy.allure().logStep(scenario.step);
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
static checkSummaryTableTrainData(): void {
const scenarios = [
{
step: 'policy wizard check summary table train max price',
selector: selectors.summaryTableTrainMaxPrice,
expectedValue: maxTrainPriceInput
},
{
step: 'policy wizard check summary table train book lead time',
selector: selectors.summaryTableTrainBookLeadTime,
expectedValue: bookLeadTimeInput
},
{
step: 'policy wizard check summary table train class',
selector: selectors.summaryTableTrainClass,
expectedValue: 'Standard'
}
];
cy.allure().logStep('policy wizard check summary table train data');
scenarios.forEach((scenario) => {
cy.allure().logStep(scenario.step);
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
static checkFlightPolicyTable(): void {
const scenarios = [
{ selector: selectors.flightValidationPageCost, expectedValue: percentInput },
{
selector: selectors.flightValidationPageCost,
expectedValue: maxFlightPriceInput
},
{
selector: selectors.flightCabinClassLong,
expectedValue: 'Premium Economy'
},
{
selector: selectors.flightBookingLeadTimeLong,
expectedValue: bookLeadTimeInput
}
];
cy.allure().logStep('Check policy page data validation - flights');
cy.allure().logStep('Click on dismiss button in modal');
//cy.get(selectors.dismissButtonModalValidationPage).click();
scenarios.forEach((scenario) => {
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
static checkHotelPolicyTable(): void {
cy.allure().logStep('Click on the hotel validation page icon');
cy.get(selectors.validationPageHotelIcon).click();
const scenarios = [
{
step: 'policy wizard check page validation hotel median price',
selector: selectors.validationPageCost,
expectedValue: percentInput
},
{
step: 'policy wizard check page validation hotel max price',
selector: selectors.validationPageCost,
expectedValue: maxHotelPriceInput
},
{
step: 'policy wizard check page validation hotel book lead time',
selector: selectors.ValidationPageBookLeadTime,
expectedValue: bookLeadTimeInput
},
{
step: 'policy wizard check page validation hotel room type',
selector: selectors.hotelValidationPageRoomsCancellation,
expectedValue: 'All rooms allowed'
}
];
cy.allure().logStep('Check policy page data validation - Hotel');
scenarios.forEach((scenario) => {
cy.allure().logStep(scenario.step);
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
static checkCarPolicyTable(): void {
cy.allure().logStep('Click on the car validation page icon');
cy.get(selectors.validationPageCarIcon).click();
const scenarios = [
{
step: 'policy wizard check page validation car median price',
selector: selectors.validationPageCost,
expectedValue: percentInput
},
{
step: 'policy wizard check page validation car book lead time',
selector: selectors.ValidationPageBookLeadTime,
expectedValue: bookLeadTimeInput
},
{
step: 'policy wizard check page validation car max class',
selector: selectors.ValidationPageClassAllowed,
expectedValue: 'Luxury'
}
];
cy.allure().logStep('Check policy page data validation - Cars');
scenarios.forEach((scenario) => {
cy.allure().logStep(scenario.step);
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
static checkTrainPolicyTable(): void {
cy.allure().logStep('Click on the train validation page icon');
cy.get(selectors.validationPageTrainIcon).click();
const scenarios = [
{
step: 'policy wizard check summary table train max price',
selector: selectors.validationPageCost,
expectedValue: maxTrainPriceInput
},
{
step: 'policy wizard check page validation train book lead time',
selector: selectors.ValidationPageBookLeadTime,
expectedValue: bookLeadTimeInput
},
{
step: 'policy wizard check page validation train class',
selector: selectors.ValidationPageClassAllowed,
expectedValue: 'Standard'
}
];
cy.allure().logStep('Check policy page data validation - Trains');
scenarios.forEach((scenario) => {
cy.allure().logStep(scenario.step);
cy.get(scenario.selector).should('contain', scenario.expectedValue);
});
}
}