import {
  HotelInterceptApis,
  Hotels,
  HotelSearchResults,
  HotelCheckout
} from '@hotel-lib/index';
import { PersonalTravel } from '../../../lib/travel';
import { Utility } from '@utility-lib/utility';
import { LocationUtility } from '@utility-lib/location';
import { Random } from '@utility-lib/random';

const tripTileType = 'Personal';
describe('Personal Travel: Trips page validation for personal trips', () => {
  beforeEach(() => {
    PersonalTravel.createUserUnifiedOnboarding();
    HotelInterceptApis.interceptHotelApis();
  });

  it(
    'C9367212: User should be prompted for gender, birthdate, phone number at checkout when required by BE',
    { tags: ['@tier2'] },
    () => {
      Utility.selectTripTileType(tripTileType);
      Utility.selectVertical('hotel');
      Hotels.setCheckInCheckOutDate();
      Hotels.selectHotelLocation(LocationUtility.getCityUS());
      Hotels.searchHotel();
      HotelSearchResults.selectHotel(0);
      HotelSearchResults.selectRoomOption();
      HotelCheckout.waitToBeLoaded();
      HotelCheckout.setTripInfo();
      HotelCheckout.acceptHotelBookingPolicy();
      HotelCheckout.setPhoneNumber();
      HotelCheckout.checkIfProofOfVaccineRequired();
      PersonalTravel.fillDob();
      HotelCheckout.updateEmailDetails(
        'personal-' + Random.randomString(12) + '@staging-prime.tripactions.xyz'
      );
      PersonalTravel.fillPhoneNumber();
      PersonalTravel.saveRequiredInfo();
    }
  );
});
