mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-08 00:26:12 +01:00
- Implement Priority 1 E2E test coverage for critical user journeys: * Group lifecycle management (creation, navigation, editing) * Basic expense management (create, view, edit, delete) * Balance calculation and verification * Multiple expense scenarios and split calculations - Add comprehensive reliability infrastructure: * ReliabilityUtils class with retry mechanisms and enhanced navigation * Page Object Model (POM) architecture for maintainable tests * Test data management utilities with unique identifiers * Enhanced Playwright configuration with increased timeouts and retries - Fix all flaky test issues: * Add required test IDs to UI components for reliable element targeting * Implement multiple fallback strategies for element selection * Enhanced tab navigation with URL verification and retry logic * Proper wait strategies for network idle states and dynamic content - Test results: 39/39 tests passing (100% success rate) across all browsers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
export class CalculationUtils {
|
|
/**
|
|
* Calculate expected balance for a participant
|
|
*/
|
|
static calculateExpectedBalance(
|
|
participantExpenses: number[],
|
|
participantShares: number[]
|
|
): number {
|
|
const totalPaid = participantExpenses.reduce((sum, expense) => sum + expense, 0)
|
|
const totalOwed = participantShares.reduce((sum, share) => sum + share, 0)
|
|
|
|
return totalPaid - totalOwed
|
|
}
|
|
|
|
/**
|
|
* Calculate even split amount
|
|
*/
|
|
static calculateEvenSplit(totalAmount: number, participantCount: number): number {
|
|
return totalAmount / participantCount
|
|
}
|
|
|
|
/**
|
|
* Calculate split by percentage
|
|
*/
|
|
static calculatePercentageSplit(totalAmount: number, percentage: number): number {
|
|
return (totalAmount * percentage) / 100
|
|
}
|
|
|
|
/**
|
|
* Calculate split by shares
|
|
*/
|
|
static calculateShareSplit(totalAmount: number, shares: number, totalShares: number): number {
|
|
return (totalAmount * shares) / totalShares
|
|
}
|
|
|
|
/**
|
|
* Format currency amount to 2 decimal places
|
|
*/
|
|
static formatCurrency(amount: number, currency: string = 'USD'): string {
|
|
return `${currency}${amount.toFixed(2)}`
|
|
}
|
|
|
|
/**
|
|
* Parse currency string to number
|
|
*/
|
|
static parseCurrency(currencyString: string): number {
|
|
return parseFloat(currencyString.replace(/[^0-9.-]+/g, ''))
|
|
}
|
|
|
|
/**
|
|
* Validate that balances sum to zero (group balance check)
|
|
*/
|
|
static validateGroupBalance(balances: number[]): boolean {
|
|
const sum = balances.reduce((total, balance) => total + balance, 0)
|
|
return Math.abs(sum) < 0.01 // Allow for small rounding errors
|
|
}
|
|
} |