import { LoginPage } from '@admin-lib/index';
import { Provider_Type, User_Type } from '@support-onboard/index';
import { LocationUtility } from '@utility-lib/index';
import { ProfileInterceptApis } from '@profile-lib/index';
import {
  HotelCheckout,
  HotelInterceptApis,
  Hotels,
  HotelSearchResults
} from '@hotel-lib/index';
import { TravelPlanner } from '../../lib/travel_planner';
import { ExploratorySearch } from '../../lib/exploratory_search';

describe('Personal Travel: EA Trips page', () => {
  beforeEach(() => {
    LoginPage.createNewCompanyAndLoginWithUserByType({
      providers: [Provider_Type.ALL_CAR],
      users: [User_Type.ADMIN],
      companySuffix: 'travelplanner'
    });
    ProfileInterceptApis.interceptProfileApis();
    HotelInterceptApis.interceptHotelApis();
    TravelPlanner.assignDelegateAndViewTravelPlanner();
  });

  it(
    'C9756014: Verify delegate is able to create a new trip for traveler from EA trip page',
    { tags: ['@tier1'] },
    () => {
      TravelPlanner.acceptOnboardingAndBookmarkTraveler();
      cy.wait(3000);
      TravelPlanner.clickNewTrip();
      ExploratorySearch.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();
      HotelCheckout.acceptAcknowledgement();
      HotelCheckout.bookNow();
      HotelCheckout.expectHotelBookedSuccessfully('Hotel confirmed!');
      TravelPlanner.seeAllTrips();
    }
  );
});
