test(webapp): seed the visual login session in indicadores specs
The indicadores navigation, sections and cancer-journey specs routed through the real routes without a session, so authGuard redirected to LoginPage. Add auth.testing helpers that seed and clear the sessionStorage session, use them in those specs, and add a spec that /indicadores/<dominio> without a session presents LoginPage with returnUrl.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { Usuario } from './auth.service';
|
||||
|
||||
/** Same key AuthService persists the visual session under. */
|
||||
const CLAVE_SESION = 'isssteleon.sesion';
|
||||
|
||||
/**
|
||||
* Seeds the browser-only visual session before the router and AuthService are created,
|
||||
* so routes behind authGuard render instead of redirecting to /login. Pair every call
|
||||
* with `limpiarSesionVisual()` in afterEach so the session never leaks between tests.
|
||||
*/
|
||||
export function iniciarSesionVisual(sesion: Usuario = { usuario: 'admin', nombre: 'Administrador', dominios: ['cacu', 'cama', 'tea'] }): void {
|
||||
sessionStorage.setItem(CLAVE_SESION, JSON.stringify(sesion));
|
||||
}
|
||||
|
||||
export function limpiarSesionVisual(): void {
|
||||
sessionStorage.removeItem(CLAVE_SESION);
|
||||
}
|
||||
Reference in New Issue
Block a user