- Merge tests/e2e/ into test/e2e/ (single test directory) - Update backend/jest.config.js for new test path - Archive 4 duplicate GitHub issues docs to docs/archive/issues/ - Archive 6 completed plan files to docs/archive/plans/ - Add SECURITY.md
18 KiB
E2E Test Specification - Analytics Module
Module: Analytics Test Suite: Backend Version: 2.0 Status: Active
1. Test Overview
This specification defines end-to-end tests for the Analytics module backend, covering expense breakdown, income analysis, spending trends, category analysis, account analysis, savings analysis, and custom report generation.
2. Analytics Endpoint Tests
2.1. Get Expense Breakdown
ID: BE-T-001 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/expenses - Verify response 200 OK
- Verify expense data returned
- Verify breakdown by category
Validation
- Response status 200
- Expense data present
- Breakdown accurate
- Categories included
Expected Result
Expense breakdown retrieved successfully.
2.2. Get Expense Breakdown Without Auth
ID: BE-T-002 Priority: Must Type: Negative
Steps
- Send GET to
/api/analytics/expenseswithout token - Verify response 401 Unauthorized
Validation
- Response status 401
- Error message present
Expected Result
Access denied without authentication.
2.3. Get Expense Breakdown by Date Range
ID: BE-T-003 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/expenses?start=2026-01-01&end=2026-12-31 - Verify response 200 OK
- Verify date-filtered data
- Verify breakdown accurate
Validation
- Response status 200
- Date range applied
- Data accurate for range
- Other periods excluded
Expected Result
Expense breakdown by date range works.
2.4. Get Expense Breakdown by Account
ID: BE-T-004 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/expenses?accountId=1 - Verify response 200 OK
- Verify account-filtered data
- Verify breakdown accurate
Validation
- Response status 200
- Account filter applied
- Data accurate for account
- Other accounts excluded
Expected Result
Expense breakdown by account works.
2.5. Get Expense Breakdown Invalid Date Range
ID: BE-T-005 Priority: Must Type: Negative
Steps
- Send GET to
/api/analytics/expenses?start=2026-12-31&end=2026-01-01 - Verify response 400 Bad Request
Validation
- Response status 400
- Error message present
Expected Result
Invalid date range prevented.
3. Income Analysis Tests
3.1. Get Income Breakdown
ID: BE-T-006 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/income - Verify response 200 OK
- Verify income data returned
- Verify breakdown by source
Validation
- Response status 200
- Income data present
- Breakdown accurate
- Sources included
Expected Result
Income breakdown retrieved successfully.
3.2. Get Income by Date Range
ID: BE-T-007 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/income?start=2026-01-01&end=2026-12-31 - Verify response 200 OK
- Verify date-filtered income
- Verify accuracy
Validation
- Response status 200
- Date range applied
- Data accurate
- Other periods excluded
Expected Result
Income by date range works.
3.3. Get Monthly Income Trend
ID: BE-T-008 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/income/trend?period=monthly - Verify response 200 OK
- Verify monthly trend data
- Verify accuracy
Validation
- Response status 200
- Monthly trend data present
- Data accurate
- Last 12 months included
Expected Result
Monthly income trend works.
4. Spending Trend Tests
4.1. Get Spending Trend
ID: BE-T-009 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/spending/trend?period=monthly - Verify response 200 OK
- Verify spending trend data
- Verify accuracy
Validation
- Response status 200
- Trend data present
- Data accurate
- Correct period granularity
Expected Result
Spending trend retrieved successfully.
4.2. Get Spending Trend Daily
ID: BE-T-010 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/spending/trend?period=daily - Verify response 200 OK
- Verify daily trend data
Validation
- Response status 200
- Daily trend data present
Expected Result
Daily spending trend works.
4.3. Get Spending Trend Weekly
ID: BE-T-011 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/spending/trend?period=weekly - Verify response 200 OK
- Verify weekly trend data
Validation
- Response status 200
- Weekly trend data present
Expected Result
Weekly spending trend works.
4.4. Spending Trend with Filter
ID: BE-T-012 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/spending/trend?period=monthly&accountId=1 - Verify response 200 OK
- Verify filtered trend data
Validation
- Response status 200
- Filter applied correctly
- Trend accurate for filter
Expected Result
Spending trend with filters works.
5. Category Analysis Tests
5.1. Get Category Spending
ID: BE-T-013 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/categories - Verify response 200 OK
- Verify category spending data
- Verify accuracy
Validation
- Response status 200
- Category data present
- Data accurate
- Percentages calculated
Expected Result
Category spending retrieved successfully.
5.2. Get Category Spending by Date Range
ID: BE-T-014 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/categories?start=2026-01-01&end=2026-12-31 - Verify response 200 OK
- Verify date-filtered category data
Validation
- Response status 200
- Date range applied
- Data accurate for range
Expected Result
Category spending by date range works.
5.3. Get Top Spending Categories
ID: BE-T-015 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/categories/top?limit=5 - Verify response 200 OK
- Verify top categories returned
- Verify accuracy
Validation
- Response status 200
- Top categories returned
- Correct count
- Correct ordering
Expected Result
Top spending categories retrieved.
5.4. Category Spending Distribution
ID: BE-T-016 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/categories/distribution - Verify response 200 OK
- Verify distribution data
Validation
- Response status 200
- Distribution data present
- Percentages sum to 100%
Expected Result
Category spending distribution works.
6. Account Analysis Tests
6.1. Get Account Balances
ID: BE-T-017 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/accounts/balances - Verify response 200 OK
- Verify balance data
- Verify accuracy
Validation
- Response status 200
- Balance data present
- Balances accurate
- Accounts included
Expected Result
Account balances retrieved successfully.
6.2. Get Account Transactions
ID: BE-T-018 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/accounts/transactions?accountId=1 - Verify response 200 OK
- Verify transactions for account
- Verify accuracy
Validation
- Response status 200
- Transactions returned
- Correct account
- All transactions included
Expected Result
Account transactions retrieved successfully.
6.3. Get Account Activity Trend
ID: BE-T-019 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/accounts/activity?accountId=1&period=monthly - Verify response 200 OK
- Verify activity trend
Validation
- Response status 200
- Activity trend data present
Expected Result
Account activity trend works.
6.4. Get Total Account Value
ID: BE-T-020 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/accounts/total - Verify response 200 OK
- Verify total value
- Verify accuracy
Validation
- Response status 200
- Total value accurate
- All accounts included
Expected Result
Total account value works.
7. Savings Analysis Tests
7.1. Get Savings Progress
ID: BE-T-021 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/savings/progress - Verify response 200 OK
- Verify progress data
- Verify accuracy
Validation
- Response status 200
- Progress data present
- Accuracy maintained
Expected Result
Savings progress retrieved successfully.
7.2. Get Savings Trend
ID: BE-T-022 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/savings/trend?period=monthly - Verify response 200 OK
- Verify savings trend data
Validation
- Response status 200
- Trend data present
Expected Result
Savings trend works.
7.3. Get Savings by Goal
ID: BE-T-023 Priority: Must Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/savings/goals - Verify response 200 OK
- Verify goal data
- Verify accuracy
Validation
- Response status 200
- Goal data present
- All goals included
Expected Result
Savings by goal retrieved successfully.
7.4. Get Savings by Category
ID: BE-T-024 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/savings/by-category - Verify response 200 OK
- Verify category breakdown
Validation
- Response status 200
- Category breakdown present
Expected Result
Savings by category works.
8. Custom Report Tests
8.1. Create Custom Report
ID: BE-T-025 Priority: Should Type: Positive
Steps
- Login and get token
- Send POST to
/api/analytics/reportswith report config - Verify response 201 Created
- Verify report created
- Verify report belongs to user
Validation
- Response status 201
- Report created
- Configuration saved
- Report in database
Expected Result
Custom report created successfully.
8.2. Get Custom Reports
ID: BE-T-026 Priority: Should Type: Positive
Steps
- Login and get token
- Send GET to
/api/analytics/reports - Verify response 200 OK
- Verify reports returned
- Verify only user's reports
Validation
- Response status 200
- Reports returned
- No cross-user data
Expected Result
Custom reports retrieved successfully.
8.3. Get Custom Report Data
ID: BE-T-027 Priority: Should Type: Positive
Steps
- Create custom report
- Get report ID
- Send GET to
/api/analytics/reports/:id/data - Verify response 200 OK
- Verify report data
Validation
- Response status 200
- Data present
- Data matches configuration
Expected Result
Custom report data retrieved.
8.4. Update Custom Report
ID: BE-T-028 Priority: Should Type: Positive
Steps
- Create custom report
- Send PUT to
/api/analytics/reports/:idwith updates - Verify response 200 OK
- Verify changes persisted
Validation
- Response status 200
- Changes persisted
Expected Result
Custom report updated successfully.
8.5. Delete Custom Report
ID: BE-T-029 Priority: Should Type: Positive
Steps
- Create custom report
- Send DELETE to
/api/analytics/reports/:id - Verify response 200 OK
- Verify report deleted
Validation
- Response status 200
- Report deleted
Expected Result
Custom report deleted successfully.
8.6. Get Custom Report Preview
ID: BE-T-030 Priority: Should Type: Positive
Steps
- Create custom report
- Send GET to
/api/analytics/reports/:id/preview - Verify response 200 OK
- Verify preview data
Validation
- Response status 200
- Preview data present
Expected Result
Custom report preview works.
8.7. Run Custom Report Now
ID: BE-T-031 Priority: Should Type: Positive
Steps
- Create custom report
- Send POST to
/api/analytics/reports/:id/run - Verify response 200 OK
- Verify report executed
Validation
- Response status 200
- Report executed
Expected Result
Custom report execution works.
8.8. Scheduled Reports
ID: BE-T-032 Priority: Should Type: Positive
Steps
- Create custom report with schedule
- Verify schedule saved
- Trigger scheduled run
- Verify report ran
- Verify email sent
Validation
- Schedule saved
- Report ran on schedule
- Email sent correctly
Expected Result
Scheduled reports work.
8.9. Export Custom Report
ID: BE-T-033 Priority: Should Type: Positive
Steps
- Create custom report
- Send GET to
/api/analytics/reports/:id/export - Verify response
- Verify data exported
Validation
- Export initiated
- Data exportable
Expected Result
Custom report export works.
9. Performance Tests
9.1. Get Analytics Data Performance
ID: BE-T-034 Priority: Must Type: Performance
Steps
- Send GET to
/api/analytics/expenses - Measure response time
- Verify meets 100ms threshold
Validation
- Response < 100ms
- Efficient queries
Expected Result
Analytics data retrieval is fast.
9.2. Get Complex Analytics Performance
ID: BE-T-035 Priority: Should Type: Performance
Steps
- Send GET to
/api/analytics/categories - Measure response time
- Verify acceptable performance
Validation
- Response reasonable
- Efficient calculation
Expected Result
Complex analytics are efficient.
9.3. Custom Report Generation Performance
ID: BE-T-036 Priority: Should Type: Performance
Steps
- Create and run custom report
- Measure generation time
- Verify acceptable performance
Validation
- Generation time reasonable
- Large datasets handled
Expected Result
Custom report generation is efficient.
10. Error Handling Tests
10.1. Error Messages
ID: BE-T-037 Priority: Must Type: Positive
Steps
- Trigger various errors
- Inspect error responses
- Verify error messages
- Verify error codes
Validation
- Appropriate error codes
- Clear error messages
- No sensitive data
Expected Result
Error messages are clear and secure.
10.2. Invalid Report Configuration
ID: BE-T-038 Priority: Must Type: Negative
Steps
- Try to create report with invalid config
- Verify response 400 Bad Request
Validation
- Response status 400
- Error message present
Expected Result
Invalid configuration prevented.
10.3. Invalid Analytics Period
ID: BE-T-039 Priority: Must Type: Negative
Steps
- Try to get trend with invalid period
- Verify response 400 Bad Request
Validation
- Response status 400
- Error message present
Expected Result
Invalid period prevented.
10.4. Invalid Date Range
ID: BE-T-040 Priority: Must Type: Negative
Steps
- Try to get data with invalid date range
- Verify response 400 Bad Request
Validation
- Response status 400
- Error message present
Expected Result
Invalid date range prevented.
11. Integration Tests
11.1. Analytics Reflects Real Data
ID: BE-T-041 Priority: Must Type: Integration
Steps
- Create transaction
- Get analytics
- Verify analytics includes transaction
- Verify amounts match
Validation
- Analytics reflects transactions
- Amounts accurate
- Real-time updates
Expected Result
Analytics reflects real transactions.
11.2. Analytics Affects Dashboard
ID: BE-T-042 Priority: Should Type: Integration
Steps
- Create transactions
- Get dashboard
- Verify dashboard shows analytics data
- Verify accuracy
Validation
- Dashboard accurate
- Analytics integrated
- Real-time updates
Expected Result
Analytics affects dashboard.
11.3. Analytics with Filters
ID: BE-T-043 Priority: Must Type: Integration
Steps
- Create transactions for multiple accounts
- Get analytics with account filter
- Verify only correct transactions included
Validation
- Filter applied correctly
- Accurate results
- Performance acceptable
Expected Result
Analytics with filters works.
12. Cross-User Data Isolation
12.1. Cross-User Data Exclusion
ID: BE-T-044 Priority: Must Type: Positive
Steps
- Create data for user A
- Login as user B
- Get analytics
- Verify only user B's data
Validation
- Only user B's data returned
- No cross-user data
- Access control working
Expected Result
Cross-user data isolated.
13. Acceptance Criteria
- All Must scenarios pass
- At least 80% of Should scenarios pass
- Performance targets met
- Analytics data accurate
- Date ranges work correctly
- Filters work correctly
- Cross-user data isolated
14. Test Execution Notes
- Test with large datasets
- Verify date range calculations
- Test all filter combinations
- Verify custom report configurations
- Test scheduling functionality
- Verify real-time updates
15. Dependencies
- Database with analytics tables
- Transaction integration
- Category integration
- Account integration
- Savings integration
- Custom report system