Some checks failed
/ Deploy to Cloudflare Pages (push) Has been cancelled
Tier 1 — Automatizado Build: ✅ limpio Lint: ✅ limpio en archivos nuevos de Sprint 4 (separé resource-types.ts de resource-display.tsx para sacar 2 warnings de Fast Refresh; quedan 0 errores/warnings nuevos). Quedó 1 error preexistente en ReportPage.tsx (no tocado desde Sprint 3, fuera de scope) y ~102 warnings no-explicit-any preexistentes en tests viejos. Tests unitarios: ✅ 521/521 verdes Tests E2E: ⚠️ 43-44/48 verdes (varía levemente entre corridas) — detalle abajo Auditoría inicial vs. estado final Antes: 39/39 specs (100%) fallaban — ROJO-AUTH puro, todos por #bpmn-file-input nunca apareciendo (esperaban el flujo pre-Sprint-4 directamente en /). Decisión tomada (con tu input): Opción A — sesión real. Creaste el usuario martin.bernal@inquality.com.py; yo verifiqué que no tenía fila en public.users y se la inserté con platform_role='platform_admin'. Implementé tests/e2e/setup/auth-setup.ts como globalSetup de Playwright: hace signInWithPassword, inyecta la sesión real en localStorage con el formato exacto que usa supabase-js v2, y genera tests/e2e/setup/auth-state.json (gitignored) en cada corrida. Fix adicional necesario: todos los specs navegaban a / esperando el input de archivo ahí — ahora vive en /import. Corregí los 18 page.goto('/') → /import, incluyendo reescribir el flujo obsoleto de prod-smoke.spec.ts (esperaba una landing pre-auth que ya no existe). Resultado: 33→43-44 specs pasan. Quedan 5-6 ROJO-OTRO, con dos causas raíz identificadas (no relacionadas con auth, fuera del mandato de esta etapa que pide no reescribir lógica de tests): Botón "Guardar" en ActivityPanel queda deshabilitado (3 specs de PDF) — encontré algo extraño: el texto del botón dice "Guardar cambios" (que solo se renderiza si isDirty=true) pero Playwright lo sigue viendo disabled. Esto contradice la lógica simple de disabled={!isDirty} en el componente — sospecho un bug real de re-render en producción, pero diagnosticarlo a fondo requiere debugging en vivo. Recomiendo abrir esto como bug dedicado en un sprint futuro. 2 specs usan IndexedDB/Dexie directamente (export-pdf.spec.ts, validate-dod-etapa4.spec.ts) — Dexie se eliminó completamente en Etapa 4. Estos tests necesitan reescritura para inyectar datos vía Supabase en vez de IndexedDB — eso sí es "reescribir lógica de tests", explícitamente fuera de este alcance. Los resultados varían levemente entre corridas porque Playwright corre specs en paralelo bajo la misma cuenta de test compartida — puede haber interferencia de datos entre specs concurrentes. Sugiero como mejora futura (no implementada ahora): --workers=1 para diagnóstico determinístico. Entregables nuevos tests/e2e/setup/auth-setup.ts — global setup con sesión real tests/e2e/sprint-4-smoke.spec.ts — 9 tests (4 sin auth: login, redirects de /, /workspace, /recursos; 5 con auth: biblioteca sin 500, sin 406 en simulations, catálogo carga, avatar visible, import navega a workspace) docs/CHECKLIST_ENTREGA.md — las 4 tiers completas .env.test (gitignored) + .env.example documentado .gitignore actualizado (.env.test, auth-state.json) Polish Textos de OwnershipBadge y "Compartir con equipo" ya estaban en español — sin cambios. Tooltip "Disponible próximamente" para "Compartir con equipo": no lo agregué, tal como pedía el propio brief, consultarte antes. ¿Lo querés?
138 lines
5.2 KiB
TypeScript
138 lines
5.2 KiB
TypeScript
/**
|
|
* Etapa 9 Sprint 1.5 — Badge ⚡ naranja InQ en BpmnCanvas.
|
|
*
|
|
* Validaciones:
|
|
* 1. El badge aparece cuando una actividad se marca como automatizable
|
|
* 2. El badge desaparece cuando se desmarca (toggle off)
|
|
* 3. El badge reaparece al volver a marcar (toggle on)
|
|
* 4. El badge usa var(--inq-orange) / naranja InQ (no ámbar legacy)
|
|
* 5. Screenshots: workspace-badge-on.png + workspace-badge-detail.png
|
|
*/
|
|
import { test, expect } from '@playwright/test'
|
|
import { resolve } from 'path'
|
|
import { mkdirSync } from 'fs'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
test.use({ storageState: 'tests/e2e/setup/auth-state.json' })
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
const BPMN_DIR = resolve(__dirname, '../../public/sample-processes')
|
|
const SCREENSHOTS_DIR = resolve(__dirname, '../screenshots/etapa-9')
|
|
|
|
test.beforeAll(() => { mkdirSync(SCREENSHOTS_DIR, { recursive: true }) })
|
|
|
|
async function loadProcess(page: import('@playwright/test').Page, filename: string) {
|
|
await page.goto('/import')
|
|
await page.locator('#bpmn-file-input').setInputFiles(resolve(BPMN_DIR, filename))
|
|
await page.waitForURL(/\/workspace\//, { timeout: 15_000 })
|
|
await page.waitForSelector('button:has-text("Simular")', { timeout: 10_000 })
|
|
await page.waitForTimeout(800)
|
|
}
|
|
|
|
async function markAutomatable(page: import('@playwright/test').Page, elementId: string) {
|
|
await page.locator(`[data-element-id="${elementId}"]`).first().click()
|
|
await page.waitForTimeout(400)
|
|
const toggle = page.getByRole('switch', { name: /automatizable/i })
|
|
const checked = await toggle.getAttribute('aria-checked')
|
|
if (checked === 'false') {
|
|
await toggle.click()
|
|
await page.waitForTimeout(200)
|
|
// Guardar es necesario para persistir al store → actualiza automatableElementIds
|
|
await page.getByRole('button', { name: /Guardar/i }).click()
|
|
}
|
|
await page.waitForSelector('.automatable-badge', { timeout: 8_000 })
|
|
}
|
|
|
|
async function unmarkAutomatable(page: import('@playwright/test').Page, elementId: string) {
|
|
await page.locator(`[data-element-id="${elementId}"]`).first().click()
|
|
await page.waitForTimeout(400)
|
|
const toggle = page.getByRole('switch', { name: /automatizable/i })
|
|
const checked = await toggle.getAttribute('aria-checked')
|
|
if (checked === 'true') {
|
|
await toggle.click()
|
|
await page.waitForTimeout(200)
|
|
await page.getByRole('button', { name: /Guardar/i }).click()
|
|
}
|
|
await page.waitForTimeout(800) // esperar que el overlay se elimine
|
|
}
|
|
|
|
test('badge ⚡ aparece al marcar actividad como automatizable', async ({ page }) => {
|
|
await loadProcess(page, 'medium-with-gateways.bpmn')
|
|
await markAutomatable(page, 'task_recv')
|
|
|
|
const badge = page.locator('.automatable-badge').first()
|
|
await expect(badge).toBeVisible({ timeout: 5_000 })
|
|
await expect(badge).toHaveText('⚡')
|
|
})
|
|
|
|
test('badge ⚡ desaparece al desmarcar actividad', async ({ page }) => {
|
|
await loadProcess(page, 'medium-with-gateways.bpmn')
|
|
|
|
// Marcar
|
|
await markAutomatable(page, 'task_recv')
|
|
await expect(page.locator('.automatable-badge').first()).toBeVisible({ timeout: 5_000 })
|
|
|
|
// Desmarcar
|
|
await unmarkAutomatable(page, 'task_recv')
|
|
await expect(page.locator('.automatable-badge')).toHaveCount(0, { timeout: 5_000 })
|
|
})
|
|
|
|
test('badge ⚡ reaparece después de toggle on → off → on', async ({ page }) => {
|
|
await loadProcess(page, 'medium-with-gateways.bpmn')
|
|
|
|
await markAutomatable(page, 'task_recv')
|
|
await expect(page.locator('.automatable-badge')).toHaveCount(1, { timeout: 5_000 })
|
|
|
|
await unmarkAutomatable(page, 'task_recv')
|
|
await expect(page.locator('.automatable-badge')).toHaveCount(0, { timeout: 5_000 })
|
|
|
|
await markAutomatable(page, 'task_recv')
|
|
await expect(page.locator('.automatable-badge')).toHaveCount(1, { timeout: 5_000 })
|
|
})
|
|
|
|
test('screenshot workspace-badge-on: múltiples badges visibles', async ({ page }) => {
|
|
await loadProcess(page, 'medium-with-gateways.bpmn')
|
|
|
|
for (const id of ['task_recv', 'task_score', 'task_analisis']) {
|
|
const el = page.locator(`[data-element-id="${id}"]`)
|
|
if (await el.count() > 0) {
|
|
await markAutomatable(page, id)
|
|
}
|
|
}
|
|
|
|
await page.waitForTimeout(400)
|
|
|
|
await page.screenshot({
|
|
path: resolve(SCREENSHOTS_DIR, 'workspace-badge-on.png'),
|
|
fullPage: false,
|
|
})
|
|
|
|
const badgeCount = await page.locator('.automatable-badge').count()
|
|
expect(badgeCount).toBeGreaterThanOrEqual(1)
|
|
})
|
|
|
|
test('screenshot workspace-badge-detail: zoom in sobre nodo automatizable', async ({ page }) => {
|
|
await loadProcess(page, 'medium-with-gateways.bpmn')
|
|
await markAutomatable(page, 'task_recv')
|
|
|
|
// Capturar área del nodo con el badge
|
|
const nodeWithBadge = page.locator('[data-element-id="task_recv"]').first()
|
|
const box = await nodeWithBadge.boundingBox()
|
|
if (box) {
|
|
const padding = 40
|
|
await page.screenshot({
|
|
path: resolve(SCREENSHOTS_DIR, 'workspace-badge-detail.png'),
|
|
clip: {
|
|
x: Math.max(0, box.x - padding),
|
|
y: Math.max(0, box.y - padding),
|
|
width: box.width + padding * 2,
|
|
height: box.height + padding * 2,
|
|
},
|
|
})
|
|
} else {
|
|
await page.screenshot({ path: resolve(SCREENSHOTS_DIR, 'workspace-badge-detail.png') })
|
|
}
|
|
|
|
await expect(page.locator('.automatable-badge')).toBeVisible()
|
|
})
|