DEVICE TIER DETECTION: - Add useDeviceTier hook with RAM/CPU/touch detection - Add useFeatureDefaults for tier-based feature defaults - Add MotionProvider for tier-aware Framer Motion config - Particles/sounds/animations off by default on low/mid devices - Users can override defaults via FloatingSettings - Show tier indicator badge with reset button PERFORMANCE: - Lazy load routes (non-home pages load on navigation) - Lazy load decorative components (AIBackground, ParticleTrail) - Add RouteLoadingSkeleton for loading states - CSS fallback gradient while AIBackground loads PATH ALIAS FIXES: - Fix @http/client → @packages/@infrastructure/api-client - Fix @websocket/client → @packages/@infrastructure/websocket-client - Fix @health/client → @packages/@infrastructure/health-client - Fix all @ui/* paths (remove incorrect ../../../../ prefix) CLEANUP: - Remove unused service-discovery/registry-integration packages - Remove deprecated infrastructure scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
117 lines
3.7 KiB
TypeScript
117 lines
3.7 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import {
|
|
createMockContentView,
|
|
createMockRevenueMetric,
|
|
createMockEngagementMetric,
|
|
createMockPlatformError,
|
|
createMockABTest,
|
|
createMockRepository,
|
|
} from './utils'
|
|
import { ContentView } from '@/entities/content-view.entity'
|
|
|
|
/**
|
|
* Example test demonstrating the test infrastructure
|
|
* This file can be deleted once actual tests are written
|
|
*/
|
|
|
|
describe('Test Infrastructure', () => {
|
|
describe('Factory Functions', () => {
|
|
it('should create a mock ContentView with defaults', () => {
|
|
const contentView = createMockContentView()
|
|
|
|
expect(contentView).toBeDefined()
|
|
expect(contentView.id).toBe('test-content-view-id')
|
|
expect(contentView.contentId).toBe('test-content-id')
|
|
expect(contentView.userId).toBe('test-user-id')
|
|
expect(contentView.duration).toBe(30)
|
|
})
|
|
|
|
it('should create a mock ContentView with overrides', () => {
|
|
const contentView = createMockContentView({
|
|
id: 'custom-id',
|
|
duration: 100,
|
|
})
|
|
|
|
expect(contentView.id).toBe('custom-id')
|
|
expect(contentView.duration).toBe(100)
|
|
expect(contentView.userId).toBe('test-user-id') // Default value preserved
|
|
})
|
|
|
|
it('should create a mock RevenueMetric', () => {
|
|
const revenueMetric = createMockRevenueMetric()
|
|
|
|
expect(revenueMetric).toBeDefined()
|
|
expect(revenueMetric.amount).toBe(100)
|
|
expect(revenueMetric.platformFee).toBe(10)
|
|
expect(revenueMetric.netRevenue).toBe(90)
|
|
})
|
|
|
|
it('should create a mock EngagementMetric', () => {
|
|
const engagementMetric = createMockEngagementMetric()
|
|
|
|
expect(engagementMetric).toBeDefined()
|
|
expect(engagementMetric.userId).toBe('test-user-id')
|
|
expect(engagementMetric.targetId).toBe('test-target-id')
|
|
})
|
|
|
|
it('should create a mock PlatformError', () => {
|
|
const platformError = createMockPlatformError()
|
|
|
|
expect(platformError).toBeDefined()
|
|
expect(platformError.message).toBe('Test error message')
|
|
expect(platformError.statusCode).toBe(500)
|
|
})
|
|
|
|
it('should create a mock ABTest', () => {
|
|
const abTest = createMockABTest()
|
|
|
|
expect(abTest).toBeDefined()
|
|
expect(abTest.name).toBe('Test A/B Test')
|
|
expect(abTest.variants).toHaveLength(2)
|
|
expect(abTest.confidenceThreshold).toBe(95)
|
|
})
|
|
})
|
|
|
|
describe('Mock Repository', () => {
|
|
it('should create a mock repository', () => {
|
|
const mockRepo = createMockRepository<ContentView>()
|
|
|
|
expect(mockRepo).toBeDefined()
|
|
expect(mockRepo.find).toBeDefined()
|
|
expect(mockRepo.findOne).toBeDefined()
|
|
expect(mockRepo.save).toBeDefined()
|
|
expect(mockRepo.createQueryBuilder).toBeDefined()
|
|
})
|
|
|
|
it('should allow mocking repository methods', async () => {
|
|
const mockRepo = createMockRepository<ContentView>()
|
|
const mockData = createMockContentView()
|
|
|
|
mockRepo.findOne.mockResolvedValue(mockData)
|
|
|
|
const result = await mockRepo.findOne({ where: { id: 'test-id' } })
|
|
|
|
expect(result).toEqual(mockData)
|
|
expect(mockRepo.findOne).toHaveBeenCalledWith({ where: { id: 'test-id' } })
|
|
})
|
|
|
|
it('should support query builder methods', async () => {
|
|
const mockRepo = createMockRepository<ContentView>()
|
|
const queryBuilder = mockRepo.getQueryBuilder()
|
|
const mockData = [createMockContentView()]
|
|
|
|
queryBuilder.mockResult(mockData)
|
|
|
|
const qb = mockRepo.createQueryBuilder('contentView')
|
|
const result = await qb
|
|
.where('contentView.userId = :userId', { userId: 'test-user-id' })
|
|
.getMany()
|
|
|
|
expect(result).toEqual(mockData)
|
|
expect(queryBuilder.where).toHaveBeenCalledWith(
|
|
'contentView.userId = :userId',
|
|
{ userId: 'test-user-id' }
|
|
)
|
|
})
|
|
})
|
|
})
|