\chapter{Pruebas end-to-end} \label{ch:e2e} \section{Matriz de flujos de negocio} \begin{longtable}{@{}p{1.8cm}p{2.8cm}p{5.0cm}p{3.0cm}@{}} \caption{Casos E2E cr\'iticos.}\\ \toprule \textbf{ID} & \textbf{Flujo} & \textbf{Pasos m\'inimos} & \textbf{\'Exito} \\ \midrule \endhead E2E-01 & Conteo & Lotes PDF $\rightarrow$ \texttt{/count/v1/count} $\rightarrow$ \texttt{/count-jobs} $\rightarrow$ PATCH & Conteos editables \\ E2E-02 & Extracci\'on from-count & Tras E2E-01 $\rightarrow$ task extraction $\rightarrow$ rows & Filas coherentes \\ E2E-03 & Extracci\'on ingest & Upload PDFs $\rightarrow$ task $\rightarrow$ rows & Paridad con fixtures \\ E2E-04 & Limpieza & Batch extraction $\rightarrow$ cleaning job & Reglas aplicadas \\ E2E-05 & Bot feliz & Worker online $\rightarrow$ Excel $\rightarrow$ claim $\rightarrow$ PDFs MinIO $\rightarrow$ completed & Manifest + events \\ E2E-06 & Bot cancel & Cancel pending y running & Estados correctos \\ E2E-07 & Worker offline & Create job sin heartbeat & HTTP 409 \\ E2E-08 & Pipeline largo & Descarga $\rightarrow$ extracci\'on PDFs & Sin corrupci\'on \\ \bottomrule \end{longtable} \section{Detalle E2E-05 (bot descarga)} \subsection{Precondiciones} \begin{itemize} \item Stack Compose healthy; MinIO accesible; token \texttt{BOT\_API\_TOKEN} compartido. \item Job Desktop padre existente en tabla \texttt{jobs}. \item Agent registrado y con heartbeat $<$45\,s. \item Excel fixture con $N$ radicados v\'alidos ($N\geq 3$ en smoke; $N\geq 50$ en regresi\'on). \end{itemize} \subsection{Pasos} \begin{enumerate} \item Arrancar agent: \texttt{python -m bot\_descarga.worker.run --api-url http://127.0.0.1:8189/bot-descarga ...} \item Desde Desktop o HTTP: crear job multipart con Excel. \item Verificar claim y descarga de Excel. \item (Staging Imaging) Completar descargas; en CI mock: simular eventos + PutObject. \item Verificar \texttt{completed}, lista \texttt{/files} y \texttt{\_manifest.json}. \end{enumerate} \subsection{Asserts} \begin{itemize} \item Un \'unico claim; status final \texttt{completed} o \texttt{failed} expl\'icito. \item Eventos ordenados; \texttt{processed/total} coherentes. \item Objetos MinIO bajo \texttt{downloads/\{id\}/}. \end{itemize} \section{Desktop} Checklist manual / automatizable: \begin{itemize} \item Wizard de descargas (2 pasos) y panel de resultados. \item Polling de job ($\sim$3\,s) y workers ($\sim$5\,s). \item Token en \texttt{localStorage} (\texttt{botApiToken}). \end{itemize} Gap conocido a resolver antes de E2E desktop completo: import de m\'odulo downloads ausente referenciado en \texttt{App.tsx}.