import { FlightBookingUtility } from '@flight-modal/index';
import { FlightTripType } from '@flight-lib/search';
import { LocationUtility } from '@utility-lib/location';
import { Directions, FlightBookingData } from '@chat-lib/booking';
import { User_Type } from '@support-onboard/data_model/user_type';
import { HelpCenter } from '@helpcenter-lib/helpcenter';
import { ChatApiIntercept, ChatBooking, ChatBox } from '@chat-lib/index';
import { LoginPage } from '@admin-lib/index';
import { FlightInterceptApis } from '@flight-lib/index';

describe('Chat: ML supported flows', () => {
  xit('C9472001: Use chat to book flight via ML flow', { tags: ['@tier2'] }, () => {
    const flightBookingParams = FlightBookingUtility.initFlightBookingParams({
      locations: LocationUtility.getPairOfOriginAndDestinationAirportsUSWithShortName(),
      flightTripType: FlightTripType.ROUNDTRIP,
      tripTileType: 'Business'
    });
    const flightBookingData: FlightBookingData = {
      flightBookingParams: flightBookingParams,
      departingFrom: Directions.FROM,
      arrivingAt: Directions.TO,
      isChangeFlight: true
    };
    const daysToMove = { daysToMove: 8, daysAfterMovedDays: 2 };

    ChatApiIntercept.interceptChatApis();
    FlightInterceptApis.interceptFlightsApis();
    LoginPage.createNewCompanyAndLoginWithUserByType({
      users: [User_Type.ADMIN],
      companySuffix: '-avamltest'
    });
    HelpCenter.visitPage();
    ChatBox.openChatWithAva();
    ChatBox.typeMsgToAva(`I want to book a flight to ${flightBookingParams.locations}`);
    ChatBox.expectMsgReceivedFromAva(`provide`);
    ChatBooking.enterShiftedDates(daysToMove);
    ChatBox.readAvaMsgAndTypeReply('confirm', 'Yes');
    ChatBooking.continueBookTripFlight(flightBookingData);
    ChatBooking.checkIsChatMinimized();
  });
});
