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

describe('Train: Amtrak oneway multi traveler cancellation workflow', () => {
  it(
    'C48360: Should be able to book and cancel one way train ticket',
    { tags: ['@amtrak', '@all_train_test'] },
    () => {
      TrainSearchModalUtil.createCompanyWithProviderName({
        multipleTravelers: true
      });
      const tripType = TrainTripType.ONEWAY;

      TrainSearchModalUtil.executeTrainSearch({
        tripType: TrainTripType.ONEWAY,
        origin: AmtrakBookingParams.Location.NewYork,
        destination: AmtrakBookingParams.Location.Washington,
        multipleTravelers: true
      });
      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
      );
    }
  );
});
