qe-fe-automation
Version:
FE test automation framework using cypress
99 lines (85 loc) • 4.59 kB
text/typescript
import { OnboardingGuide } from '@growth-lib/onboarding-guide';
import { Timeouts } from '@utility-lib/constants';
import { AmplitudeEvents } from '@growth-lib/amplitude-events';
const freePricingSelectors = {
pricingScreenTitle: 'Grow & save with Navan',
pricingScreenTravelSlider: '.calculator__estimation-box__slider',
pricingScreenExpenseSlider: '.calculator__estimation__slider',
pricingScreenFaqAccordion: '[data-testid="mainFaqAccordion"]',
pricingScreenExpandFaq: '.help-box__container',
pricingScreenTravelNote: 'Unlimited trips every month with $0 trip fees',
pricingScreenFootNotes: '.footnotes',
travelAdminTitle: '.pricing-overview__title',
travelAdminTripsNote: 'Unlimited trips every month with $0 trip fees',
travelAdminTermsOfServiceNote: '.pricing-overview__description',
travelAdminFaqSection: '.pricing-faq__title',
expenseAdminFaqSection: '.pricing-faq__title__web',
expenseAdminTitle: '[data-testid="pricingOverviewObjectTitle"]',
expenseAdminSlider: '.price-calculation__calculator__slider',
createAccountButton: '[data-testid="primaryActionButton"]',
chilliPiper: '[data-testid="chilipiper"]',
pricingScreenTermsOfServiceNote: '.pricing__terms-and-condition',
companySetUpCTA: '[data-testid="companySetup"]',
adminClaimEntryPoint: 'ta-entry-points-growth-container ta-button-v2'
};
export class FreePricing {
static verifyTravelAdminPricingScreen(): void {
cy.allure().logStep('verify the travel admin pricing screen');
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
cy.visit('/app/admin2/en/settings/pricing/');
cy.get(freePricingSelectors.travelAdminTitle).should('be.visible');
cy.contains('Unlimited trips every month with $0 trip fees').should('be.visible');
cy.contains(' Monthly, renews on the 1st of every month').should('be.visible');
cy.get(freePricingSelectors.travelAdminTermsOfServiceNote).should('be.visible');
cy.get(freePricingSelectors.travelAdminFaqSection).should('be.visible');
}
static verifyExpenseAdminPricingScreen(): void {
cy.allure().logStep('verify the expense admin pricing screen');
OnboardingGuide.openOnboardingGuide();
OnboardingGuide.completeAddAddressTask();
cy.visit('/app/liquid/admin/company/settings/pricing-overview');
cy.get(freePricingSelectors.expenseAdminTitle).should('be.visible');
cy.contains('3 active users').should('be.visible');
cy.contains('From the 4th active user and for every additional user, a monthly fee of $8 will be applied.').should(
'be.visible'
);
cy.get(freePricingSelectors.travelAdminTermsOfServiceNote).should('be.visible');
cy.get(freePricingSelectors.travelAdminFaqSection).should('be.visible');
cy.get(freePricingSelectors.expenseAdminSlider).should('be.visible');
cy.get(freePricingSelectors.expenseAdminFaqSection).should('be.visible');
}
static rogueVerifyPricingAndClaimAdmin(): void {
cy.allure().logStep('Claim the promo banner as a rogue');
cy.get(freePricingSelectors.createAccountButton).click();
this.verifyTravelPricingScreenIsOpened();
}
static verifyTravelPricingScreenIsOpened(isDelegate = false): void {
cy.allure().logStep('verify t elements in the pricing screen');
cy.wait('@chilipiperSDK');
cy.contains('Grow & save with Navan').should('be.visible');
cy.get(freePricingSelectors.pricingScreenTravelSlider).should('be.visible');
cy.get(freePricingSelectors.pricingScreenFaqAccordion).should('be.visible');
cy.get(freePricingSelectors.pricingScreenExpandFaq).click();
cy.wait(Timeouts.SHORT_TIMEOUT_1_SEC.timeout);
cy.scrollTo('bottom');
if (!isDelegate) {
cy.get(freePricingSelectors.chilliPiper).should('be.visible');
}
cy.get(freePricingSelectors.pricingScreenTermsOfServiceNote).should('not.exist');
}
static verifyExpensePricingScreenIsOpened(): void {
cy.allure().logStep('verify t&e elements in the pricing screen');
cy.get(freePricingSelectors.pricingScreenExpenseSlider).should('be.visible');
this.verifyTravelPricingScreenIsOpened();
}
static openPricing(): void {
cy.allure().logStep('Open pricing page from home');
cy.get(freePricingSelectors.adminClaimEntryPoint).eq(0).click();
AmplitudeEvents.addExpectedAmplitudeEvents('pricing page clicked', 'pricing page opened');
}
static openAdminClaim(): void {
cy.allure().logStep('Display pricing page');
cy.get(freePricingSelectors.companySetUpCTA).eq(0).click();
AmplitudeEvents.addExpectedAmplitudeEvents('admin claim clicked', 'admin claim page opened');
}
}