docs: cierre formal de Sprint 1.5

- OBSERVATIONS.md reseteado para Sprint 2
- STRATEGIC_DIRECTION.md con reflexiones del sprint
- TECH_DEBT.md curado: items resueltos archivados
- methodology/CASE_STUDIES/inq-roi-sprint-1-5.md generado

Sprint 1.5 cerrado:
- 11 etapas + 1 fix pre-Etapa 11
- 526 unit tests + 38 E2E al cierre
- Producto con identidad InQ aplicada en web + 3 PDFs
- Metodología documentada con casos reales (2 de mala
  clasificación de iniciativa, originaron AP.8 +
  refinamiento C.6)
- Material para transmisión al equipo de 5 técnicos
This commit is contained in:
2026-05-19 07:27:40 -03:00
parent 4f6c424d5c
commit 49364f4b18
20 changed files with 1448 additions and 52 deletions

View File

@@ -0,0 +1,98 @@
/**
* Etapa 11 Parte A — Genera el PDF ROI con los 4 refinamientos del polish final.
* Guarda en tests/e2e/__output__/etapa-11-roi.pdf para validación visual del director.
*/
import { test, expect } from '@playwright/test'
import { resolve } from 'path'
import { mkdirSync, readFileSync } from 'fs'
import { fileURLToPath } from 'url'
import { PDFParse } from 'pdf-parse'
import { getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const BPMN_DIR = resolve(__dirname, '../../public/sample-processes')
const OUT_DIR = resolve(__dirname, './__output__')
test.beforeAll(() => { mkdirSync(OUT_DIR, { recursive: true }) })
async function parsePdf(buffer: Buffer) {
const parser = new PDFParse({ data: buffer })
const result = await parser.getText()
await parser.destroy()
return { numpages: result.total, text: result.text }
}
async function getOrientations(buffer: Buffer): Promise<string[]> {
const uint8 = new Uint8Array(buffer)
const pdf = await getDocument({ data: uint8 }).promise
const out: string[] = []
for (let i = 1; i <= pdf.numPages; i++) {
const page = await pdf.getPage(i)
const vp = page.getViewport({ scale: 1 })
out.push(vp.width > vp.height ? 'landscape' : 'portrait')
}
return out
}
test('etapa-11-roi.pdf — polish final página 1 ROI', async ({ page }) => {
await page.goto('/')
await page.locator('#bpmn-file-input').setInputFiles(resolve(BPMN_DIR, 'medium-with-gateways.bpmn'))
await page.waitForURL(/\/workspace\//, { timeout: 15_000 })
await page.waitForSelector('button:has-text("Simular")', { timeout: 10_000 })
await page.waitForTimeout(800)
for (const [id, cost, auto] of [
['task_recv', 200, 20], ['task_score', 200, 20], ['task_analisis', 200, 20]
] as [string, number, number][]) {
await page.locator(`[data-element-id="${id}"]`).first().click()
await page.waitForTimeout(400)
const toggle = page.getByRole('switch', { name: /automatizable/i })
if (await toggle.getAttribute('aria-checked') === 'false') await toggle.click()
await page.waitForTimeout(200)
await page.getByLabel(/Costo directo fijo/i).fill(String(cost))
await page.getByLabel(/Costo automatizado/i).fill(String(auto))
await page.getByLabel(/Tiempo automatizado/i).fill('10')
await page.getByRole('button', { name: /Guardar/i }).click()
await page.waitForTimeout(400)
}
await page.getByRole('tab', { name: /Global/i }).click()
await page.waitForTimeout(300)
await page.getByLabel(/Frecuencia anual/i).fill('5000')
await page.getByLabel(/Inversión en automatización/i).fill('80000')
await page.getByRole('button', { name: /Guardar/i }).click()
await page.waitForTimeout(400)
await page.getByRole('button', { name: 'Simular' }).click()
await page.waitForURL(/\/report\//, { timeout: 20_000 })
await page.waitForSelector('button:has-text("Exportar PDF")', { timeout: 15_000 })
await page.waitForSelector('.bpmn-container .djs-group', { timeout: 30_000 })
await page.waitForTimeout(800)
await page.getByRole('tab', { name: /Comparación/i }).click()
await page.waitForSelector('[data-testid="roi-kpi-card"]', { timeout: 10_000 })
await page.waitForTimeout(500)
const outPath = resolve(OUT_DIR, 'etapa-11-roi.pdf')
const [download] = await Promise.all([
page.waitForEvent('download', { timeout: 30_000 }),
page.getByRole('button', { name: 'Exportar PDF' }).click(),
])
await download.saveAs(outPath)
const buffer = readFileSync(outPath)
const sizeKB = (buffer.length / 1024).toFixed(1)
const { numpages, text } = await parsePdf(buffer)
const orientations = await getOrientations(buffer)
console.log(`etapa-11-roi.pdf: ${numpages} págs, ${sizeKB} KB`)
console.log(`Texto p.1 (500 chars): ${text.slice(0, 500).replace(/\n/g, ' ')}`)
console.log(`Orientaciones: ${orientations.join(', ')}`)
expect(numpages).toBe(5)
expect(orientations).toEqual(['portrait', 'portrait', 'portrait', 'portrait', 'portrait'])
expect(text).toMatch(/AHORRO PROYECTADO A/)
expect(text).toMatch(/TOP 3 ACTIVIDADES POR AHORRO/)
expect(text).toMatch(/InQ ROI/)
expect(text).toMatch(/Powered by InQuality/)
})

View File

@@ -114,7 +114,7 @@ function validatePdfText(text: string, filename: string) {
// ─── Tests ────────────────────────────────────────────────────────────────────
test('etapa-4-actual.pdf — 3 páginas, marca InQ, sin términos prohibidos', async ({ page }) => {
test('etapa-4-actual.pdf — 4 páginas, marca InQ, sin términos prohibidos', async ({ page }) => {
await setupAndSimulate(page)
const outPath = resolve(OUT_DIR, 'etapa-4-actual.pdf')
@@ -125,17 +125,17 @@ test('etapa-4-actual.pdf — 3 páginas, marca InQ, sin términos prohibidos', a
const buffer = readFileSync(outPath)
const sizeKB = buffer.length / 1024
console.log(`Tamaño: ${sizeKB.toFixed(1)} KB`)
expect(sizeKB, 'Tamaño total > 15 KB por página').toBeGreaterThan(15 * 3)
expect(sizeKB, 'Tamaño total < 80 KB por página (3 págs)').toBeLessThan(80 * 3)
expect(sizeKB, 'Tamaño total > 15 KB por página').toBeGreaterThan(15 * 4)
expect(sizeKB, 'Tamaño total < 80 KB por página (4 págs)').toBeLessThan(80 * 4)
const { numpages, text } = await parsePdf(buffer)
console.log(`Páginas: ${numpages}`)
console.log(`Primeros 300 chars: ${text.slice(0, 300).replace(/\n/g, ' ')}`)
expect(numpages).toBe(3)
expect(numpages).toBe(4)
validatePdfText(text, 'etapa-4-actual.pdf')
})
test('etapa-4-automatizado.pdf — 3 páginas, marca InQ, sin términos prohibidos', async ({ page }) => {
test('etapa-4-automatizado.pdf — 4 páginas, marca InQ, sin términos prohibidos', async ({ page }) => {
await setupAndSimulate(page)
const outPath = resolve(OUT_DIR, 'etapa-4-automatizado.pdf')
@@ -145,16 +145,16 @@ test('etapa-4-automatizado.pdf — 3 páginas, marca InQ, sin términos prohibid
const buffer = readFileSync(outPath)
const sizeKB = buffer.length / 1024
console.log(`etapa-4-automatizado.pdf: ${sizeKB.toFixed(1)} KB`)
expect(sizeKB).toBeGreaterThan(15 * 3)
expect(sizeKB).toBeLessThan(80 * 3)
expect(sizeKB).toBeGreaterThan(15 * 4)
expect(sizeKB).toBeLessThan(80 * 4)
const { numpages, text } = await parsePdf(buffer)
console.log(`Páginas: ${numpages}`)
expect(numpages).toBe(3)
expect(numpages).toBe(4)
validatePdfText(text, 'etapa-4-automatizado.pdf')
})
test('etapa-4-roi.pdf — 4 páginas, marca InQ, keywords ROI, sin términos prohibidos', async ({ page }) => {
test('etapa-4-roi.pdf — 5 páginas, marca InQ, keywords ROI, sin términos prohibidos', async ({ page }) => {
await setupAndSimulate(page)
const outPath = resolve(OUT_DIR, 'etapa-4-roi.pdf')
@@ -164,14 +164,14 @@ test('etapa-4-roi.pdf — 4 páginas, marca InQ, keywords ROI, sin términos pro
const buffer = readFileSync(outPath)
const sizeKB = buffer.length / 1024
console.log(`etapa-4-roi.pdf: ${sizeKB.toFixed(1)} KB`)
// ROI PDF no tiene imagen BPMN embebida → tamaño por página es menor (~8-12 KB texto puro)
expect(sizeKB, 'ROI PDF debe tener contenido mínimo (4 páginas texto)').toBeGreaterThan(20)
expect(sizeKB, 'ROI PDF no debe ser irrazonablemente grande').toBeLessThan(300)
// ROI PDF incluye imagen de gradiente en página 1 → tamaño mayor (~250 KB)
expect(sizeKB, 'ROI PDF debe tener contenido mínimo (5 páginas)').toBeGreaterThan(20)
expect(sizeKB, 'ROI PDF no debe ser irrazonablemente grande').toBeLessThan(400)
const { numpages, text } = await parsePdf(buffer)
console.log(`Páginas: ${numpages}`)
console.log(`Primeros 400 chars: ${text.slice(0, 400).replace(/\n/g, ' ')}`)
expect(numpages).toBe(4)
expect(numpages).toBe(5)
validatePdfText(text, 'etapa-4-roi.pdf')
// Keywords específicos del PDF de ROI

View File

@@ -145,7 +145,7 @@ for (const c of CASES) {
expect(csvBytes, `CSV de ${c.file} debe ser > 100 bytes`).toBeGreaterThan(100)
const csvText = csvBuffer.toString('utf-8')
expect(csvText, 'CSV debe tener BOM UTF-8').toMatch(/^/)
expect(csvText, 'CSV debe tener BOM UTF-8').toMatch(/^/)
expect(csvText, 'CSV debe contener "Costo total"').toContain('Costo total')
expect(csvText, 'CSV debe contener la moneda').toContain(c.currency)
})

View File

@@ -191,7 +191,7 @@ test('Export ROI — flujo completo con medium-with-gateways', async ({ page })
const csvText = csvBuffer.toString('utf-8')
// BOM UTF-8
expect(csvText).toMatch(/^/)
expect(csvText).toMatch(/^/)
// Metadata ROI presente
expect(csvText).toContain('# Ahorro por ejecución')
@@ -200,7 +200,7 @@ test('Export ROI — flujo completo con medium-with-gateways', async ({ page })
expect(csvText).toContain('# Frecuencia anual: 12000')
// 16 columnas en el header de datos
const csvNoBom = csvText.startsWith('') ? csvText.slice(1) : csvText
const csvNoBom = csvText.startsWith('') ? csvText.slice(1) : csvText
const headerLine = csvNoBom.split('\r\n').find((l) => !l.startsWith('#') && l.trim())!
const colCount = headerLine.split('","').length
console.log(` Columnas CSV: ${colCount}`)

View File

@@ -19,7 +19,7 @@ test.beforeAll(() => {
test('prod-smoke — import → simulate → export PDF', async ({ page }) => {
// ── 1. Landing page carga correctamente ──────────────────────────────────
await page.goto('/')
await expect(page).toHaveTitle(/Process Cost Platform/)
await expect(page).toHaveTitle(/InQ ROI/)
// Verificar heading principal
await expect(page.getByText('Cuantificá el costo operativo')).toBeVisible({ timeout: 10_000 })
@@ -83,7 +83,7 @@ test('prod-smoke — import → simulate → export PDF', async ({ page }) => {
await dlCsv.saveAs(csvPath)
const csvText = readFileSync(csvPath, 'utf-8')
expect(csvText, 'CSV debe tener BOM UTF-8').toMatch(/^/)
expect(csvText, 'CSV debe tener BOM UTF-8').toMatch(/^/)
expect(csvText, 'CSV debe contener encabezado').toContain('Costo total')
console.log(`\n✅ Prod smoke PASSED — https://process-cost-platform.pages.dev`)

View File

@@ -0,0 +1,132 @@
/**
* Etapa 10 Sprint 1.5 — Generación de PDFs baseline final del sprint.
* Genera los 3 PDFs de referencia en tests/e2e/__output__/sprint-1-5-final/
* NO es un test de regresión — es el artefacto baseline para Sprint 2.
*/
import { test, expect } from '@playwright/test'
import { resolve } from 'path'
import { mkdirSync, readFileSync } from 'fs'
import { fileURLToPath } from 'url'
import { PDFParse } from 'pdf-parse'
import { getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const BPMN_DIR = resolve(__dirname, '../../public/sample-processes')
const OUT_DIR = resolve(__dirname, './__output__/sprint-1-5-final')
test.beforeAll(() => { mkdirSync(OUT_DIR, { recursive: true }) })
async function parsePdf(buffer: Buffer) {
const parser = new PDFParse({ data: buffer })
const result = await parser.getText()
await parser.destroy()
return { numpages: result.total, text: result.text }
}
async function getOrientations(buffer: Buffer): Promise<string[]> {
const uint8 = new Uint8Array(buffer)
const pdf = await getDocument({ data: uint8 }).promise
const out: string[] = []
for (let i = 1; i <= pdf.numPages; i++) {
const page = await pdf.getPage(i)
const vp = page.getViewport({ scale: 1 })
out.push(vp.width > vp.height ? 'landscape' : 'portrait')
}
return out
}
async function setupFullScenario(page: import('@playwright/test').Page) {
await page.goto('/')
await page.locator('#bpmn-file-input').setInputFiles(resolve(BPMN_DIR, 'medium-with-gateways.bpmn'))
await page.waitForURL(/\/workspace\//, { timeout: 15_000 })
await page.waitForSelector('button:has-text("Simular")', { timeout: 10_000 })
await page.waitForTimeout(800)
for (const [id, cost, auto] of [
['task_recv', 200, 20], ['task_score', 200, 20], ['task_analisis', 200, 20]
] as [string, number, number][]) {
await page.locator(`[data-element-id="${id}"]`).first().click()
await page.waitForTimeout(400)
const toggle = page.getByRole('switch', { name: /automatizable/i })
if (await toggle.getAttribute('aria-checked') === 'false') await toggle.click()
await page.waitForTimeout(200)
await page.getByLabel(/Costo directo fijo/i).fill(String(cost))
await page.getByLabel(/Costo automatizado/i).fill(String(auto))
await page.getByLabel(/Tiempo automatizado/i).fill('10')
await page.getByRole('button', { name: /Guardar/i }).click()
await page.waitForTimeout(400)
}
await page.getByRole('tab', { name: /Global/i }).click()
await page.waitForTimeout(300)
await page.getByLabel(/Frecuencia anual/i).fill('5000')
await page.getByLabel(/Inversión en automatización/i).fill('80000')
await page.getByRole('button', { name: /Guardar/i }).click()
await page.waitForTimeout(400)
await page.getByRole('button', { name: 'Simular' }).click()
await page.waitForURL(/\/report\//, { timeout: 20_000 })
await page.waitForSelector('button:has-text("Exportar PDF")', { timeout: 15_000 })
await page.waitForSelector('.bpmn-container .djs-group', { timeout: 30_000 })
await page.waitForTimeout(800)
}
async function downloadTab(page: import('@playwright/test').Page, tab: 'actual' | 'automatizado' | 'roi', outPath: string) {
if (tab === 'actual') {
await page.getByRole('tab', { name: 'Actual' }).click()
await page.waitForTimeout(400)
} else if (tab === 'automatizado') {
await page.getByRole('tab', { name: 'Automatizado' }).click()
await page.waitForTimeout(400)
} else {
await page.getByRole('tab', { name: /Comparación/i }).click()
await page.waitForSelector('[data-testid="roi-kpi-card"]', { timeout: 10_000 })
await page.waitForTimeout(500)
}
const [download] = await Promise.all([
page.waitForEvent('download', { timeout: 30_000 }),
page.getByRole('button', { name: 'Exportar PDF' }).click(),
])
await download.saveAs(outPath)
}
test('sprint-1-5-final: generar y validar 3 PDFs baseline', async ({ page }) => {
await setupFullScenario(page)
// PDF Actual
const actualPath = resolve(OUT_DIR, 'final-actual.pdf')
await downloadTab(page, 'actual', actualPath)
const actualBuf = readFileSync(actualPath)
const actualKB = (actualBuf.length / 1024).toFixed(1)
const { numpages: actualPages } = await parsePdf(actualBuf)
const actualOrientations = await getOrientations(actualBuf)
console.log(`final-actual.pdf: ${actualPages} págs, ${actualKB} KB, ${actualOrientations.join(',')}`)
expect(actualPages).toBe(4)
expect(actualOrientations).toEqual(['portrait', 'landscape', 'portrait', 'portrait'])
// PDF Automatizado
const autoPath = resolve(OUT_DIR, 'final-automatizado.pdf')
await downloadTab(page, 'automatizado', autoPath)
const autoBuf = readFileSync(autoPath)
const autoKB = (autoBuf.length / 1024).toFixed(1)
const { numpages: autoPages } = await parsePdf(autoBuf)
const autoOrientations = await getOrientations(autoBuf)
console.log(`final-automatizado.pdf: ${autoPages} págs, ${autoKB} KB, ${autoOrientations.join(',')}`)
expect(autoPages).toBe(4)
expect(autoOrientations).toEqual(['portrait', 'landscape', 'portrait', 'portrait'])
// PDF ROI
const roiPath = resolve(OUT_DIR, 'final-roi.pdf')
await downloadTab(page, 'roi', roiPath)
const roiBuf = readFileSync(roiPath)
const roiKB = (roiBuf.length / 1024).toFixed(1)
const { numpages: roiPages, text: roiText } = await parsePdf(roiBuf)
const roiOrientations = await getOrientations(roiBuf)
console.log(`final-roi.pdf: ${roiPages} págs, ${roiKB} KB, ${roiOrientations.join(',')}`)
expect(roiPages).toBe(5)
expect(roiOrientations).toEqual(['portrait', 'portrait', 'portrait', 'portrait', 'portrait'])
expect(roiText).toMatch(/AHORRO PROYECTADO A/)
expect(roiText).toMatch(/TRAYECTORIA DEL AHORRO ACUMULADO/)
expect(roiText).toMatch(/InQ ROI/)
expect(roiText).toMatch(/Powered by InQuality/)
})