qe-fe-automation
Version:
FE test automation framework using cypress
116 lines (102 loc) • 3.98 kB
text/typescript
import { guidRegex } from '@utility-lib/index';
import { AmplitudeEvents } from '@growth-lib/amplitude-events';
import { SharedIntercepts } from '@intercepts-lib/index';
const flightBaseUrl = 'api/v1/trip/flight';
export class FlightInterceptApis {
static interceptFlightsApis() {
SharedIntercepts.intercepts();
AmplitudeEvents.interceptAmplitudeAPI();
cy.intercept('GET', '**/api/v1/trip/affiliate/profile/companies/**').as(
'waitForPpbProfile'
);
// flight search result page
cy.intercept('GET', '**/api/v1/trip/flight/searches/**/flights/**/fares').as(
'waitForDepartureFlightFares'
);
cy.intercept('GET', '**/api/v1/trip/flight/searches/**/flights/**/validate').as(
'waitForDepartureFlightValidation'
);
cy.intercept('POST', '**/api/v1/trip/flight/searches/**/departures/**/returns**').as(
'waitForReturnFlight'
);
cy.intercept(
'GET',
'**/api/v1/trip/flight/searches/**/departures/**/returns/**/fares**'
).as('waitForReturnFlightFares');
cy.intercept(
'GET',
'**/api/v1/trip/flight/searches/**/departures/**/returns/**/validate**'
).as('waitForReturnFlightValidation');
cy.intercept('POST', '**/api/v1/trip/flight/searches/**/departures/**/contract**').as(
'waitForOnewayFlightContract'
);
cy.intercept(
'POST',
'**/api/v1/trip/flight/searches/**/departures/**/returns/**/contract**'
).as('waitForRoundtripFlightContract');
cy.intercept(
'POST',
'**/api/v1/trip/flight/bundle/searches/**/bundles/**/contract**'
).as('waitForBundleFlightContract');
//################## Flight CONTRACTS ##################
cy.intercept(
'GET',
new RegExp(
`${flightBaseUrl}(/bundle/|/bundle/flexible/|/)searches/${guidRegex}/contracts/${guidRegex}`
)
).as('waitForFlightContract');
cy.intercept(
'POST',
new RegExp(
`${flightBaseUrl}(/bundle/|/bundle/flexible/|/)searches/${guidRegex}/contract\\?`
)
).as('waitForAlternativeContract');
//################## Flight TRIPS ##################
cy.intercept(
'GET',
new RegExp(
`(${flightBaseUrl}(/bundle/|/bundle/flexible/|/)searches/${guidRegex}/matchingTrips\\?.+|/api/user/trips/${guidRegex})`
)
).as('waitForMatchingTrips');
//################## FLIGHT SEARCHES ##################
cy.intercept('POST', new RegExp(`${flightBaseUrl}/searches/`)).as(
'waitForFlightStatus'
);
cy.intercept('GET', '/api/v1/trip/flight/searches?*').as('waitForGetFlightResults');
cy.intercept('POST', new RegExp(`${flightBaseUrl}/bundle/flexible/`)).as(
'waitForFlexibleFlightSearch'
);
cy.intercept('POST', /api\/v1\/trip\/flight/).as('waitForFlightSearch');
//################## FLIGHT INSURANCES ##################
cy.intercept('POST', /api\/v1\/trip\/flight\/searches/).as('waitForAirline');
cy.intercept('POST', /api\/v1\/trip\/flight\/insurance\/multipassenger/).as(
'waitForPostInsurances'
);
cy.intercept(
'POST',
/api\/v1\/trip\/flight\/insurance\/multipassenger\/insurance-details/
).as('waitForInsurances');
cy.intercept('GET', new RegExp('api/admin/trips\\?.+')).as('manageTrip');
cy.intercept(
'POST',
new RegExp(`/api/user/bookableUsers/${guidRegex}/loyaltyProgramMemberships`)
).as('waitForLoyaltyPrograms');
cy.intercept(
'GET',
new RegExp(`(${flightBaseUrl}/bookings/${guidRegex}/tickets)`)
).as('tickets');
cy.intercept('GET', new RegExp(`(/api/invoices/v2/sync_status/${guidRegex})`)).as(
'invoice'
);
cy.intercept(
'POST',
new RegExp(
`${flightBaseUrl}/searches/${guidRegex}/departures/${guidRegex}/returns?`
)
).as('waitForFlightBookStatus');
// itinerary page
cy.intercept('GET', '**api/v1/trip/flight/bookings/**/tickets').as(
'waitForFlightTickets'
);
}
}