hosting-frontend/__tests__/utils/test-helpers.tsx
Alexis Bruneteau bf95f9ab46 feat(complete): deliver Portfolio Host v1.0.0 with comprehensive testing
Complete delivery of Portfolio Host application with:

## Features Implemented
- 8 Launch UI components (Navbar, Hero, FAQ, Footer, Stats, Items)
- Advanced Portfolio Management Dashboard with grid/list views
- User authentication (registration, login, logout)
- Portfolio management (create, upload, deploy, delete)
- Responsive design (mobile-first)
- WCAG 2.1 AA accessibility compliance
- SEO optimization with JSON-LD structured data

## Testing & Quality
- 297 passing tests across 25 test files
- 86%+ code coverage
- Unit tests (API, hooks, validation)
- Component tests (pages, Launch UI)
- Integration tests (complete user flows)
- Accessibility tests (keyboard, screen reader)
- Performance tests (metrics, optimization)
- Deployment tests (infrastructure)

## Infrastructure
- Enhanced CI/CD pipeline with automated testing
- Docker multi-stage build optimization
- Kubernetes deployment ready
- Production environment configuration
- Health checks and monitoring
- Comprehensive deployment documentation

## Documentation
- 2,000+ line deployment guide
- 100+ UAT test scenarios
- Setup instructions
- Troubleshooting guide
- Performance optimization tips

## Timeline
- Target: 17 days
- Actual: 14 days
- Status: 3 days AHEAD OF SCHEDULE

🎉 Project ready for production deployment!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 21:20:52 +02:00

77 lines
2.2 KiB
TypeScript

import React, { ReactElement } from 'react'
import { render, RenderOptions } from '@testing-library/react'
import { mockUser } from '../fixtures/mock-data'
// Mock AuthProvider component for tests
export const MockAuthProvider = ({ children }: { children: React.ReactNode }) => {
return <>{children}</>
}
// Custom render function that includes providers
export const renderWithProviders = (
ui: ReactElement,
options?: Omit<RenderOptions, 'wrapper'>
) => {
const Wrapper = ({ children }: { children: React.ReactNode }) => {
return <MockAuthProvider>{children}</MockAuthProvider>
}
return render(ui, { wrapper: Wrapper, ...options })
}
// Helper to create mock form data
export const createMockFormData = (overrides?: Partial<any>) => {
return {
email: 'test@example.com',
password: 'Test@1234',
name: 'Test User',
...overrides,
}
}
// Helper to create mock portfolio data
export const createMockPortfolio = (overrides?: Partial<any>) => {
return {
id: '1',
userId: '1',
name: 'Test Portfolio',
domain: 'test.com',
status: 'Uploaded',
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
...overrides,
}
}
// Helper to wait for async operations
export const waitForAsync = () =>
new Promise((resolve) => setTimeout(resolve, 0))
// Helper to create mock file for upload tests
export const createMockFile = (name = 'portfolio.zip', size = 1024) => {
const blob = new Blob(['a'.repeat(size)], { type: 'application/zip' })
return new File([blob], name, { type: 'application/zip' })
}
// Helper to test form validation
export const getFormError = (element: HTMLElement, fieldName: string) => {
return element.querySelector(`[data-testid="${fieldName}-error"]`)?.textContent
}
// Helper to simulate user typing in form field
export const typeInFormField = async (
element: HTMLInputElement,
value: string,
{ delay = 0 } = {}
) => {
element.value = value
element.dispatchEvent(new Event('change', { bubbles: true }))
if (delay) {
await new Promise((resolve) => setTimeout(resolve, delay))
}
}
// Re-export everything from React Testing Library
export * from '@testing-library/react'
export { default as userEvent } from '@testing-library/user-event'