diff --git a/src/app/app.html b/src/app/app.html index 5d3c7ac..9061833 100644 --- a/src/app/app.html +++ b/src/app/app.html @@ -4,6 +4,17 @@ {{ title }} + @if (activeDomain(); as domain) { + + + @for (option of otherDomains(); track option) { + {{ domainLabels[option] }} + } + + } diff --git a/src/app/app.routes.spec.ts b/src/app/app.routes.spec.ts index 6f041e4..4bbfe73 100644 --- a/src/app/app.routes.spec.ts +++ b/src/app/app.routes.spec.ts @@ -24,7 +24,7 @@ for (const dominio of ['tea', 'cacu', 'cama']) { expect(page.dominio).toBe(dominio); const http = TestBed.inject(HttpTestingController); http.expectOne(`/${dominio}/indicadores`).flush([]); - expect(harness.routeNativeElement?.querySelectorAll('nav a').length).toBe(3); + expect(harness.routeNativeElement?.querySelector('nav')).toBeNull(); http.verify(); }); } diff --git a/src/app/app.scss b/src/app/app.scss index f52f0dc..22e0425 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -38,6 +38,18 @@ overflow-wrap: anywhere; } +.domain-selector { + flex: 0 0 auto; + margin-inline-start: auto; + background-color: var(--issste-accent); + color: var(--issste-text); + font-weight: 700; + white-space: nowrap; +} +.domain-selector:hover { background-color: var(--issste-accent); filter: brightness(.94); } +.domain-selector:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 2px; } +.domain-selector:disabled { background-color: var(--issste-accent); color: var(--issste-text-secondary); } + main { padding: var(--issste-space-4) var(--issste-page-gutter) 5.5rem; scroll-margin-top: var(--issste-header-clearance); @@ -71,6 +83,8 @@ main { .platform-title { font-size: 1.125rem; + min-width: 0; + overflow-wrap: anywhere; } } @@ -83,9 +97,11 @@ main { } .platform-title { - flex-basis: 100%; - text-align: center; + font-size: 1rem; } + .header-content { gap: .25rem; } + .institutional-logo { width: 112px; } + .domain-selector { padding-inline: .5rem; } } .back-to-top { diff --git a/src/app/app.spec.ts b/src/app/app.spec.ts index c6ea793..d5ac7a0 100644 --- a/src/app/app.spec.ts +++ b/src/app/app.spec.ts @@ -3,12 +3,14 @@ import { provideRouter } from '@angular/router'; import { provideHttpClient } from '@angular/common/http'; import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing'; import { App } from './app'; +import { routes } from './app.routes'; +import { Router } from '@angular/router'; describe('App — UX-06B', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [App], - providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting()], + providers: [provideRouter(routes), provideHttpClient(), provideHttpClientTesting()], }).compileComponents(); }); @@ -53,6 +55,33 @@ describe('App — UX-06B', () => { TestBed.inject(HttpTestingController).expectNone(() => true); TestBed.inject(HttpTestingController).verify(); }); + + it.each([ + ['tea', 'TEA', 'CaCu', 'CaMa'], + ['cacu', 'CaCu', 'TEA', 'CaMa'], + ['cama', 'CaMa', 'TEA', 'CaCu'], + ] as const)('announces %s as the active domain and offers the other domains in the shell', async (domain, active, ...others) => { + const fixture = render(); + await TestBed.inject(Router).navigateByUrl(`/indicadores/${domain}`); + fixture.detectChanges(); + const http = TestBed.inject(HttpTestingController); + const catalog = http.expectOne({ method: 'GET', url: `/${domain}/indicadores` }); + catalog.flush([]); + fixture.detectChanges(); + + const element = fixture.nativeElement as HTMLElement; + const selector = element.querySelector('.domain-selector')!; + expect(selector.textContent).toContain(active); + expect(selector.getAttribute('aria-label')).toBe(`Dominio actual: ${active}. Cambiar dominio`); + selector.click(); + fixture.detectChanges(); + const menuItems = Array.from(document.querySelectorAll('[role="menuitem"]')); + expect(menuItems.map(item => item.textContent?.trim())).toEqual(others); + expect(element.querySelector('nav')).toBeNull(); + http.expectNone(() => true); + fixture.destroy(); + http.verify(); + }); }); describe('App — UX-06D volver al inicio', () => { diff --git a/src/app/app.ts b/src/app/app.ts index ff7f2d1..b1c6779 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,15 +1,29 @@ import { DOCUMENT } from '@angular/common'; -import { Component, ElementRef, inject, OnDestroy, OnInit, signal, ViewChild } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; +import { Component, computed, ElementRef, inject, OnDestroy, OnInit, signal, ViewChild } from '@angular/core'; +import { NavigationEnd, Router, RouterLink, RouterOutlet } from '@angular/router'; +import { MatButtonModule } from '@angular/material/button'; +import { MatMenuModule } from '@angular/material/menu'; +import { filter } from 'rxjs'; @Component({ - imports: [RouterOutlet], + imports: [RouterOutlet, RouterLink, MatButtonModule, MatMenuModule], selector: 'app-root', styleUrl: './app.scss', templateUrl: './app.html', }) export class App implements OnInit, OnDestroy { protected readonly title = 'Plataforma de Indicadores'; + private readonly router = inject(Router); + private readonly currentUrl = signal(this.router.url); + protected readonly activeDomain = computed(() => { + const match = /^\/indicadores\/(tea|cacu|cama)(?:\/|$)/.exec(this.currentUrl()); + return match?.[1] as 'tea' | 'cacu' | 'cama' | undefined; + }); + protected readonly domainLabels = { tea: 'TEA', cacu: 'CaCu', cama: 'CaMa' } as const; + protected readonly otherDomains = computed(() => (['tea', 'cacu', 'cama'] as const) + .filter(domain => domain !== this.activeDomain())); + private readonly routeSubscription = this.router.events.pipe(filter(event => event instanceof NavigationEnd)) + .subscribe(event => this.currentUrl.set(event.urlAfterRedirects)); readonly showBackToTop = signal(false); @ViewChild('mainContent') private mainContent?: ElementRef; private readonly browserWindow = inject(DOCUMENT).defaultView; @@ -28,6 +42,7 @@ export class App implements OnInit, OnDestroy { } ngOnDestroy() { + this.routeSubscription.unsubscribe(); this.browserWindow?.removeEventListener('scroll', this.updateScroll); } } diff --git a/src/app/features/indicadores/indicador-catalog-card.ts b/src/app/features/indicadores/indicador-catalog-card.ts index fb93ded..642b355 100644 --- a/src/app/features/indicadores/indicador-catalog-card.ts +++ b/src/app/features/indicadores/indicador-catalog-card.ts @@ -33,7 +33,7 @@ import { IndicadoresService } from './indicadores.service'; (click)="pinChanged.emit()"> {{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }} -
+
@if (selectedFigure) { @if (!pair.length || otherFigures.length) { @@ -59,16 +59,31 @@ import { IndicadoresService } from './indicadores.service'; `, styles: ` - :host { display: block; min-width: 0; margin: var(--issste-space-4) 0; } - mat-card { padding: clamp(.75rem, 2vw, 1.5rem); background: var(--issste-surface); + :host { display: flex; min-width: 0; margin: 0; } + mat-card { flex: 1; min-width: 0; padding: clamp(.75rem, 2vw, 1.5rem); background: var(--issste-surface); color: var(--issste-text); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); box-shadow: none; } header { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--issste-space-3); } - .graphic-region { min-height: 620px; } + .catalog-content { display: flex; flex-direction: column; flex: 1; min-width: 0; } + .graphic-region { flex: 1; min-width: 0; } :host(.dual-card) { grid-column: 1 / -1; } - .dual-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--issste-space-4); } - .representation-panel { min-width: 0; } - .representation-panel > h3 { margin-bottom: 0; } - @media (max-width: 900px) { .dual-panels { grid-template-columns: minmax(0, 1fr); } } + .graphic-region { display: grid; grid-template-columns: minmax(0, 1fr); } + .representation-panel { display: grid; min-width: 0; grid-template-rows: auto minmax(0, 1fr); } + .representation-panel > h3 { margin: 1rem 0 0; overflow-wrap: anywhere; } + app-indicador-figure-panel { grid-row: 2; } + // Nine shared tracks: name, controls, help, title, legend, plot, notes, + // full labels and stratified detail. Content determines their height. + @supports (grid-template-rows: subgrid) { + .graphic-region { grid-auto-rows: auto; grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto auto auto; } + .representation-panel { grid-row: span 9; grid-template-rows: subgrid; } + app-indicador-figure-panel { grid-row: 2 / span 8; } + .graphic-region:has(app-indicador-figure-card.methodology-expanded) { grid-template-rows: none; align-items: start; } + .graphic-region:has(app-indicador-figure-card.methodology-expanded) .representation-panel { grid-row: auto; grid-template-rows: auto auto; } + .graphic-region:has(app-indicador-figure-card.methodology-expanded) app-indicador-figure-panel { grid-row: auto; grid-template-rows: auto auto auto; } + .graphic-region:has(app-indicador-figure-card.methodology-expanded) app-indicador-figure-card { grid-row: auto; grid-template-rows: auto auto auto auto auto auto; } + } + @media (min-width: 901px) { + .dual-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--issste-space-4); } + } .card-identity { min-width: 0; } h2, p { overflow-wrap: anywhere; } h2 { margin: 0; font-family: var(--issste-font-heading); font-weight: 700; font-size: 1.5rem; line-height: 1.25; } diff --git a/src/app/features/indicadores/indicador-figure-card.html b/src/app/features/indicadores/indicador-figure-card.html index 64c4b38..c2813dc 100644 --- a/src/app/features/indicadores/indicador-figure-card.html +++ b/src/app/features/indicadores/indicador-figure-card.html @@ -1,3 +1,4 @@ + @if (selected) {
} - +
@if (state.status === 'loading') {

Cargando figura…

@@ -35,8 +36,9 @@ } @else {

{{ !selected?.figuras?.length ? 'El indicador no tiene figuras disponibles.' : 'Completa una selección válida para consultar la figura.' }}

} +
@if (chartFigure) { -
+
@if (state.status === 'ready' && state.hierarchy; as hierarchy) {

{{ activeParent ? 'Categorías de ' + activeParent + '. Anillo exterior: porcentajes dentro de este grupo. Anillo interior: todos los grupos.' : 'Selecciona un segmento para ver sus categorías. También puedes explorar los grupos con Tab y Enter o Espacio.' }}

@@ -84,12 +86,19 @@ }
} +
+
+
+ } + +
@if (state.categoryLabels?.length) {
Nombres completos de las categorías @@ -100,6 +109,5 @@
} -
- } +
diff --git a/src/app/features/indicadores/indicador-figure-card.scss b/src/app/features/indicadores/indicador-figure-card.scss index 050a7ec..7b66cf7 100644 --- a/src/app/features/indicadores/indicador-figure-card.scss +++ b/src/app/features/indicadores/indicador-figure-card.scss @@ -1,6 +1,7 @@ -:host { display: block; min-width: 0; } +:host { display: grid; min-width: 0; } .interpretation { - margin-bottom: var(--issste-space-4); + margin: 0; + padding: 0 1rem .75rem; color: var(--issste-text); font-family: var(--issste-font-body); line-height: 1.5; @@ -14,12 +15,26 @@ .interpretation ul { margin: 0; padding-left: 1.25rem; } .interpretation li + li { margin-top: .25rem; } .period-note { margin: .75rem 0 0; color: var(--issste-text-secondary); } -.methodology-toggle { margin-top: var(--issste-space-3); min-height: 44px; max-width: 100%; height: auto; white-space: normal; +.methodology-toggle { margin-top: .75rem; min-height: 44px; max-width: 100%; height: auto; white-space: normal; --mat-button-outlined-label-text-color: var(--issste-text); --mat-button-outlined-outline-color: var(--issste-border); } .methodology-detail p { margin: 0; } .methodology-detail p + p { margin-top: var(--issste-space-2); } .methodology-toggle:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 3px; } -.figure-card { overflow: visible; min-width: 0; border: 1px solid var(--issste-border); } +.figure-card { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; + overflow: visible; min-width: 0; border: 1px solid var(--issste-border); } +.figure-heading { grid-row: 2; min-width: 0; padding-bottom: .5rem; } +.interpretation { grid-row: 1; } +.figure-legend { grid-row: 3; min-width: 0; } +.plot-slot { grid-row: 4; min-width: 0; align-content: start; } +.plot-slot[hidden] { display: none; } +.figure-footer { grid-row: 5; min-width: 0; align-content: end; } +.figure-labels { grid-row: 6; min-width: 0; } +@supports (grid-template-rows: subgrid) { + :host, .figure-card { grid-template-rows: subgrid; } + .figure-card { grid-row: span 6; } +} +:host(.methodology-expanded), :host(.methodology-expanded) .figure-card { grid-template-rows: auto auto auto auto auto auto; } +:host(.methodology-expanded) .figure-card { grid-row: auto; } .figure-title { display: block; padding: 1rem 1rem 0; margin: 0; font: var(--mat-sys-title-medium); font-family: var(--issste-font-heading); overflow-wrap: anywhere; } .state { padding: 1.25rem; margin: 0; overflow-wrap: anywhere; } .dark { background: #151b28; color: #eef1f7; color-scheme: dark; --mat-sys-primary: #b1c9ff; --mat-sys-outline: #a1aabd; } @@ -49,7 +64,7 @@ .category-labels ul { margin: .25rem 0 0; padding-left: 1.25rem; } .category-labels li + li { margin-top: .5rem; } -.figure-skeleton { min-height: 620px; display: flex; flex-direction: column; } +.figure-skeleton { min-height: 12rem; display: flex; flex-direction: column; } .skeleton { flex: 1; margin: 0 1.25rem 1.25rem; border-radius: var(--issste-radius); background: var(--issste-border); opacity: .35; } .donut-navigation { position: relative; diff --git a/src/app/features/indicadores/indicador-figure-card.spec.ts b/src/app/features/indicadores/indicador-figure-card.spec.ts index 1919dd2..b4de189 100644 --- a/src/app/features/indicadores/indicador-figure-card.spec.ts +++ b/src/app/features/indicadores/indicador-figure-card.spec.ts @@ -48,6 +48,30 @@ describe('IndicadorFigureCard', () => { state({ status: 'ready', figure: original, presentationFigure: copy }); return copy; } + it.each(['bar', 'box', 'scatter'])('%s conserva el dimensionamiento intrínseco de Plotly', async type => { + const automatic: PlotlyFigure = { data: [{ type, x: ['A'], y: [2] }], layout: { autosize: true } }; + ready(automatic); await settle(); + const chart = fixture.nativeElement.querySelector('app-plotly-chart') as HTMLElement; + expect(chart.style.getPropertyValue('--plot-height')).toBe(''); + expect(automatic.layout['height']).toBeUndefined(); + const tall = { ...automatic, layout: { ...automatic.layout, height: 830 } }; + ready(tall); await settle(); + expect(chart.style.getPropertyValue('--plot-height')).toBe(''); + expect(fixture.nativeElement.querySelector('app-plotly-chart')).toBe(chart); + expect(tall.layout.height).toBe(830); + }); + it('la leyenda de exploración precede al lienzo y conserva su host y altura al expandir', async () => { + const { figure, data } = donutFixture(); + state({ status: 'ready', figure, presentationFigure: figure, hierarchy: donutHierarchy(figure, data)! }); await settle(); + const plot = fixture.nativeElement.querySelector('app-plotly-chart') as HTMLElement; + const slot = plot.closest('.plot-slot')!; + const legendElement = fixture.nativeElement.querySelector('.figure-legend') as HTMLElement; + expect(legendElement.compareDocumentPosition(slot) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + fixture.componentInstance.expandParent('G2'); await settle(); + expect(fixture.nativeElement.querySelector('app-plotly-chart')).toBe(plot); + expect(plot.style.getPropertyValue('--plot-height')).toBe('440px'); + expect(fixture.nativeElement.querySelector('.figure-card .interpretation')).toBeTruthy(); + }); it('C2 expande por Plotly y teclado, vuelve con foco y conserva host; reinicia al cambiar resultado', async () => { const { figure, data } = donutFixture(); const hierarchy = donutHierarchy(figure, data)!; @@ -105,6 +129,13 @@ describe('IndicadorFigureCard', () => { expect(chart.figure.data[0]['domain']).toEqual({ x: [0, 1], y: [0, 1] }); expect(chart.figure.data[0]['labels']).toEqual(figure.data[0]['labels']); expect(chart.figure.data[0]['values']).toEqual(figure.data[0]['values']); + const heading = fixture.nativeElement.querySelector('.figure-heading') as HTMLElement; + const legendElement = fixture.nativeElement.querySelector('.figure-legend') as HTMLElement; + const slot = fixture.nativeElement.querySelector('.plot-slot') as HTMLElement; + const notes = fixture.nativeElement.querySelector('.figure-footer') as HTMLElement; + expect(heading.compareDocumentPosition(legendElement) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(legendElement.compareDocumentPosition(slot) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(slot.compareDocumentPosition(notes) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); }); it.each(['dominio', 'figuraId', 'selected'])('reinicia expansión cuando cambia identidad %s aunque reciba la misma referencia de figura', input => { const { figure, data } = donutFixture(); @@ -124,9 +155,9 @@ describe('IndicadorFigureCard', () => { expect(section.getAttribute('aria-label')).toBe('Notas al pie de la figura'); expect([...section.querySelectorAll('p')].map(p => p.textContent)).toEqual(notes); expect(section.querySelector('img, script, a')).toBeNull(); - expect(section.previousElementSibling?.tagName).toBe('APP-PLOTLY-CHART'); + expect(section.parentElement?.previousElementSibling?.querySelector('app-plotly-chart')).toBeTruthy(); expect(section.closest('.plot-viewport, app-plotly-chart, details')).toBeNull(); - expect(section.nextElementSibling?.classList.contains('category-labels')).toBe(true); + expect(section.parentElement?.parentElement?.querySelector('.figure-labels .category-labels')).toBeTruthy(); for (const status of ['loading', 'deferred', 'error', 'incompatible', 'idle'] as const) { state({ status }); expect(fixture.nativeElement.querySelector('.methodological-footnotes')).toBeNull(); @@ -277,6 +308,7 @@ describe('IndicadorFigureCard', () => { const button = section.querySelector('button')!; const detail = section.querySelector('[id]') as HTMLElement; expect(button.getAttribute('aria-expanded')).toBe('false'); + expect(fixture.nativeElement.classList.contains('methodology-expanded')).toBe(false); expect(button.getAttribute('aria-controls')).toBe(detail.id); expect(detail.hidden).toBe(true); expect(button.tagName).toBe('BUTTON'); @@ -289,10 +321,12 @@ describe('IndicadorFigureCard', () => { expect([...detail.querySelectorAll('li')].map(li => li.textContent)).toEqual(fixture.componentInstance.interpretation); button.click(); fixture.detectChanges(); expect(detail.hidden).toBe(false); expect(button.getAttribute('aria-expanded')).toBe('true'); + expect(fixture.nativeElement.classList.contains('methodology-expanded')).toBe(true); state({ status: 'loading' }); expect(detail.hidden).toBe(false); button.click(); fixture.detectChanges(); expect(detail.hidden).toBe(true); + expect(fixture.nativeElement.classList.contains('methodology-expanded')).toBe(false); expect(section.querySelector('.methodology-detail[hidden]')).toBe(detail); }); it('UX-06E.P0.2 muestra el contenido de la figura seleccionada al cambiarla', () => { diff --git a/src/app/features/indicadores/indicador-figure-card.ts b/src/app/features/indicadores/indicador-figure-card.ts index 6ea8ab1..101a918 100644 --- a/src/app/features/indicadores/indicador-figure-card.ts +++ b/src/app/features/indicadores/indicador-figure-card.ts @@ -34,6 +34,7 @@ export interface FigureState { @Component({ selector: 'app-indicador-figure-card', standalone: true, + host: { '[class.methodology-expanded]': 'methodologyExpanded()' }, imports: [MatButtonModule, MatIconModule, MatCardModule, MatProgressBarModule, MatTooltipModule, PlotlyChart], templateUrl: './indicador-figure-card.html', styleUrl: './indicador-figure-card.scss', diff --git a/src/app/features/indicadores/indicador-figure-panel.ts b/src/app/features/indicadores/indicador-figure-panel.ts index 98b44fd..edf3992 100644 --- a/src/app/features/indicadores/indicador-figure-panel.ts +++ b/src/app/features/indicadores/indicador-figure-panel.ts @@ -16,14 +16,23 @@ import { c2Capability, c2Figure } from './indicadores-c2-adapter'; import { stratifiedBars, stratifiedCapabilities, StratifiedCell } from './indicadores-stratified'; import { donutPeriodFigures, periodDatos } from './indicadores-donut-periods'; import { c2GeneralSelection } from './indicadores-c2-general-selection'; +import { MatTooltipModule } from '@angular/material/tooltip'; @Component({ selector: 'app-indicador-figure-panel', - imports: [IndicadorFigureCard], + imports: [IndicadorFigureCard, MatTooltipModule], template: ` -
+

{{ dominio }} · {{ indicador.id }} · {{ indicador.titulo }} · {{ figuraId }}

+

Filtro general aplicado: {{ appliedSummary }}

+ @if (!dimension && figuraId === 'fig_c2_barras' && indicador.figuras.includes('fig_c2_donas')) { + + {{ generalSelectionContext ? 'Selección activa' : 'Distribución completa' }} + + } @if (figuraId === 'fig_c2_barras' && capabilities.length) {
Distribución @@ -51,9 +60,10 @@ import { c2GeneralSelection } from './indicadores-c2-general-selection'; } - @if (generalSelectionContext) {

{{ generalSelectionContext }}

} +
+
@if (dimension && result().status === 'ready') { @if (hasSuppressedCells) {

Hay celdas suprimidas: no se dibuja su magnitud y no representan un cero. Consulta su estado en la tabla de valores.

} @if (hasMissingCells) {

Hay datos no disponibles; los espacios sin barra no representan un cero observado.

} @@ -64,12 +74,29 @@ import { c2GeneralSelection } from './indicadores-c2-general-selection'; @if (!cells.length) {

No hay categorías publicadas para esta selección.

} } +
`, styles: ` - :host { display: block; min-width: 0; } - section { margin-top: var(--issste-space-6); padding-top: var(--issste-space-4); border-top: 1px solid var(--issste-border); } - .applied-summary { color: var(--issste-text-secondary); overflow-wrap: anywhere; } + :host { display: grid; min-width: 0; } + .figure-panel { display: grid; min-width: 0; grid-template-rows: auto minmax(0, 1fr) auto; } + .panel-controls { min-width: 0; padding-block: var(--issste-space-3); border-top: 1px solid var(--issste-border); } + .applied-summary { margin: 0; color: var(--issste-text-secondary); overflow-wrap: anywhere; } + .selection-status { display: inline-flex; align-items: center; min-height: 44px; white-space: nowrap; + font: var(--mat-sys-body-small); color: var(--issste-text-secondary); cursor: help; } + .selection-active { color: var(--issste-text); font-weight: 600; } + .selection-status:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; } + .stratified-detail { min-width: 0; overflow-wrap: anywhere; } + @supports (grid-template-rows: subgrid) { + :host, .figure-panel { grid-template-rows: subgrid; } + .figure-panel { grid-row: span 8; } + .panel-controls { grid-row: 1; } + app-indicador-figure-card { grid-row: 2 / span 6; } + .stratified-detail { grid-row: 8; } + } + :host:has(app-indicador-figure-card.methodology-expanded), + .figure-panel:has(app-indicador-figure-card.methodology-expanded) { grid-template-rows: auto auto auto; } + .figure-panel:has(app-indicador-figure-card.methodology-expanded) { grid-row: auto; } .distribution-control { margin: var(--issste-space-3) 0; padding: 0; border: 0; min-width: 0; } .distribution-control legend { padding: 0; font-weight: 600; } .distribution-toggle, .distribution-dimensions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; } diff --git a/src/app/features/indicadores/indicadores-c2-general-panel.spec.ts b/src/app/features/indicadores/indicadores-c2-general-panel.spec.ts index d6f3ac6..ca462e9 100644 --- a/src/app/features/indicadores/indicadores-c2-general-panel.spec.ts +++ b/src/app/features/indicadores/indicadores-c2-general-panel.spec.ts @@ -37,10 +37,39 @@ describe('barras generales conectadas con la selección compartida de la dona', select({ parent: 'G2', period: '2025-S2' }); expect(displayed().data[0]['y']).toEqual(['B', 'C']); select({ parent: 'G2', category: 'B', period: '2025-S2' }); expect(displayed().data[0]['y']).toEqual(['B']); expect(panel().result().figure).toBe(original); expect(original).toEqual(before); - expect(fixture.nativeElement.textContent).toContain('G2 · B · 2025-S2'); + expect(fixture.nativeElement.querySelector('.selection-status').getAttribute('aria-label')).toContain('G2 · B · 2025-S2'); select({}); expect(displayed()).toEqual(all); expect(panel().generalSelectionContext).toBeUndefined(); expect(panel().applied).toEqual(filter); expect(fixture.nativeElement.querySelector('app-plotly-chart')).toBe(host); http.expectNone(() => true); }); + it('mantiene el mismo estado compacto antes, durante y después de seleccionar, fuera del lienzo', () => { + load(); + const status = fixture.nativeElement.querySelector('.selection-status') as HTMLElement; + const plot = fixture.nativeElement.querySelector('app-plotly-chart') as HTMLElement; + const height = plot.style.getPropertyValue('--plot-height'); + expect(status.textContent).toContain('Distribución completa'); + expect(status.closest('.panel-controls')).toBeTruthy(); + select({ parent: 'G2', period: '2025-S2' }); + expect(fixture.nativeElement.querySelector('.selection-status')).toBe(status); + expect(status.textContent).toContain('Selección activa'); + expect(status.getAttribute('aria-label')).toContain('denominador de la distribución completa'); + expect(fixture.nativeElement.querySelectorAll('.distribution-note')).toHaveLength(0); + expect(plot.style.getPropertyValue('--plot-height')).toBe(height); + select({}); + expect(status.textContent).toContain('Distribución completa'); + expect(fixture.nativeElement.querySelector('app-plotly-chart')).toBe(plot); + http.expectNone(() => true); + }); + it('el estado compacto general no describe una distribución estratificada ni oculta su error', () => { + fixture.componentRef.setInput('indicador', { ...item, filtros: [ + { estrato: 'grupo_edad', etiqueta: 'Edad', valores: [{ valor: 'adulto', etiqueta: 'Adulto' }] }, + ] }); + load(); select({ parent: 'G2', period: '2025-S2' }); + panel().chooseStratified(); request().flush({}, { status: 500, statusText: 'Failure' }); fixture.detectChanges(); + expect(fixture.nativeElement.querySelector('.selection-status')).toBeNull(); + expect(fixture.nativeElement.querySelector('[role="alert"]')).toBeTruthy(); + expect(panel().result().status).toBe('error'); + http.expectNone(() => true); + }); it('una selección recibida mientras carga se aplica al terminar sin otro GET', () => { fixture.detectChanges(); const pending = request(); select({ parent: 'G2', period: '2025-S2' }); pending.flush(c2Fixture()); fixture.detectChanges(); expect(displayed().data[0]['y']).toEqual(['B', 'C']); http.expectNone(() => true); diff --git a/src/app/features/indicadores/indicadores-navigation.spec.ts b/src/app/features/indicadores/indicadores-navigation.spec.ts index c2cb052..60a662a 100644 --- a/src/app/features/indicadores/indicadores-navigation.spec.ts +++ b/src/app/features/indicadores/indicadores-navigation.spec.ts @@ -44,28 +44,7 @@ describe('UX-04 navegación Angular', () => { const harness = await setup(); await harness.navigateByUrl('/indicadores/' + domain, IndicadoresPage); load(domain, harness); harness.detectChanges(); - const links = Array.from(harness.routeNativeElement!.querySelectorAll('nav a')) as HTMLAnchorElement[]; - expect(links.map(a => a.textContent?.trim())).toEqual(['TEA', 'CaCu', 'CaMa']); - expect(links.map(a => a.getAttribute('href'))).toEqual(['/indicadores/tea', '/indicadores/cacu', '/indicadores/cama']); - const selected = links.find(a => a.getAttribute('aria-current') === 'page')!; - expect(selected.getAttribute('href')).toBe('/indicadores/' + domain); - expect(links.filter(a => a.hasAttribute('aria-current'))).toHaveLength(1); - // Check the compiled CSSOM rule against the actual encapsulated element. - // jsdom's computed link decoration can remain stale after aria-current changes. - const activeRule = Array.from(document.styleSheets).flatMap(sheet => Array.from(sheet.cssRules)) - .find((rule): rule is CSSStyleRule => rule instanceof CSSStyleRule - && rule.selectorText.includes('[aria-current=') && selected.matches(rule.selectorText))!; - expect(activeRule).toBeTruthy(); - expect(activeRule.style.getPropertyValue('text-decoration')).toBe('none'); - expect(activeRule.style.getPropertyValue('font-weight')).toBe('700'); - expect(activeRule.style.getPropertyValue('background')).toBe('var(--issste-accent)'); - for (const link of links) { - expect(link.tabIndex).toBe(0); - link.focus(); expect(document.activeElement).toBe(link); - const key = new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true }); - link.dispatchEvent(key); expect(key.defaultPrevented).toBe(false); - expect(selected.getAttribute('aria-current')).toBe('page'); - } + expect(harness.routeNativeElement!.querySelector('nav')).toBeNull(); http.expectNone(() => true); }); it('mantiene la ruta, restaura borradores y reconsulta la aplicación entre TEA/CaCu/CaMa', async () => { diff --git a/src/app/features/indicadores/indicadores-page.html b/src/app/features/indicadores/indicadores-page.html index db3cb6b..33124c2 100644 --- a/src/app/features/indicadores/indicadores-page.html +++ b/src/app/features/indicadores/indicadores-page.html @@ -4,12 +4,6 @@

Dashboard de indicadores

Explora las figuras de indicadores {{ domainLabels[dominio] }} generadas por el servicio de reportes.

- -
@for (section of sections; track section.id) {