- fixtures/keycloak.ts: Admin REST API helpers (createTestUser, assignRoles, deleteTestUser) — copia exacta del hub - global-setup.ts: crea usuario e2e-anexo76 en KC antes de los tests - global-teardown.ts: elimina el usuario al finalizar - auth.setup.ts: navega a /login → Workspace → llena form → /dashboard (ya no usa password grant ni Direct Access Grants) - playwright.config.ts: agrega globalSetup y globalTeardown - Jenkinsfile: a76-e2e-credentials ahora son credenciales de KC admin; usuario de prueba es efímero (creado/borrado por global-setup/teardown) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { defineConfig } from '@playwright/test';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
const authStatePath = path.join(__dirname, 'e2e/.auth/user.json');
|
|
/** GitHub/Gitea/GitLab suelen exportar CI=true; Jenkins no siempre, pero define JENKINS_URL. */
|
|
const inCI = process.env.CI === 'true' || Boolean(process.env.JENKINS_URL);
|
|
|
|
export default defineConfig({
|
|
// Crea usuario de prueba en KC antes de los tests; lo elimina al finalizar
|
|
// Patrón idéntico al de aduanasoft-hub
|
|
globalSetup: './e2e/global-setup.ts',
|
|
globalTeardown: './e2e/global-teardown.ts',
|
|
|
|
// En CI, falla si queda un .only; en local no
|
|
forbidOnly: inCI,
|
|
timeout: 60_000,
|
|
use: {
|
|
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://localhost:5173',
|
|
// Sin display en agentes de integración: obligatorio headless
|
|
headless: inCI ? true : false
|
|
},
|
|
workers: 1,
|
|
testDir: 'e2e',
|
|
projects: [
|
|
{
|
|
name: 'setup',
|
|
testMatch: '**/auth.setup.ts',
|
|
// Navegador limpio: user.json se genera aquí y no debe existir al primer run / en CI
|
|
use: { storageState: { cookies: [], origins: [] } }
|
|
},
|
|
{
|
|
name: 'tests',
|
|
dependencies: ['setup'],
|
|
testIgnore: ['**/auth.setup.ts', '**/demo.test.ts'],
|
|
use: { storageState: authStatePath }
|
|
}
|
|
]
|
|
});
|