import { LoginPage } from '@admin-lib/index';
import {
  HotelInterceptApis,
  Hotels,
  HotelCheckout,
  HotelSearchResults
} from '@hotel-lib/index';
import { LocationUtility } from '@utility-lib/index';

const newUserCredentials = Cypress.env('newUser').NEW_USER_PASSWORD;

describe('Hotel: Delegate booking', () => {
  beforeEach(() => {
    LoginPage.loginAsCompanyDelegate(newUserCredentials);
    HotelInterceptApis.interceptHotelApis();
  });

  it('C49928: should be able to book hotel as delegate', { tags: ['@tier1'] }, () => {
    Hotels.visitHotelSearch();
    Hotels.selectOneTraveller();
    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!');
  });
});
