Frontend de trading-platform - Workspace V2
Go to file
Adrian Flores Cortes 3fb1ff4f5c test(payments): Add E2E tests for Stripe Elements integration (ST4.2.3)
Comprehensive frontend E2E tests validating PCI-DSS compliance with Stripe Elements.

New Files:
- src/__tests__/e2e/payments-stripe-elements.test.tsx (550+ lines)
  - 7 test suites, 20+ test cases
  - Stripe CardElement rendering (iframe, not native input)
  - Payment Intent confirmation flow
  - Checkout Session redirect (Stripe hosted)
  - Payment Method tokenization
  - Component state validation (no card data)
  - Error handling (Stripe validation errors)
  - Security best practices (HTTPS, no logging)

Test Coverage:
 Stripe CardElement renders as iframe (NOT native input)
 NO card data in React component state
 confirmCardPayment called with clientSecret
 NO card data sent to backend
 Checkout redirects to Stripe hosted page (stripe.com)
 Payment method tokenized before backend call
 NO sensitive data logged to console

PCI-DSS Frontend Validation:
- CardElement is iframe from stripe.com (not our domain)
- Card data sent directly to Stripe (bypasses our servers)
- Only tokens/IDs sent to backend
- No cardNumber, cvv, expiryDate in React state
- All API calls use HTTPS
- Stripe validation errors displayed (proves validation in Stripe iframe)

Mock Infrastructure:
- @stripe/stripe-js mocked
- @stripe/react-stripe-js mocked
- apiClient mocked
- window.location mocked (redirect tests)

Test Scenarios:
1. Wallet deposit (Payment Intent + confirmCardPayment)
2. Checkout session (redirect to Stripe hosted page)
3. Payment method attachment (createPaymentMethod + tokenization)
4. Error handling (card validation, network errors)
5. Security (HTTPS, console logging, state validation)

Key Validations:
- CardElement is iframe (NOT <input type="text" />)
- confirmCardPayment receives CardElement (Stripe iframe reference)
- Backend receives paymentMethodId (NOT raw card data)
- Checkout URL is checkout.stripe.com (NOT our domain)
- React state has NO cardNumber, cvv, expiryDate properties

Status: BLOCKER-002 (ST4.2) - Frontend tests complete
Task: #3 ST4.2.3 - Tests E2E flujos de pago PCI-DSS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 21:57:57 -06:00
src test(payments): Add E2E tests for Stripe Elements integration (ST4.2.3) 2026-01-26 21:57:57 -06:00
.env.example feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
.eslintrc.cjs feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
.gitignore feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
Dockerfile feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
eslint.config.js feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
index.html feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
ML_DASHBOARD_IMPLEMENTATION.md feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
nginx.conf feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
package-lock.json feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
package.json feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
postcss.config.js feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
README.md feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
tailwind.config.js feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
tsconfig.json feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
tsconfig.node.json feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00
vite.config.ts feat: Initial commit - Trading Platform Frontend 2026-01-18 04:30:39 -06:00

Trading Platform Frontend

Aplicacion web frontend para Trading Platform.

Stack Tecnologico

  • Framework: React 18
  • Build Tool: Vite 6
  • Lenguaje: TypeScript 5.x
  • Estilos: TailwindCSS 3.4
  • Estado: Zustand + React Query
  • Forms: React Hook Form + Zod
  • Charts: Recharts + Lightweight Charts
  • Icons: Heroicons + Lucide React

Estructura del Proyecto

src/
├── components/       # Componentes reutilizables
│   ├── ui/           # Componentes UI base
│   ├── charts/       # Graficos y visualizaciones
│   ├── forms/        # Componentes de formulario
│   └── layout/       # Layout components
├── hooks/            # Custom React hooks
├── modules/          # Modulos de negocio
│   ├── auth/         # Autenticacion
│   ├── dashboard/    # Dashboard principal
│   ├── trading/      # Trading interface
│   ├── portfolio/    # Gestion de portfolios
│   └── education/    # Modulo educativo
├── services/         # API clients y servicios
├── stores/           # Zustand stores
├── styles/           # Estilos globales
├── types/            # TypeScript types
├── App.tsx           # Componente raiz
└── main.tsx          # Entry point

Instalacion

# Instalar dependencias
npm install

# Copiar variables de entorno
cp .env.example .env

Variables de Entorno

# API Backend
VITE_API_URL=http://localhost:3000/api/v1
VITE_WS_URL=ws://localhost:3000/ws

# Stripe (public key)
VITE_STRIPE_PUBLIC_KEY=pk_test_xxx

# Feature flags
VITE_ENABLE_ML_DASHBOARD=true
VITE_ENABLE_TRADING=true

Scripts Disponibles

Script Descripcion
npm run dev Servidor desarrollo (Vite)
npm run build Build produccion
npm run preview Preview build local
npm run lint Verificar codigo ESLint
npm run test Ejecutar tests (Vitest)
npm run typecheck Verificar tipos TypeScript

Desarrollo

# Iniciar servidor desarrollo
npm run dev

# Abrir en navegador
# http://localhost:5173

Componentes Principales

Dashboard

  • Overview de portfolio
  • Graficos de rendimiento
  • Senales ML activas

Trading

  • Interfaz de ordenes
  • Graficos en tiempo real (TradingView style)
  • Order book y historial

Portfolio

  • Distribucion de assets
  • Historial de transacciones
  • Metricas de rendimiento

ML Dashboard

  • Predicciones activas
  • Metricas de modelos
  • Historial de senales

Estado Global (Zustand)

// stores/authStore.ts
const useAuthStore = create((set) => ({
  user: null,
  token: null,
  login: (user, token) => set({ user, token }),
  logout: () => set({ user: null, token: null }),
}));

// stores/tradingStore.ts
const useTradingStore = create((set) => ({
  orders: [],
  positions: [],
  // ...
}));

API Client (React Query)

// services/api.ts
import { useQuery, useMutation } from '@tanstack/react-query';

export const useUser = () => useQuery({
  queryKey: ['user'],
  queryFn: fetchUser,
});

export const useCreateOrder = () => useMutation({
  mutationFn: createOrder,
});

Testing

# Ejecutar tests
npm run test

# Tests con UI
npm run test:ui

# Coverage
npm run test:coverage

Build y Deploy

# Build produccion
npm run build

# Output en dist/
ls dist/

Docker

# Build imagen
docker build -t trading-frontend .

# Ejecutar con nginx
docker run -p 80:80 trading-frontend

Configuracion Nginx

Ver nginx.conf para configuracion de produccion con:

  • Compresion gzip
  • Cache de assets estaticos
  • SPA fallback routing
  • Security headers

Documentacion Relacionada


Proyecto: Trading Platform Version: 0.1.0 Actualizado: 2026-01-07