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:
@@ -7,6 +7,8 @@ import { provideRouter, Router } from '@angular/router';
|
||||
import { RouterTestingHarness } from '@angular/router/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { routes } from '../../app.routes';
|
||||
import { LoginPage } from '../../auth/login-page';
|
||||
import { iniciarSesionVisual, limpiarSesionVisual } from '../../auth/auth.testing';
|
||||
import { IndicadorCatalogCard } from './indicador-catalog-card';
|
||||
import { IndicadorFigurePanel } from './indicador-figure-panel';
|
||||
import { IndicadoresPage } from './indicadores-page';
|
||||
@@ -22,6 +24,7 @@ class ChartStub { figure?: PlotlyFigure; }
|
||||
describe('UX-04 navegación Angular', () => {
|
||||
let http: HttpTestingController;
|
||||
async function setup() {
|
||||
iniciarSesionVisual();
|
||||
vi.stubGlobal('IntersectionObserver', class { observe() {} unobserve() {} disconnect() {} });
|
||||
TestBed.configureTestingModule({ providers: [provideRouter(routes), provideHttpClient(), provideHttpClientTesting(), periodAvailabilityProvider, kpiQueriesProvider] });
|
||||
TestBed.overrideComponent(IndicadorFigureCard, { remove: { imports: [PlotlyChart] }, add: { imports: [ChartStub] } });
|
||||
@@ -39,7 +42,14 @@ describe('UX-04 navegación Angular', () => {
|
||||
req.flush({ data: [{ y: [0, null] }], layout: {} });
|
||||
return req;
|
||||
}
|
||||
afterEach(() => { http.verify(); vi.unstubAllGlobals(); });
|
||||
afterEach(() => { http.verify(); vi.unstubAllGlobals(); limpiarSesionVisual(); });
|
||||
it.each(['tea', 'cacu', 'cama'] as const)('sin sesión visual, /indicadores/%s presenta LoginPage y conserva returnUrl', async domain => {
|
||||
const harness = await setup();
|
||||
limpiarSesionVisual();
|
||||
await harness.navigateByUrl('/indicadores/' + domain, LoginPage);
|
||||
expect(TestBed.inject(Router).url).toBe('/login?returnUrl=%2Findicadores%2F' + domain);
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it.each(['tea', 'cacu', 'cama'] as const)('navegación %s mantiene tres enlaces, estado, decoración y foco independiente', async domain => {
|
||||
const harness = await setup();
|
||||
await harness.navigateByUrl('/indicadores/' + domain, IndicadoresPage);
|
||||
|
||||
Reference in New Issue
Block a user