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.
This commit is contained in:
2026-05-21 17:53:40 -05:00
parent 9cc840da8b
commit ae321f5077
2 changed files with 24 additions and 2 deletions

10
Jenkinsfile vendored
View File

@@ -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
}
}
}

View File

@@ -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()
}