From ae321f5077a680616cfb828d25b720e7813ce8ae Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Thu, 21 May 2026 17:53:40 -0500 Subject: [PATCH] feat(jenkins): enhance E2E testing and debugging capabilities - Updated Jenkinsfile to include Playwright's trace option for better debugging on test failures. - Added archiving of test results, including trace files, error context, and screenshots for failed tests. - Enhanced error handling in `auth.setup.ts` to log diagnostic information when authentication fails, improving visibility into issues. These changes aim to improve the reliability and debuggability of E2E tests. --- Jenkinsfile | 10 +++++++++- frontend/e2e/auth.setup.ts | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index edde2aba..3b559ac9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -334,7 +334,9 @@ pipeline { E2E_EXIT=0 PLAYWRIGHT_JUNIT_OUTPUT_NAME=playwright-results.xml \ - pnpm exec playwright test --reporter=junit,html || E2E_EXIT=$? + pnpm exec playwright test \ + --reporter=junit,html \ + --trace=retain-on-failure || E2E_EXIT=$? exit "$E2E_EXIT" ' @@ -342,6 +344,9 @@ pipeline { "$WORKSPACE/frontend/playwright-results.xml" 2>/dev/null || true docker cp "$C:/workspace/frontend/playwright-report" \ "$WORKSPACE/frontend/playwright-report" 2>/dev/null || true + # test-results contiene trace.zip + error-context.md + screenshots por test fallido + docker cp "$C:/workspace/frontend/test-results" \ + "$WORKSPACE/frontend/test-results" 2>/dev/null || true ''' } } @@ -349,6 +354,9 @@ pipeline { always { junit allowEmptyResults: true, testResults: 'frontend/playwright-results.xml' archiveArtifacts artifacts: 'frontend/playwright-report/**', allowEmptyArchive: true + // Artefactos de debug: trace.zip (abrir con `pnpm exec playwright show-trace`), + // error-context.md (snapshot del DOM al fallo) y screenshots por test fallido. + archiveArtifacts artifacts: 'frontend/test-results/**', allowEmptyArchive: true } } } diff --git a/frontend/e2e/auth.setup.ts b/frontend/e2e/auth.setup.ts index 2332e917..426a8354 100644 --- a/frontend/e2e/auth.setup.ts +++ b/frontend/e2e/auth.setup.ts @@ -36,7 +36,21 @@ setup('autenticacion', async ({ page }) => { // ── 3. Si Workspace muestra el app-launcher (usuario con múltiples apps), // elegir anexo76-dev — la app del launcher cuya URL apunta al frontend bajo prueba. // Cuando hay match directo de dominio, Workspace salta el launcher y este paso no ejecuta. - await page.waitForURL(/\/(app-launcher|dashboard|auth\/callback)/, { timeout: 30_000 }) + try { + await page.waitForURL(/\/(app-launcher|dashboard|auth\/callback)/, { timeout: 30_000 }) + } catch (e) { + // Si seguimos en /login de Workspace, las credenciales fueron rechazadas o el form no aceptó. + // Imprimir diagnóstico antes de fallar: URL actual + posibles mensajes de error visibles. + const currentUrl = page.url() + const errorMessages = await page.locator('.text-destructive, [role="alert"], .error, .invalid-feedback') + .allTextContents() + .catch(() => [] as string[]) + const visibleText = await page.locator('body').innerText().catch(() => '') + console.log(`[auth.setup][DIAG] URL: ${currentUrl}`) + console.log(`[auth.setup][DIAG] Mensajes de error: ${JSON.stringify(errorMessages)}`) + console.log(`[auth.setup][DIAG] Body (primeros 800 chars): ${visibleText.slice(0, 800)}`) + throw e + } if (/\/app-launcher/.test(page.url())) { await page.getByRole('button', { name: /^anexo76-dev/i }).click() }