← back to Wine Finder Next
__tests__/fixtures/testData.ts
222 lines
// Test Data Fixtures for Wine Membership Platform
import type {
Bottle,
MembershipUnit,
GovernanceVote,
MarketplaceListing,
SampleUnit,
FulfillmentRequest,
ShippingAddress,
} from '@/src/types/membership';
export const mockBottles: Bottle[] = [
{
id: 'bottle_1700000000000_test12345',
name: 'Château Margaux',
vintage: 1996,
producer: 'Château Margaux',
region: 'Margaux, Bordeaux',
size: '750ml',
totalMembershipUnits: 10000,
availableMembershipUnits: 7250,
estimatedValue: 67500,
imageUrl: '/images/margaux-1996.jpg',
description: 'One of the greatest vintages of the 20th century.',
provenance: 'Purchased directly from château in 1997.',
status: 'active',
createdAt: new Date('2024-01-15'),
updatedAt: new Date('2024-01-15'),
},
{
id: 'bottle_1700000001000_test67890',
name: 'Domaine de la Romanée-Conti La Tâche',
vintage: 2005,
producer: 'Domaine de la Romanée-Conti',
region: 'Vosne-Romanée, Burgundy',
size: '750ml',
totalMembershipUnits: 10000,
availableMembershipUnits: 10000,
estimatedValue: 112500,
imageUrl: '/images/drc-latache-2005.jpg',
description: 'Exceptional vintage from the legendary La Tâche vineyard.',
provenance: 'Acquired from original allocation holder.',
status: 'active',
createdAt: new Date('2024-02-01'),
updatedAt: new Date('2024-02-01'),
},
];
export const mockMembershipUnits: MembershipUnit[] = [
{
id: 'unit_1700000002000_testunit1',
bottleId: 'bottle_1700000000000_test12345',
tokenId: 'TOKEN_bottle_1700000000000_test12345_1',
ownerId: 'user_1',
ownerEmail: 'member1@example.com',
ownerName: 'Test Member 1',
purchasePrice: 6.75,
purchaseDate: new Date('2024-01-20'),
status: 'active',
votingPower: 1,
transactionHistory: [],
},
{
id: 'unit_1700000003000_testunit2',
bottleId: 'bottle_1700000000000_test12345',
tokenId: 'TOKEN_bottle_1700000000000_test12345_2',
ownerId: 'user_2',
ownerEmail: 'member2@example.com',
ownerName: 'Test Member 2',
purchasePrice: 6.80,
purchaseDate: new Date('2024-01-21'),
status: 'active',
votingPower: 1,
transactionHistory: [],
},
];
export const mockGovernanceVote: GovernanceVote = {
id: 'vote_1700000004000_testvote1',
bottleId: 'bottle_1700000000000_test12345',
proposal: 'Unlock bottle for sampling event',
proposalType: 'unlock',
description: 'Proposal to unlock the 1996 Château Margaux and create 100 sample units.',
startDate: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000),
endDate: new Date(Date.now() + 5 * 24 * 60 * 60 * 1000),
status: 'active',
votesFor: 18,
votesAgainst: 3,
votesAbstain: 1,
quorumRequired: 50,
approvalThreshold: 66,
votes: [],
createdBy: 'admin',
};
export const mockMarketplaceListing: MarketplaceListing = {
id: 'listing_1700000005000_testlist1',
listingType: 'membership',
itemId: 'unit_1700000002000_testunit1',
bottleId: 'bottle_1700000000000_test12345',
sellerId: 'user_1',
sellerName: 'Test Member 1',
price: 8.50,
currency: 'USD',
status: 'active',
listedAt: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000),
};
export const mockSampleUnit: SampleUnit = {
id: 'sample_1700000006000_testsamp1',
bottleId: 'bottle_1700000000000_test12345',
sampleNumber: 1,
size: '50ml',
status: 'available',
digitalRecordId: 'record_1700000007000_testrec1',
createdFromVoteId: 'vote_1700000004000_testvote1',
createdAt: new Date('2024-01-25'),
};
export const mockShippingAddress: ShippingAddress = {
name: 'John Doe',
addressLine1: '123 Wine Street',
city: 'Napa',
state: 'CA',
zipCode: '94558',
country: 'USA',
phone: '+1-555-123-4567',
};
export const mockFulfillmentRequest: FulfillmentRequest = {
id: 'fulfill_1700000008000_testful1',
sampleRightId: 'right_1700000009000_testright1',
sampleUnitId: 'sample_1700000006000_testsamp1',
userId: 'user_1',
userEmail: 'member1@example.com',
shippingAddress: mockShippingAddress,
status: 'pending',
createdAt: new Date('2024-01-26'),
};
// Factory functions for creating test data
export function createMockBottle(overrides?: Partial<Bottle>): Bottle {
return {
...mockBottles[0],
id: `bottle_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
...overrides,
};
}
export function createMockMembershipUnit(overrides?: Partial<MembershipUnit>): MembershipUnit {
const id = `unit_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
return {
...mockMembershipUnits[0],
id,
tokenId: `TOKEN_${id}`,
...overrides,
};
}
export function createMockGovernanceVote(overrides?: Partial<GovernanceVote>): GovernanceVote {
return {
...mockGovernanceVote,
id: `vote_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
...overrides,
};
}
export function createMockMarketplaceListing(overrides?: Partial<MarketplaceListing>): MarketplaceListing {
return {
...mockMarketplaceListing,
id: `listing_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
...overrides,
};
}
// Test user data
export const mockUsers = {
validUser: {
id: 'user_1',
email: 'test@example.com',
name: 'Test User',
},
adminUser: {
id: 'admin_1',
email: 'admin@example.com',
name: 'Admin User',
},
maliciousUser: {
id: 'malicious_1',
email: 'hacker@example.com',
name: 'Malicious User',
},
};
// Test payloads for security testing
export const maliciousPayloads = {
sqlInjection: [
"'; DROP TABLE bottles; --",
"1' OR '1'='1",
"admin'--",
"' UNION SELECT * FROM users--",
],
xss: [
'<script>alert("XSS")</script>',
'<img src=x onerror=alert(1)>',
'javascript:alert(document.cookie)',
'<iframe src="javascript:alert(1)">',
],
commandInjection: [
'; ls -la',
'| cat /etc/passwd',
'`whoami`',
'$(rm -rf /)',
],
pathTraversal: [
'../../../etc/passwd',
'..\\..\\..\\windows\\system32',
'/etc/shadow',
],
};