UNPKG

qe-fe-automation

Version:
116 lines (105 loc) 4.15 kB
const adminDashboardPageSelectors = { spendSummary: 'app-spend-summary', spendOverview: 'app-spend-summary .card-item__title:nth-child(1)', analyzeButtonOnSpendOverviewCard: '[qaid=SPEND_OVERVIEW__analyze-button]', travelSpendAnalysisScreen: 'app-spend-analysis', bookingTimeFilter: '[data-qa-id=PERF_DASH_DATE_FILTER]', adoptionCard: 'app-adoption', signUpsTitle: '[qaid=signUps__title]', signUpsValue: '[qaid=signUps__value]', appInstallationsTitle: '[qaid=appInstallations__title]', appInstallationsValue: '[qaid=appInstallations__value]', travelersTitle: '[qaid=travelers__title]', travelersValue: '[qaid=travelers__value]', signUpsDownloadButton: '[qaid=signUps__download-metrics]', appInstallationsDownloadButton: '[qaid=appInstallations__download-metrics]' }; const adminQaAttribute = 'qaid'; export class AdminDashboardPage { static visitAdminDashboardPage() { cy.visit(`app/admin2/dashboard`); cy.url().should('include', '/dashboard'); } static checkSpendOverviewPresence() { cy.allure().logStep('Verify Spend Overview card is displayed on Admin Dashboard'); cy.get(adminDashboardPageSelectors.spendSummary).should('be.visible'); cy.get(adminDashboardPageSelectors.spendOverview).should('contain', 'Spend overview'); } static checkSpendOverviewValuesPresence() { cy.allure().logStep( 'Verify Spend Overview card items are displayed on Admin Dashboard' ); const spendOverviewTableTitles = [ 'TRAVEL_SPEND__title', 'TRAVEL_SPEND__value', 'SAVINGS__title', 'SAVINGS__value', 'TRIPS__title', 'TRIPS__value', 'BOOKINGS__title', 'BOOKINGS__value', 'CARBON_EMISSIONS__title', 'CARBON_EMISSIONS__value', 'FLIGHT__title', 'FLIGHT__value', 'HOTEL__title', 'HOTEL__value', 'RAIL__title', 'RAIL__value', 'CAR__title', 'CAR__value', 'BLACK_CAR__title', 'BLACK_CAR__value', 'GROUND_TRANSPORTATION__title', 'GROUND_TRANSPORTATION__unlock_liquid', 'FOOD_AND_INCIDENTALS__title', 'FOOD_AND_INCIDENTALS__unlock_liquid' ]; cy.verifySelectorsContainsAttributeQaid(adminQaAttribute, spendOverviewTableTitles); } static clickAnalyzeButtonOnSpendOverviewCard() { cy.allure().logStep( 'Verify admin user can click on Analyze button on Spend Overview card' ); cy.get(adminDashboardPageSelectors.analyzeButtonOnSpendOverviewCard) .should('be.visible') .click(); cy.get(adminDashboardPageSelectors.travelSpendAnalysisScreen).should('be.visible'); } static checkBookingDateDefaultState() { cy.allure().logStep('Verify YTD filter is set by default on Performance dashboard'); cy.get(adminDashboardPageSelectors.bookingTimeFilter) .should('be.visible') .contains('Year to date'); } static checkAdoptionCardPresence() { cy.allure().logStep('Verify Adoption card is displayed on Admin Dashboard'); cy.get(adminDashboardPageSelectors.adoptionCard).should('be.visible'); } static checkAdoptionCardItemsPresence() { cy.allure().logStep('Verify Adoption card items are displayed on Admin Dashboard'); const adoptionCardTableTitles = [ 'signUps__title', 'signUps__value', 'appInstallations__title', 'appInstallations__value', 'travelers__title', 'travelers__value', 'signUps__download-metrics', 'appInstallations__download-metrics' ]; cy.verifySelectorsContainsAttributeQaid(adminQaAttribute, adoptionCardTableTitles); } static checkSignUpsReportDownload() { cy.allure().logStep('Verify Sing Ups Report downloads'); cy.get(adminDashboardPageSelectors.signUpsDownloadButton).click(); cy.verifyDownload('.csv', { contains: true, timeout: 45000 }); cy.deleteDownloadsFolder(); } static checkAppInstallationsReportDownload() { cy.allure().logStep('Verify App Installations Report downloads'); cy.get(adminDashboardPageSelectors.appInstallationsDownloadButton).click(); cy.verifyDownload('.csv', { contains: true, timeout: 46000 }); cy.deleteDownloadsFolder(); } }