Kit exit: TEA over FHIR, dashboard-test presentation merged in #9
@@ -33,13 +33,15 @@ import { parTiempos } from './indicadores-tiempos-pareados';
|
||||
<h2 [id]="titleId" tabindex="-1">{{ indicador.titulo }}</h2>
|
||||
</div>
|
||||
</header>
|
||||
<button class="pin-toggle" mat-button type="button" [attr.aria-pressed]="pinned"
|
||||
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + indicador.titulo"
|
||||
(click)="pinChanged.emit()">
|
||||
<mat-icon aria-hidden="true">push_pin</mat-icon>{{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }}
|
||||
</button>
|
||||
@if (!sobrio) {
|
||||
<button class="pin-toggle" mat-button type="button" [attr.aria-pressed]="pinned"
|
||||
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + indicador.titulo"
|
||||
(click)="pinChanged.emit()">
|
||||
<mat-icon aria-hidden="true">push_pin</mat-icon>{{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }}
|
||||
</button>
|
||||
}
|
||||
<div class="catalog-content" [id]="contentId" [attr.aria-labelledby]="titleId">
|
||||
<p class="catalog-metadata">{{ indicador.figuras.length }} figuras publicadas</p>
|
||||
@if (!sobrio) { <p class="catalog-metadata">{{ indicador.figuras.length }} figuras publicadas</p> }
|
||||
@if (isEu7) {
|
||||
<div #visibilityRegion class="eu7-region">
|
||||
<app-indicador-eu7-escenario [dominio]="dominio" [indicador]="indicador" [tema]="tema" [applied]="applied" [visible]="visible" [metadata]="metadata" (metadataRequested)="loadMetadata()" />
|
||||
@@ -53,7 +55,7 @@ import { parTiempos } from './indicadores-tiempos-pareados';
|
||||
<app-indicador-tiempos-pareados [dominio]="dominio" [par]="par" [indicador]="indicador" [tema]="tema" [applied]="applied" [visible]="visible" [metadata]="metadata" (metadataRequested)="loadMetadata()" />
|
||||
</div>
|
||||
} @else if (selectedFigure) {
|
||||
@if (!pair.length || otherFigures.length) {
|
||||
@if (!sobrio && (!pair.length || otherFigures.length)) {
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-label>Representación gráfica</mat-label>
|
||||
<mat-select [value]="selectedFigure" [disabled]="indicador.figuras.length === 1"
|
||||
@@ -131,6 +133,8 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
|
||||
if (this.indicador && this.applied) untracked(() => this.updateNumeric());
|
||||
});
|
||||
}
|
||||
// CaMa's cards carry no pin, representation selector or figure count, as in the mockup.
|
||||
get sobrio() { return this.dominio === 'cama'; }
|
||||
get pair() { return dualFigures(this.indicador); }
|
||||
get isEu7() { return this.dominio === 'cacu' && this.indicador.id === 'cacu_eu7'; }
|
||||
get isConfirmacion() { return this.dominio === 'cacu' && this.indicador.id === ID_CONFIRMACION; }
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// Covers the clinical section of CaMa's summary: its heading and counter, and the controls the mockup does not
|
||||
// have (search, pins, floating navigation, representation selector, figure count), which CaCu and TEA keep.
|
||||
// Fixtures are catalogs shaped like /<dominio>/indicadores; no figure is requested (the cards stay out of view).
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { IndicadoresPage } from './indicadores-page';
|
||||
import { IndicadoresMemory } from './indicadores-memory';
|
||||
import { Dominio } from './indicadores.models';
|
||||
|
||||
const item = (id: string, titulo: string, contrato: string, figuras: string[]) => ({ id, titulo, contrato, figuras, tipos_periodo: ['semestre', 'mes'] });
|
||||
// The catalog 18080 publishes for CaMa.
|
||||
const CAMA = [
|
||||
item('cama_biopsias', 'Distribución de resultados de biopsia', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_birads_456_mastografia', 'Porcentaje individual de mastografías', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_birads_456_paciente', 'Porcentaje de pacientes con resultados de BI-RADS 4, 5 y 6', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_confirmacion_birads45', 'Tasa de confirmación histopatológica', 'C1', ['fig_c1_puntos']),
|
||||
item('cama_dias_toma_diagnostico', 'Tiempo de tamizaje a diagnóstico', 'C3r', ['fig_c3r_caja']),
|
||||
item('cama_eu38a', 'Días de la toma de la mastografía a su resultado', 'C3r', ['fig_c3r_caja']),
|
||||
];
|
||||
const OTRO = (prefijo: string) => ['a', 'b', 'c', 'd', 'e', 'f'].map(letra => item(`${prefijo}_${letra}`, `Indicador ${letra}`, 'C2', ['f', 'g']));
|
||||
|
||||
describe('Resumen clínico de CaMa y los demás dominios', () => {
|
||||
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController;
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('IntersectionObserver', class { observe() {} unobserve() {} disconnect() {} });
|
||||
TestBed.configureTestingModule({ imports: [IndicadoresPage], providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting()] });
|
||||
for (const domain of ['tea', 'cacu', 'cama'] as const) TestBed.inject(IndicadoresMemory).finishInitialKpiPresentation(domain);
|
||||
fixture = TestBed.createComponent(IndicadoresPage); http = TestBed.inject(HttpTestingController);
|
||||
http.expectOne('/tea/indicadores').flush([]); fixture.detectChanges();
|
||||
});
|
||||
// The KPI and period requests are not what these tests are about.
|
||||
afterEach(() => { fixture.destroy(); http.match(() => true); http.verify(); vi.unstubAllGlobals(); });
|
||||
function open(domain: Dominio, catalog: unknown[]) {
|
||||
// The page starts in TEA, whose catalog is already answered: leave it first to load it again.
|
||||
if (domain === fixture.componentInstance.dominio) {
|
||||
fixture.componentInstance.changeDominio(domain === 'cacu' ? 'cama' : 'cacu'); fixture.detectChanges();
|
||||
http.match(() => true);
|
||||
}
|
||||
fixture.componentInstance.changeDominio(domain); fixture.detectChanges();
|
||||
http.expectOne('/' + domain + '/indicadores').flush(catalog); fixture.detectChanges();
|
||||
http.match(() => true); fixture.detectChanges();
|
||||
}
|
||||
const root = () => fixture.nativeElement as HTMLElement;
|
||||
const section = () => root().querySelector('.graphic-section') as HTMLElement;
|
||||
const titles = () => [...root().querySelectorAll('.catalog-grid app-indicador-catalog-card h2')].map(e => e.textContent?.trim());
|
||||
|
||||
it('CaMa: «Indicadores clínicos» y un contador que cuenta lo que la sección muestra', () => {
|
||||
// Fails if the heading or the counter go back to the whole catalog (6) while a card is not drawn.
|
||||
open('cama', CAMA);
|
||||
expect(root().querySelector('#graphic-section-title')?.textContent).toBe('Indicadores clínicos');
|
||||
expect(titles()).not.toContain('Distribución de resultados de biopsia');
|
||||
expect(root().querySelector('.catalog-count')?.textContent?.trim()).toBe(titles().length + ' indicadores publicados');
|
||||
});
|
||||
it('CaMa: sin buscador, indicadores fijados, navegación flotante, selector de representación ni conteo de figuras', () => {
|
||||
// Fails if any of the controls the mockup does not have comes back to CaMa's summary.
|
||||
open('cama', CAMA);
|
||||
expect(root().querySelector('.catalog-search')).toBeNull();
|
||||
expect(section().textContent).not.toContain('Buscar indicadores');
|
||||
expect(root().querySelector('.pin-toggle')).toBeNull();
|
||||
expect(section().textContent).not.toContain('Fijar indicador');
|
||||
expect(root().querySelector('.graphic-navigation-trigger')).toBeNull();
|
||||
expect(section().querySelector('mat-form-field')).toBeNull();
|
||||
expect(section().textContent).not.toContain('Representación gráfica');
|
||||
expect(section().textContent).not.toContain('figuras publicadas');
|
||||
});
|
||||
it('CaMa: las figuras guardadas como fijadas no reordenan las tarjetas', () => {
|
||||
// Fails if a pin saved earlier (the control is gone) still changes the order of CaMa's cards.
|
||||
open('cama', CAMA);
|
||||
const before = titles();
|
||||
fixture.componentInstance.togglePinned(CAMA[5] as never); fixture.detectChanges();
|
||||
expect(titles()).toEqual(before);
|
||||
});
|
||||
it.each(['tea', 'cacu'] as const)('%s conserva buscador, fijados, navegación flotante, selector y conteo de figuras', domain => {
|
||||
// Fails if CaMa's simplified section leaks into the other domains.
|
||||
open(domain, OTRO(domain));
|
||||
expect(root().querySelector('.catalog-search')).not.toBeNull();
|
||||
expect(root().querySelectorAll('.pin-toggle').length).toBe(6);
|
||||
expect(root().querySelector('.graphic-navigation-trigger')).not.toBeNull();
|
||||
expect(section().querySelector('app-indicador-catalog-card mat-form-field')).not.toBeNull();
|
||||
expect(section().textContent).toContain('2 figuras publicadas');
|
||||
expect(root().querySelector('.catalog-count')?.textContent?.trim()).toBe('6 indicadores publicados');
|
||||
});
|
||||
it('CaCu conserva su encabezado «Indicadores clínicos» y TEA «Indicadores gráficos»', () => {
|
||||
open('cacu', OTRO('cacu'));
|
||||
expect(root().querySelector('#graphic-section-title')?.textContent).toBe('Indicadores clínicos');
|
||||
open('tea', OTRO('tea'));
|
||||
expect(root().querySelector('#graphic-section-title')?.textContent).toBe('Indicadores gráficos');
|
||||
});
|
||||
});
|
||||
@@ -65,7 +65,8 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => {
|
||||
}
|
||||
function expectNoFigureRequests() { http.expectNone(request => request.url.includes('/figuras/') || request.url.endsWith('/datos')); }
|
||||
|
||||
it.each(['tea', 'cacu', 'cama'] as const)('aparece solo en Resumen para el dominio %s', async domain => {
|
||||
// CaMa follows the mockup and has no floating navigation (indicadores-cama-resumen-clinico.spec.ts).
|
||||
it.each(['tea', 'cacu'] as const)('aparece solo en Resumen para el dominio %s', async domain => {
|
||||
await load([item('chart', 'Indicador gráfico')], domain);
|
||||
expect(trigger()).not.toBeNull();
|
||||
page.changeSection('seguimiento'); fixture.detectChanges();
|
||||
@@ -160,7 +161,7 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => {
|
||||
|
||||
it('mantiene keys únicas para títulos duplicados y navega a la tarjeta elegida', async () => {
|
||||
const items = [item('duplicate-a', 'Resultado clínico'), item('duplicate-b', 'Resultado clínico')];
|
||||
await load(items, 'cama');
|
||||
await load(items, 'cacu');
|
||||
const scroll = vi.fn();
|
||||
const focus = vi.spyOn(HTMLElement.prototype, 'focus');
|
||||
for (const card of fixture.nativeElement.querySelectorAll('app-indicador-catalog-card')) {
|
||||
@@ -173,7 +174,7 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const targetId = identityElementId(indicatorIdentity('cama', 'duplicate-b'));
|
||||
const targetId = identityElementId(indicatorIdentity('cacu', 'duplicate-b'));
|
||||
expect(scroll).toHaveBeenCalledOnce();
|
||||
expect(scroll.mock.instances[0]).toBe(fixture.nativeElement.querySelector('#' + targetId));
|
||||
expect(focus).toHaveBeenCalled();
|
||||
@@ -394,8 +395,8 @@ describe('UX-10 navegación lateral del catálogo gráfico', () => {
|
||||
vi.advanceTimersByTime(500);
|
||||
expect(page.navigationOpen()).toBe(true);
|
||||
pointer(trigger()!, 'pointerleave');
|
||||
page.changeDominio('cama');
|
||||
http.expectOne('/cama/indicadores').flush([item('b', 'CaMa')]); fixture.detectChanges();
|
||||
page.changeDominio('cacu');
|
||||
http.expectOne('/cacu/indicadores').flush([item('b', 'CaCu')]); fixture.detectChanges();
|
||||
expect(page.navigationAttached()).toBe(false);
|
||||
pointer(trigger()!, 'pointerenter');
|
||||
vi.advanceTimersByTime(500);
|
||||
|
||||
@@ -97,9 +97,9 @@
|
||||
|
||||
<section class="graphic-section" aria-labelledby="graphic-section-title">
|
||||
<div class="catalog-heading">
|
||||
<h2 id="graphic-section-title" class="section-title">{{ dominio === 'cacu' ? 'Indicadores clínicos' : 'Indicadores gráficos' }}</h2>
|
||||
<h2 id="graphic-section-title" class="section-title">{{ dominio === 'cacu' || dominio === 'cama' ? 'Indicadores clínicos' : 'Indicadores gráficos' }}</h2>
|
||||
@if (!catalogLoading() && !catalogError() && catalog().length) {
|
||||
<p class="catalog-count" role="status">{{ catalog().length }} indicadores publicados</p>
|
||||
<p class="catalog-count" role="status">{{ shownIndicators }} indicadores publicados</p>
|
||||
}
|
||||
</div>
|
||||
@if (catalogLoading()) {
|
||||
|
||||
@@ -289,6 +289,8 @@ export class IndicadoresPage {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
// How many indicators the graphic section shows: all the catalog, except in CaMa, which draws only some of them.
|
||||
get shownIndicators() { return this.dominio === 'cama' ? this.searchResults().items.length : this.catalog().length; }
|
||||
get availableKpis() { return this.kpisByDomain[this.dominio].filter(definition => this.catalog().some(item => item.id === definition.id)); }
|
||||
get opportunityKpis() {
|
||||
const definitions = this.availableKpis;
|
||||
@@ -306,13 +308,15 @@ export class IndicadoresPage {
|
||||
private readonly catalogRequests = new Subject<void>();
|
||||
readonly catalog = signal<Indicador[]>([]);
|
||||
readonly searchQuery = signal('');
|
||||
readonly searchVisible = computed(() => this.catalog().length >= 5);
|
||||
// CaMa follows the mockup: no search box and no pins; its cards are the ones the summary draws.
|
||||
readonly searchVisible = computed(() => this.dominio !== 'cama' && this.catalog().length >= 5);
|
||||
readonly searchResults = computed(() => {
|
||||
const catalog = this.catalog();
|
||||
// Stable presentation priority; search matches and pins still take precedence.
|
||||
const items = this.dominio === 'cacu'
|
||||
? [...catalog.filter(item => item.id === 'cacu_eu7'), ...catalog.filter(item => item.id !== 'cacu_eu7')]
|
||||
: this.dominio === 'cama' ? catalog.filter(item => !CAMA_FUERA_DEL_RESUMEN.includes(item.id)) : catalog;
|
||||
if (this.dominio === 'cama') return { items, active: false, count: 0 };
|
||||
const query = this.normalizeSearch(this.searchQuery());
|
||||
const prioritize = (group: Indicador[]) => [
|
||||
...group.filter(item => this.isPinned(item)),
|
||||
@@ -360,7 +364,7 @@ export class IndicadoresPage {
|
||||
cardIdentity(item: Indicador) { return indicatorIdentity(this.dominio, item.id); }
|
||||
cardElementId(item: Indicador) { return identityElementId(this.cardIdentity(item)); }
|
||||
get showGraphicNavigation() {
|
||||
return this.activeSection() === 'resumen' && !this.fichaPacienteAbierta() && !this.catalogLoading()
|
||||
return this.dominio !== 'cama' && this.activeSection() === 'resumen' && !this.fichaPacienteAbierta() && !this.catalogLoading()
|
||||
&& !this.catalogError() && !this.initialPeriodBlocked && this.navigationItems().length > 0;
|
||||
}
|
||||
toggleGraphicNavigation(event?: MouseEvent) {
|
||||
|
||||
@@ -85,8 +85,9 @@ describe('UX-06E.D.3.B fijación temporal', () => {
|
||||
});
|
||||
it('memoria independiente por dominio y persistente al recrear la página', async () => {
|
||||
await pin('i3'); page.changeDominio('cacu'); load('cacu'); expect(ids()).toEqual(items.map(i => i.id));
|
||||
// CaMa has no pin control (the mockup has none), so it neither keeps nor applies pins.
|
||||
await pin('i1'); page.changeDominio('cama'); load('cama'); expect(ids()).toEqual(items.map(i => i.id));
|
||||
await pin('i4'); page.changeDominio('cacu'); load('cacu'); expect(ids()[0]).toBe('i1');
|
||||
page.changeDominio('cacu'); load('cacu'); expect(ids()[0]).toBe('i1');
|
||||
page.changeDominio('tea'); load(); expect(ids()[0]).toBe('i3');
|
||||
fixture.destroy(); create(); load(); expect(ids()[0]).toBe('i3'); http.expectNone(() => true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user