qe-fe-automation
Version:
FE test automation framework using cypress
130 lines (124 loc) • 4.2 kB
text/typescript
import {
TravelEventInvitationRequest,
TravelEventLocationType,
TravelEventTravelWindowsDateTimeType,
TravelEventVertical
} from '@admin-factory/interface/guest_travel';
import { faker } from '@faker-js/faker';
import { Dates } from '@utility-lib/dates';
import { LocationUtility } from '@utility-lib/index';
export function createCarGuestTravel(): TravelEventInvitationRequest {
const airportUSWithLocationId = LocationUtility.getAirportUSWithLocationId();
const guestTravel: TravelEventInvitationRequest = {
settings: {
notificationSettings: {
enabledOrganizerNotifications: [],
enabledParticipantNotifications: [],
enabledParticipantReminders: []
},
travelConditions: {
accommodation: {
hotelConditions: {
numberOfBookingsAllowed: 0
}
},
transportation: {
carConditions: {
numberOfBookingsAllowed: 1
},
flightConditions: {
numberOfBookingsAllowed: 0
},
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: `CarEvent-${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: airportUSWithLocationId.locationGoogleId,
displayName: airportUSWithLocationId.location,
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;
}