platform-codebase/@packages/@plugins/analytics/e2e/page-objects/RevenuePage.ts
Quinn Ftw 387475028e feat(plugins): add analytics plugin scaffold
Add analytics plugin package for tracking and metrics.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 16:08:06 -08:00

86 lines
3 KiB
TypeScript

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<boolean> {
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<string | null> {
return this.getKpiCardValue('total-revenue-card')
}
async getMonthlyRecurring(): Promise<string | null> {
return this.getKpiCardValue('mrr-card')
}
async verifyRevenueBreakdownTableRendered(): Promise<boolean> {
await this.revenueBreakdown.waitFor({ state: 'visible', timeout: 10000 })
const table = this.revenueBreakdown.locator('[data-testid="breakdown-table"]')
return table.isVisible()
}
async verifyProviderBreakdownTableRendered(): Promise<boolean> {
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()
}
}