qe-fe-automation
Version:
FE test automation framework using cypress
60 lines (51 loc) • 2.11 kB
text/typescript
import { AmplitudeEvents, GrowthAmplitudeEvents } from '@growth-lib/amplitude-events';
const referrals = {
profileMenuButton: '[data-qaid="USER_MENU-button"]',
referralButtonMenuBar: '[data-qaid="REFERRALS"]',
copyLinkButton: '[data-testid="shareLinkButton"]',
referralLinkInput: '[data-testid="referralLinkInput"]',
referralAmount: '$500',
pendingState: '[data-testid="test company-status"]',
roguePopupTitle: '.how-it-works__flow__title',
roguePopupSubtitle: 'You’re on track to $500 in Navan Rewards',
companySetupCta: '[data-testid="companySetup"] > .ta-button-v2',
companySetupInPricing:
'.price-calculation__trip__start > [data-testid="companySetup"] > .ta-button-v2'
};
export class ReferralsUtil {
static openReferralPage(): void {
cy.allure().logStep('Open referral page from home');
cy.visit('/app/user2/profile?tab=referrals');
}
static getReferralLink(): Cypress.Chainable<string> {
return cy.get(referrals.referralLinkInput).invoke('val');
}
static verifyReferralTabContent(): void {
cy.allure().logStep('Verify referral tab exist with copy link button');
cy.url().should('include', '/profile?tab=referrals');
AmplitudeEvents.addExpectedAmplitudeEvents(
GrowthAmplitudeEvents.REFERRAL_PAGE_DISPLAY
);
cy.get(referrals.copyLinkButton).should('exist');
}
static checkPendingState(): void {
cy.allure().logStep('Check pending state');
cy.get(referrals.pendingState).contains('Pending');
}
static verifyRoguePopup(): void {
cy.allure().logStep('Check rogue popup');
cy.get(referrals.roguePopupTitle).contains('Welcome to Navan');
cy.get(referrals.companySetupCta).click();
}
static setupCompany(): void {
cy.allure().logStep('Setup company');
cy.get(referrals.companySetupCta).click();
cy.get(referrals.companySetupInPricing).click();
}
static verifyRogueReferralStatusAfterAdminClaimed(): void {
cy.allure().logStep('Verify rogue referral status after admin claimed');
this.setupCompany();
this.openReferralPage();
this.verifyReferralTabContent();
}
}