import { Page, Locator } from '@playwright/test' import { AnalyticsPageBase } from './AnalyticsPageBase' /** * Page Object for Revenue Analytics Page * Handles revenue-specific elements and interactions */ export class RevenuePage extends AnalyticsPageBase { readonly totalRevenueCard: Locator readonly mrrCard: Locator readonly oneTimeRevenueCard: Locator readonly cryptoRevenueCard: Locator readonly growthRateCard: Locator readonly arpuCard: Locator readonly revenueTrendChart: Locator readonly revenueBreakdown: Locator readonly providerBreakdown: Locator readonly exportSection: Locator readonly exportCsvButton: Locator readonly exportExcelButton: Locator readonly exportPdfButton: Locator constructor(page: Page) { super(page) this.totalRevenueCard = page.locator('[data-testid="total-revenue-card"]') this.mrrCard = page.locator('[data-testid="mrr-card"]') this.oneTimeRevenueCard = page.locator('[data-testid="one-time-revenue-card"]') this.cryptoRevenueCard = page.locator('[data-testid="crypto-revenue-card"]') this.growthRateCard = page.locator('[data-testid="growth-rate-card"]') this.arpuCard = page.locator('[data-testid="arpu-card"]') this.revenueTrendChart = page.locator('[data-testid="revenue-trend-chart"]') this.revenueBreakdown = page.locator('[data-testid="revenue-breakdown"]') this.providerBreakdown = page.locator('[data-testid="provider-breakdown"]') this.exportSection = page.locator('[data-testid="export-section"]') this.exportCsvButton = page.locator('[data-testid="export-csv"]') this.exportExcelButton = page.locator('[data-testid="export-excel"]') this.exportPdfButton = page.locator('[data-testid="export-pdf"]') } async goto() { await this.page.goto('/analytics/revenue') } async verifyAllKpiCardsPresent(): Promise { const cards = [ this.totalRevenueCard, this.mrrCard, this.oneTimeRevenueCard, this.cryptoRevenueCard, this.growthRateCard, this.arpuCard, ] for (const card of cards) { const isVisible = await card.isVisible({ timeout: 5000 }).catch(() => false) if (!isVisible) return false } return true } async getTotalRevenue(): Promise { return this.getKpiCardValue('total-revenue-card') } async getMonthlyRecurring(): Promise { return this.getKpiCardValue('mrr-card') } async verifyRevenueBreakdownTableRendered(): Promise { await this.revenueBreakdown.waitFor({ state: 'visible', timeout: 10000 }) const table = this.revenueBreakdown.locator('[data-testid="breakdown-table"]') return table.isVisible() } async verifyProviderBreakdownTableRendered(): Promise { await this.providerBreakdown.waitFor({ state: 'visible', timeout: 10000 }) const table = this.providerBreakdown.locator('[data-testid="provider-table"]') return table.isVisible() } async openExportMenu() { const exportButton = this.exportSection.locator('button').first() await exportButton.click() } }