import {
  TrainSearchModalUtil,
  TrainTripType,
  AmtrakBookingParams,
  CheckoutModal,
  CancellationFlow,
  TrainBookingManager
} from '@train-lib/index';

describe('Train: Amtrak round trip multi traveler cancellation workflow', () => {
  it(
    'C48360: Should be able to book and cancel one way train ticket',
    { tags: ['@amtrak', '@all_train_test'] },
    () => {
      const tripType = TrainTripType.ROUND_TRIP;
      const bookingParams = {
        tripType: tripType,
        origin: AmtrakBookingParams.Location.NewYork,
        destination: AmtrakBookingParams.Location.Washington,
        multipleTravelers: true
      };

      TrainSearchModalUtil.createCompanyWithProviderName({
        multipleTravelers: true
      });

      TrainSearchModalUtil.executeTrainSearch(bookingParams);
      TrainBookingManager.selectCancelOrExchangeTripAndProcessForCheckout({
        tripType: tripType,
        trainClass: true,
        fareType: AmtrakBookingParams.FareType.FIRST_CLASS
      });
      CheckoutModal.checkout({
        noOfTravelers: 2
      });

      cy.contains('We advise you to print your e-ticket(s) for this route.');

      CancellationFlow.executeTrainCancellation(
        'We advise you to print your e-ticket(s) for this route.',
        tripType
      );
    }
  );
});
