// Test fixtures for MCP Sigmund
// This file provides consistent test data to ensure reliable test execution
export const TEST_FIXTURES = {
// Test provider data
providers: [
{
id: 'test-provider-1',
name: 'Test Bank',
environment: 'sandbox',
status: 'active',
created_at: '2024-01-01T00:00:00Z',
updated_at: '2024-01-01T00:00:00Z',
},
{
id: 'test-provider-2',
name: 'Test Credit Union',
environment: 'sandbox',
status: 'active',
created_at: '2024-01-01T00:00:00Z',
updated_at: '2024-01-01T00:00:00Z',
},
],
// Test user data
users: [
{
id: 'test-user-1',
provider_id: 'test-provider-1',
external_id: 'ext-user-1',
email: 'test@example.com',
status: 'active',
created_at: '2024-01-01T00:00:00Z',
updated_at: '2024-01-01T00:00:00Z',
},
],
// Test account data
accounts: [
{
id: 'test-account-1',
user_id: 'test-user-1',
provider_id: 'test-provider-1',
external_id: 'ext-account-1',
account_type: 'checking',
display_name: 'Test Checking Account',
currency: 'EUR',
current_balance: 1500.0,
available_balance: 1500.0,
status: 'active',
created_at: '2024-01-01T00:00:00Z',
updated_at: '2024-01-01T00:00:00Z',
last_updated: '2024-01-01T00:00:00Z',
},
{
id: 'test-account-2',
user_id: 'test-user-1',
provider_id: 'test-provider-2',
external_id: 'ext-account-2',
account_type: 'savings',
display_name: 'Test Savings Account',
currency: 'EUR',
current_balance: 5000.0,
available_balance: 5000.0,
status: 'active',
created_at: '2024-01-01T00:00:00Z',
updated_at: '2024-01-01T00:00:00Z',
last_updated: '2024-01-01T00:00:00Z',
},
],
// Test transaction data
transactions: [
{
id: 'test-transaction-1',
account_id: 'test-account-1',
user_id: 'test-user-1',
provider_id: 'test-provider-1',
external_id: 'ext-transaction-1',
amount: -25.5,
currency: 'EUR',
date: '2024-01-15T10:30:00Z',
description: 'Coffee Shop Purchase',
category: 'Food & Dining',
status: 'completed',
created_at: '2024-01-15T10:30:00Z',
updated_at: '2024-01-15T10:30:00Z',
},
{
id: 'test-transaction-2',
account_id: 'test-account-1',
user_id: 'test-user-1',
provider_id: 'test-provider-1',
external_id: 'ext-transaction-2',
amount: 3000.0,
currency: 'EUR',
date: '2024-01-01T09:00:00Z',
description: 'Salary Payment',
category: 'Income',
status: 'completed',
created_at: '2024-01-01T09:00:00Z',
updated_at: '2024-01-01T09:00:00Z',
},
{
id: 'test-transaction-3',
account_id: 'test-account-2',
user_id: 'test-user-1',
provider_id: 'test-provider-2',
external_id: 'ext-transaction-3',
amount: -100.0,
currency: 'EUR',
date: '2024-01-10T14:20:00Z',
description: 'Grocery Store',
category: 'Food & Dining',
status: 'completed',
created_at: '2024-01-10T14:20:00Z',
updated_at: '2024-01-10T14:20:00Z',
},
],
// Test balance data
balances: [
{
id: 'test-balance-1',
account_id: 'test-account-1',
user_id: 'test-user-1',
provider_id: 'test-provider-1',
balance_type: 'current',
amount: 1500.0,
currency: 'EUR',
snapshot_date: '2024-01-15T00:00:00Z',
},
{
id: 'test-balance-2',
account_id: 'test-account-2',
user_id: 'test-user-1',
provider_id: 'test-provider-2',
balance_type: 'current',
amount: 5000.0,
currency: 'EUR',
snapshot_date: '2024-01-15T00:00:00Z',
},
],
};
// Helper functions for test data
export const TestHelpers = {
// Get a random transaction for testing
getRandomTransaction: () => {
const transactions = TEST_FIXTURES.transactions;
return transactions[Math.floor(Math.random() * transactions.length)];
},
// Get transactions by category
getTransactionsByCategory: (category: string) => {
return TEST_FIXTURES.transactions.filter(t => t.category === category);
},
// Get transactions by provider
getTransactionsByProvider: (providerId: string) => {
return TEST_FIXTURES.transactions.filter(t => t.provider_id === providerId);
},
// Get accounts by provider
getAccountsByProvider: (providerId: string) => {
return TEST_FIXTURES.accounts.filter(a => a.provider_id === providerId);
},
// Calculate expected totals
calculateExpectedTotals: () => {
const transactions = TEST_FIXTURES.transactions;
const totalIncome = transactions
.filter(t => t.amount > 0)
.reduce((sum, t) => sum + t.amount, 0);
const totalExpenses = transactions
.filter(t => t.amount < 0)
.reduce((sum, t) => sum + Math.abs(t.amount), 0);
const netFlow = totalIncome - totalExpenses;
return {
totalIncome,
totalExpenses,
netFlow,
transactionCount: transactions.length,
};
},
};
// Test data validation helpers
export const TestValidators = {
// Validate transaction structure
validateTransaction: (transaction: any) => {
const requiredFields = [
'id',
'account_id',
'user_id',
'provider_id',
'amount',
'date',
'status',
];
return requiredFields.every(field => Object.prototype.hasOwnProperty.call(transaction, field));
},
// Validate account structure
validateAccount: (account: any) => {
const requiredFields = [
'id',
'user_id',
'provider_id',
'account_type',
'status',
];
return requiredFields.every(field => Object.prototype.hasOwnProperty.call(account, field));
},
// Validate provider structure
validateProvider: (provider: any) => {
const requiredFields = ['id', 'name', 'status'];
return requiredFields.every(field => Object.prototype.hasOwnProperty.call(provider, field));
},
};