# Estrategia de pruebas

## Unit tests

Objetivo: validar servicios aislados.

- `openpayService.createStoreCharge`
- `receiptService.createReference`
- `receiptService.bulkCreateReferences`
- `receiptService.updateFromWebhook`
- `callbackSigner.sign`
- `reconciliationService.compareStatus`

Casos:

- monto menor o igual a cero
- moneda distinta a MXN
- duplicado por `external_reference`
- duplicado por `Idempotency-Key`
- error Openpay
- estado desconocido

## Integration tests

Objetivo: validar endpoints completos.

- `POST /api/v1/payment-references`
- `POST /api/v1/payment-references/batches`
- `POST /api/v1/webhooks/openpay`
- `POST /api/v1/reconciliation`
- `GET /api/v1/events`
- `GET /api/v1/audit`

Validar codigos:

- `200`
- `201`
- `202`
- `207`
- `400`
- `401`
- `403`
- `404`
- `409`
- `429`
- `502`

## Mock Openpay Webhook Tests

Payloads recomendados:

```json
{
  "type": "payment.paid",
  "transaction": {
    "id": "tr_123",
    "order_id": "RECIBO-2026-000001",
    "status": "completed",
    "amount": 248.5,
    "currency": "MXN"
  }
}
```

Escenarios:

- firma valida
- firma invalida
- evento duplicado
- referencia inexistente
- callback exitoso
- callback fallido
- reproceso de webhook
- conciliacion posterior al webhook
