import { LoyaltyPrograms } from '@profile-lib/loyalty_programs';
import { LoginPage } from '@admin-lib/index';
import { Utility, verticalType } from '@utility-lib/index';
import { Provider_Type, User_Type } from '@support-onboard/index';
import { ProfileInterceptApis } from '@profile-lib/api-intercept';

describe('Trips: Profile: Loyalty Programs', () => {
  beforeEach(() => {
    LoginPage.createNewCompanyAndLoginWithUserByType({
      providers: [Provider_Type.EXPEDIA_FLIGHT, Provider_Type.ALL_CAR],
      users: [User_Type.TRAVELER]
    });
    Utility.visitSearchPage();
    ProfileInterceptApis.interceptProfileApis();
  });

  it(
    'C127221 C127222 C127223 C127224 C127225 C127226 C127227 C127228 C127229 C127230 C127189: Verify loyalty cards can be added for hotels, flights, cars and trains on profile page',
    { tags: ['@tier2'] },
    () => {
      const loyaltyClubs: { club: string; type: verticalType }[] = [
        { club: 'AAdvantage', type: 'flight' },
        { club: 'World of Hyatt', type: 'hotel' },
        { club: 'Hertz', type: 'car' },
        { club: 'Amtrak Guest Rewards', type: 'train' }
      ];
      LoyaltyPrograms.visitProfileLoyaltyPrograms();
      loyaltyClubs.forEach((program) => {
        LoyaltyPrograms.addLoyaltyToUser(program.club, program.type);
        LoyaltyPrograms.verifyLoyaltyPrograms(program.club, program.type);
      });
    }
  );
});
