import { LoginPage } from '@admin-lib/index';
import { stagingUsers } from '@fixtures/staging-users';
import { ProfileInterceptApis } from '@profile-lib/api-intercept';
import { Rewards } from '../../../../rewards/lib/rewards';
import { ReferralsUtil } from '@growth-lib/referrals-util';
import { PersonalTravel } from 'cypress/e2e/personal_travel/lib/travel';

const newUserCredentials = Cypress.env('newUser').NEW_USER_PASSWORD;
describe('Personal Travel: Rewards profile page', () => {
  beforeEach(() => {
    LoginPage.visitTALoginPage();
    ProfileInterceptApis.interceptProfileApis();
  });

  it(
    'C11753401: Verify the rewards tab is shown for personal only accounts that has rewards earned',
    { tags: ['@tier1'] },
    () => {
      LoginPage.loginWithCredentials(
        stagingUsers.personal_only_user.email,
        newUserCredentials
      );
      PersonalTravel.closeHomePagePromoModal();
      Rewards.verifyRewardsOnGlobalNav();
      Rewards.openRewardsPage();
      Rewards.verifyRewardsTabContent();
    }
  );

  it(
    'C11753402: Verify the rewards is not shown for personal only accounts that does not have rewards earned/expired',
    { tags: ['@tier1'] },
    () => {
      LoginPage.loginWithCredentials(
        stagingUsers.personal_no_rewards_user.email,
        newUserCredentials
      );
      Rewards.verifyRewardsOnGlobalNavNotShown();
      ReferralsUtil.openReferralPage();
    }
  );

  it(
    'C11753403: Verify the rewards tab is shown for business users that have rewards enabled for the company',
    { tags: ['@tier1'] },
    () => {
      LoginPage.loginWithCredentials(stagingUsers.cfr_user.email, newUserCredentials);
      Rewards.verifyRewardsOnGlobalNav();
      Rewards.openRewardsPage();
      Rewards.verifyRewardsTabContent();
    }
  );

  it(
    'C11753404: Verify the rewards tab is not shown for business users that does not have rewards enabled for the company',
    { tags: ['@tier1'] },
    () => {
      LoginPage.loginWithCredentials(
        stagingUsers.us_domestic_sabre_user.email,
        newUserCredentials
      );
      Rewards.verifyRewardsOnGlobalNavNotShown();
      ReferralsUtil.openReferralPage();
    }
  );
});
