en el medio del kilombo de la db
This commit is contained in:
70
tests/e2e/sprint5-verificacion.spec.ts
Normal file
70
tests/e2e/sprint5-verificacion.spec.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { test, expect, type Page, type BrowserContext } from '@playwright/test'
|
||||
|
||||
// Credenciales SIEMPRE desde .env.test (playwright.config.ts las carga) — nunca acá.
|
||||
const EMAIL = process.env.E2E_EMAIL!
|
||||
const PASSWORD = process.env.E2E_PASSWORD!
|
||||
|
||||
// Survey Demo — la única con datos sembrados (51 respuestas, ver
|
||||
// docs/estado/ESTADO_PROYECTO_26JUN2026.md §4). Necesaria como ?s= en el
|
||||
// formulario público: con 3 surveys en `live`, `/` sin parámetro es ambiguo
|
||||
// (app/page.tsx usa .maybeSingle() sobre status='live').
|
||||
const DEMO_SURVEY_ID = '30000000-0000-0000-0000-000000000001'
|
||||
|
||||
test.describe.serial('Sprint 5 — verificación post-deploy', () => {
|
||||
let context: BrowserContext
|
||||
let page: Page
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
context = await browser.newContext()
|
||||
page = await context.newPage()
|
||||
})
|
||||
|
||||
test.afterAll(async () => {
|
||||
await context.close()
|
||||
})
|
||||
|
||||
test('1. /admin/responses sin sesión redirige a /login', async () => {
|
||||
await page.goto('/admin/responses')
|
||||
await expect(page).toHaveURL(/\/login/)
|
||||
await expect(page.getByRole('textbox', { name: 'Email' })).toBeVisible()
|
||||
await expect(page.getByRole('textbox', { name: 'Contraseña' })).toBeVisible()
|
||||
await expect(page.getByRole('button', { name: /contraseña/i })).toBeVisible()
|
||||
})
|
||||
|
||||
test('2. login funcional redirige a /admin/responses con filtro y datos', async () => {
|
||||
await page.getByRole('textbox', { name: 'Email' }).fill(EMAIL)
|
||||
await page.getByRole('textbox', { name: 'Contraseña' }).fill(PASSWORD)
|
||||
await page.getByRole('button', { name: 'Ingresar' }).click()
|
||||
await expect(page).toHaveURL(/\/admin\/responses/)
|
||||
await expect(page.locator('select.admin-survey-select')).toBeVisible()
|
||||
await expect(page.locator('table.admin-table tbody tr').first()).toBeVisible()
|
||||
})
|
||||
|
||||
test('3. vista detallada de una respuesta', async () => {
|
||||
await page.locator('a.admin-action-link', { hasText: 'Ver' }).first().click()
|
||||
await expect(page).toHaveURL(/\/admin\/responses\/[0-9a-f-]{36}/)
|
||||
await expect(page.locator('.admin-detail-section').first()).toBeVisible()
|
||||
await expect(page.getByText('Respuesta no encontrada')).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('4. dashboard muestra datos reales (no todo suprimido por k<5)', async () => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(page.locator('.db-widget').first()).toBeVisible()
|
||||
await expect(page.locator('body')).toContainText('%')
|
||||
const totalWidgets = await page.locator('.db-widget').count()
|
||||
const suppressed = await page.locator('.db-suppressed').count()
|
||||
expect(totalWidgets).toBeGreaterThan(0)
|
||||
expect(suppressed).toBeLessThan(totalWidgets)
|
||||
})
|
||||
|
||||
test('5. formulario público accesible sin auth', async ({ browser }) => {
|
||||
const anonContext = await browser.newContext()
|
||||
const anonPage = await anonContext.newPage()
|
||||
await anonPage.goto(`/?s=${DEMO_SURVEY_ID}`)
|
||||
await expect(anonPage).not.toHaveURL(/\/login/)
|
||||
await expect(
|
||||
anonPage.locator('.consent-container, .wizard-shell').first()
|
||||
).toBeVisible()
|
||||
await anonContext.close()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user