import { LoginPage } from '@admin-lib/index';
import { HotelCheckout, HotelInterceptApis, HotelItinerary } from '@hotel-lib/index';
import { stagingUsers } from '@fixtures/staging-users';
import { HomePage } from '@rebranded_home_page-lib/home-page';
import { PersonalTravel } from '../../lib/travel';
import { ExploratorySearch } from '../../lib/exploratory_search';
import { Itinerary } from '../../lib';
import { createGuestDetails } from '@user-lib/factory/guest_user';

const newUserCredentials = Cypress.env('newUser').NEW_USER_PASSWORD;
describe('Personal Travel: Personal-only accounts', () => {
  beforeEach(() => {
    LoginPage.visitTALoginPage();
    LoginPage.loginWithCredentials(stagingUsers.personal_only_user.email, newUserCredentials);
    HotelInterceptApis.interceptHotelApis();
  });

  it('C4678766: Book a hotel for personal only account', { tags: ['@tier1'] }, () => {
    const guestDetails = createGuestDetails(30, 'MALE', 'Personal');
    PersonalTravel.closeHomePagePromoModal();
    HomePage.expandSearchForm();
    ExploratorySearch.selectVertical('hotel');
    ExploratorySearch.initiatePersonalHotelSearch();
    ExploratorySearch.selectPersonalRoomOption();
    ExploratorySearch.checkoutHotel(1);
    ExploratorySearch.clickTravelerDropdown(0);
    //ExploratorySearch.selectTravelerAtHotelCheckout(' Select Traveler for room 1 ');
    ExploratorySearch.createNewTravelerAtCheckout(guestDetails);
    HotelCheckout.setPhoneNumber();
    HotelCheckout.acceptAcknowledgement();
    HotelCheckout.bookNow();
    Itinerary.dismissBookingModal();
    HotelItinerary.cancelHotel();
  });
});
