UNPKG

qe-fe-automation

Version:
53 lines (45 loc) 2.09 kB
import { SplitUtility } from '@split-lib/index'; import { SharedIntercepts } from '@intercepts-lib/index'; const pattern = /\/api\/user\/teamEvents\/[a-zA-Z0-9-]+\/invitees\/bulkAdd/; export class TeamEventsInterceptApis { static teamEventIntercept() { cy.updateSplits(); SplitUtility.isSplitOn('GROUP_TRAVEL_REFACTOR').then((refactored) => { if (refactored) { this.groupTravelIntercept(); } else { this.teamEventInterceptLegacy(); } }); } static teamEventInterceptLegacy() { SharedIntercepts.intercepts(); cy.intercept('GET', new RegExp('/api/user/teamEvents')).as('waitForTeamEvent'); cy.intercept('GET', new RegExp('/api/user/teamEvents/bookableUsers')).as( 'waitForTeamEventBookableUser' ); cy.intercept('POST', pattern).as('waitForTeamEventBulkAdd'); cy.intercept('PUT', /api\/user\/teamEvents/).as('waitForLocation'); cy.intercept('PUT', /api\/user\/teamEvents/).as('waitForConfirmRoomBlock'); cy.intercept('PATCH', /api\/user\/teamEvents/).as('waitForSaveChanges'); cy.intercept('POST', /api\/user\/guests/).as('waitForSaveGuest'); cy.intercept('GET', /api\/user\/tripInvitations/).as('waitForInvitation'); } static groupTravelIntercept() { SharedIntercepts.intercepts(); cy.intercept('GET', new RegExp('/api/v1/user/travel-events')).as('waitForTeamEvent'); cy.intercept( 'GET', /\/api\/v1\/user\/travel-events\/[a-zA-Z0-9-]+\/invitable-users/ ).as('waitForTeamEventBookableUser'); cy.intercept( 'POST', /\/api\/v1\/user\/travel-events\/[a-zA-Z0-9-]+\/invitations\/bulk-create/ ).as('waitForTeamEventBulkAdd'); cy.intercept('PUT', /api\/v1\/user\/travel-events/).as('waitForLocation'); cy.intercept('PUT', /api\/v1\/user\/travel-events/).as('waitForConfirmRoomBlock'); cy.intercept('PUT', /api\/v1\/user\/travel-events/).as('waitForSaveChanges'); cy.intercept('POST', /api\/user\/guests/).as('waitForSaveGuest'); cy.intercept('GET', /api\/v1\/user\/bookable-travel-events/).as('waitForInvitation'); } }