import { FlightBookingUtility, FlightUtility } from '@flight-modal/index';
import { FlightTripType } from '@flight-lib/index';
import { User_Type } from '@support-onboard/index';
import isEqual from 'lodash.isequal';
import { LocationUtility } from '@utility-lib/location';

describe('Flight: Round trip flight', () => {
  it(
    'C352123: Traveler searches again from results page for round trip flight',
    { tags: ['@tier4'] },
    () => {
      const flightBookingParams = FlightBookingUtility.initFlightBookingParams({
        locations: LocationUtility.getPairOfOriginAndDestinationAirportsUS(),
        flightTripType: FlightTripType.ROUNDTRIP,
        tripTileType: 'Business'
      });
      FlightUtility.prepareCompanyAndUserCreation(User_Type.TRAVELER);
      const airports = LocationUtility.getPairOfOriginAndDestinationAirportsUS();
      FlightUtility.runSearchFlow(flightBookingParams);
      let newAirports = LocationUtility.getPairOfOriginAndDestinationAirportsUS();
      while (isEqual(airports, newAirports)) {
        newAirports = LocationUtility.getPairOfOriginAndDestinationAirportsUS();
      }
      FlightUtility.runSearchFlowFormSearchResult(newAirports[0], newAirports[1]);
    }
  );
});
