UNPKG

qe-fe-automation

Version:
127 lines (122 loc) 4.09 kB
import { TravelEventInvitationRequest, TravelEventLocationType, TravelEventTravelWindowsDateTimeType, TravelEventVertical } from '@admin-factory/interface/guest_travel'; import { faker } from '@faker-js/faker'; import { Dates } from '@utility-lib/dates'; export function createFlightGuestTravel(): TravelEventInvitationRequest { const guestTravel: TravelEventInvitationRequest = { settings: { notificationSettings: { enabledOrganizerNotifications: [], enabledParticipantNotifications: [], enabledParticipantReminders: [] }, travelConditions: { accommodation: { hotelConditions: { numberOfBookingsAllowed: 0 } }, transportation: { carConditions: { numberOfBookingsAllowed: 0 }, flightConditions: { numberOfBookingsAllowed: 1 }, trainConditions: { numberOfBookingsAllowed: 0 } }, commute: { blackCars: [], cars: [], trains: [] }, travelWindows: [ { verticals: [ TravelEventVertical.FLIGHT, TravelEventVertical.HOTEL, TravelEventVertical.CAR, TravelEventVertical.BLACK_CAR, TravelEventVertical.RAIL ], earliestDepartureDateTime: { value: Dates.getDateTime(31).slice(0, 10).concat('T12:00'), type: TravelEventTravelWindowsDateTimeType.MANDATORY }, latestReturnDateTime: { value: Dates.getDateTime(35).slice(0, 10).concat('T12:00'), type: TravelEventTravelWindowsDateTimeType.MANDATORY }, latestArrivalDateTime: { value: Dates.getDateTime(31).slice(0, 10).concat('T12:00'), type: TravelEventTravelWindowsDateTimeType.SUGGESTED }, earliestLeaveDateTime: { value: Dates.getDateTime(35).slice(0, 10).concat('T12:00'), type: TravelEventTravelWindowsDateTimeType.SUGGESTED } } ], payment: { allowedPaymentMethodIds: [], //assigned below allowedCarDirectBillPaymentMethodIds: [], addingNewPaymentMethodAllowed: false }, numberOfExtraGuestsAllowed: 0, companyPolicyLevelId: '' //assigned below }, reportingSettings: { billTo: undefined, region: undefined, subsidiary: undefined, department: undefined, customFieldValues: [] } }, summary: { name: `FlightEvent-${faker.datatype.number({ min: 10000000 })}`, description: undefined, pictureUrl: undefined, startDateTime: Dates.getDateTime(32).slice(0, 10).concat('T12:00'), endDateTime: Dates.getDateTime(34).slice(0, 10).concat('T12:00'), location: { placeId: 'ChIJVVVVVYx3j4ARP-3NGldc8qQ', displayName: 'San Francisco International Airport (SFO), San Francisco, CA, USA', type: TravelEventLocationType.PLACE, companyOfficeId: undefined, companyOfficeName: undefined }, note: [], cancellationNote: [] }, participants: [ { email: '', //assigned below givenName: faker.name.firstName(), familyName: faker.name.lastName().replace(/'/g, ''), billTo: undefined, department: undefined } ], contactId: '', //assigned below shouldSendEmail: false }; cy.task('getDataFromCache', 'userResponse').then((response: any) => { guestTravel.contactId = response.uuid; guestTravel.settings.travelConditions.companyPolicyLevelId = response.companyPolicyLevel.uuid; guestTravel.participants[0].email = response.email; }); cy.task('getDataFromCache', 'paymentMethod').then((paymentMethodResponse: any) => { guestTravel.settings.travelConditions.payment.allowedPaymentMethodIds = [ paymentMethodResponse.uuid ]; }); return guestTravel; }