feat(indicadores): add the Histórico tab to CaCu
CaCu's history is a fixed list, like CaMa's, with a pending panel for each indicator the catalog does not publish. The risk bands stay out until their batches are readable.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// Covers CaCu's history tab: its fixed list of indicators, in order, with a pending panel for each one the catalog
|
||||
// does not publish. Catalogs are synthetic, shaped like /cacu/indicadores; the tab stays inactive, so nothing is
|
||||
// requested.
|
||||
import { Component } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
||||
import { HISTORICO_CACU, IndicadoresHistorico } from './indicadores-historico';
|
||||
import { Indicador } from './indicadores.models';
|
||||
|
||||
@Component({ selector: 'app-plotly-chart', inputs: ['figure', 'label', 'showNotes'], template: '' })
|
||||
class ChartStub {}
|
||||
|
||||
const item = (id: string, contrato: string): Indicador => ({ id, titulo: id, contrato, figuras: [], tipos_periodo: ['semestre', 'mes'] }) as unknown as Indicador;
|
||||
|
||||
describe('Histórico de CaCu', () => {
|
||||
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresHistorico>>, http: HttpTestingController;
|
||||
function montar(catalog: Indicador[]) {
|
||||
TestBed.configureTestingModule({ imports: [IndicadoresHistorico], providers: [provideHttpClient(), provideHttpClientTesting(), { provide: MatDialog, useValue: { open: vi.fn() } }] });
|
||||
TestBed.overrideComponent(IndicadoresHistorico, { remove: { imports: [PlotlyChart] }, add: { imports: [ChartStub] } });
|
||||
fixture = TestBed.createComponent(IndicadoresHistorico); http = TestBed.inject(HttpTestingController);
|
||||
fixture.componentRef.setInput('dominio', 'cacu'); fixture.componentRef.setInput('catalog', catalog);
|
||||
fixture.componentRef.setInput('tema', 'claro'); fixture.componentRef.setInput('active', false);
|
||||
fixture.detectChanges();
|
||||
}
|
||||
afterEach(() => { fixture?.destroy(); http.match(() => true); http.verify(); });
|
||||
const paneles = () => [...(fixture.nativeElement as HTMLElement).querySelectorAll('article.panel')] as HTMLElement[];
|
||||
|
||||
it('lista los seis indicadores en orden y deja pendientes los que el catálogo no publica', () => {
|
||||
// Pins down: the tab shows the fixed list, not the whole catalog, so the risk bands stay out and an indicator
|
||||
// the catalog lacks keeps its place as a pending panel. Fails if the list changes, or the catalog's order or
|
||||
// extra measures leak into the tab.
|
||||
montar([item('cacu_riesgo_banda', 'C2'), item('cacu_ind1', 'C1'), item('cacu_eu13', 'C1')]);
|
||||
expect(paneles().map(p => p.querySelector('h2')?.textContent)).toEqual(HISTORICO_CACU.map(e => e.titulo));
|
||||
const pendientes = paneles().filter(p => p.textContent!.includes('Integración pendiente')).map(p => p.querySelector('h2')!.textContent);
|
||||
expect(pendientes).toEqual(['Distribución de resultados citológicos', 'Tasa de confirmación histopatológica',
|
||||
'Días de la toma de la citología a su resultado', 'Tiempo de tamizaje a diagnóstico']);
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
// Covers the history tab in the page: it exists for CaMa only, sits between Resumen and Seguimiento, and its
|
||||
// Covers the history tab in the page: it exists for TEA, CaMa and CaCu, sits between Resumen and Seguimiento, and its
|
||||
// panel loads nothing until it is opened. Catalogs are synthetic, shaped like /<dominio>/indicadores.
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
@@ -38,12 +38,13 @@ describe('Pestaña Histórico', () => {
|
||||
expect(root().querySelector('#panel-analisis')).toBeNull();
|
||||
http.expectNone(request => request.url.startsWith('/cama/analisis'));
|
||||
});
|
||||
it('cacu no tiene la pestaña Histórico', () => {
|
||||
// Fails if the history tab of TEA or CaMa leaks into CaCu.
|
||||
it('cacu tiene Histórico pero no Análisis epidemiológico', () => {
|
||||
// Fails if CaCu loses its history tab or gains CaMa's analysis tab.
|
||||
abrir('cama', []);
|
||||
abrir('cacu', [item('cacu_x', 'C2')]);
|
||||
expect(tabs()).toEqual(['Resumen', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(root().querySelector('#panel-historico')).toBeNull();
|
||||
expect(tabs()).toEqual(['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(root().querySelector('#panel-historico')).not.toBeNull();
|
||||
expect(root().querySelector('#panel-analisis')).toBeNull();
|
||||
});
|
||||
it('tea tiene Histórico pero no Análisis epidemiológico', () => {
|
||||
abrir('cama', []);
|
||||
|
||||
@@ -36,6 +36,18 @@ export const HISTORICO_CAMA: readonly { id: string; titulo: string }[] = [
|
||||
{ id: 'cama_dias_resultado_diagnostico', titulo: 'Días del resultado de la mastografía al diagnóstico' },
|
||||
];
|
||||
|
||||
// CaCu's history, built like CaMa's: a fixed list, with the same pending panel for what the catalog does not publish.
|
||||
// The risk bands are left out until their batches are readable.
|
||||
export const HISTORICO_CACU: readonly { id: string; titulo: string }[] = [
|
||||
{ id: 'cacu_eu7', titulo: 'Distribución de resultados citológicos' },
|
||||
{ id: 'cacu_ind1', titulo: 'Pacientes con citología anómala' },
|
||||
{ id: 'cacu_eu13', titulo: 'Tasa de detección histopatológica' },
|
||||
{ id: 'cacu_confirmacion_citologia', titulo: 'Tasa de confirmación histopatológica' },
|
||||
{ id: 'cacu_eu_tiempo_reporte', titulo: 'Días de la toma de la citología a su resultado' },
|
||||
{ id: 'cacu_dias_toma_diagnostico', titulo: 'Tiempo de tamizaje a diagnóstico' },
|
||||
];
|
||||
const HISTORICO_FIJO: Readonly<Partial<Record<string, readonly { id: string; titulo: string }[]>>> = { cama: HISTORICO_CAMA, cacu: HISTORICO_CACU };
|
||||
|
||||
// The screening steps go together as small charts, and the case counts are followed by their in-process share.
|
||||
function agrupar(paneles: (Panel & { datos?: IndicadorDatos })[], tema: Tema): Panel[] {
|
||||
const pasos = TIEMPOS.map(id => paneles.find(p => p.item.id === id));
|
||||
@@ -171,9 +183,11 @@ export class IndicadoresHistorico {
|
||||
readonly catalog = input.required<readonly Indicador[]>();
|
||||
readonly tema = input.required<Tema>();
|
||||
readonly active = input(false);
|
||||
// The indicators the tab draws: CaMa's fixed list, where the catalog publishes it; the whole catalog elsewhere.
|
||||
private readonly publicados = computed(() => this.dominio() === 'cama'
|
||||
? HISTORICO_CAMA.flatMap(entrada => this.catalog().filter(item => item.id === entrada.id)) : this.catalog());
|
||||
// The indicators the tab draws: a domain's fixed list, where the catalog publishes it; the whole catalog elsewhere.
|
||||
private readonly publicados = computed(() => {
|
||||
const fijo = HISTORICO_FIJO[this.dominio()];
|
||||
return fijo ? fijo.flatMap(entrada => this.catalog().filter(item => item.id === entrada.id)) : this.catalog();
|
||||
});
|
||||
// Only the granularities some indicator publishes; monthly first when there is one.
|
||||
readonly tipos = computed(() => (['mes', 'semestre'] as const).filter(tipo => this.publicados().some(item => item.tipos_periodo.includes(tipo))));
|
||||
readonly elegido = signal<TipoPeriodo | undefined>(undefined);
|
||||
@@ -241,9 +255,10 @@ export class IndicadoresHistorico {
|
||||
return { item, rango, estado: 'error', mensaje: error instanceof Error ? error.message : 'Datos de histórico inválidos' };
|
||||
}
|
||||
};
|
||||
if (this.dominio() === 'cama') {
|
||||
const fijo = HISTORICO_FIJO[this.dominio()];
|
||||
if (fijo) {
|
||||
if (!this.publicados().length) return [];
|
||||
return HISTORICO_CAMA.map((entrada): Panel => {
|
||||
return fijo.map((entrada): Panel => {
|
||||
const item = this.catalog().find(i => i.id === entrada.id);
|
||||
return item ? { ...panelDe(item), item: { ...entrada, contrato: item.contrato } } : { item: entrada, estado: 'pendiente' };
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ const SECTIONS_CAMA: readonly { id: DashboardSection; label: string }[] = [
|
||||
})
|
||||
export class IndicadoresPage {
|
||||
get sections(): readonly { id: DashboardSection; label: string }[] { return this.dominio === 'cama' ? SECTIONS_CAMA : this.conHistorico ? SECTIONS_WITH_HISTORY : SECTIONS; }
|
||||
get conHistorico() { return this.dominio === 'tea' || this.dominio === 'cama'; }
|
||||
get conHistorico() { return this.dominio === 'tea' || this.dominio === 'cama' || this.dominio === 'cacu'; }
|
||||
get conAnalisis() { return CAMA_ANALYSIS_ENABLED && this.dominio === 'cama'; }
|
||||
readonly activeSection = signal<DashboardSection>('resumen');
|
||||
readonly fichaPacienteAbierta = signal(false);
|
||||
|
||||
@@ -163,7 +163,7 @@ describe('Recorrido de cáncer de mama: análisis, lista, ficha y regreso', () =
|
||||
http.expectOne('/' + dominio + '/indicadores').flush([]); await e.asentar();
|
||||
expect(e.page.seleccionSeguimiento()).toBeUndefined();
|
||||
expect(Array.from(e.root.querySelectorAll('[role="tab"]')).map(t => t.textContent?.trim())).toEqual(
|
||||
dominio === 'tea' ? ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'] : ['Resumen', 'Seguimiento', 'Datos y definiciones']);
|
||||
['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(e.root.querySelector('#panel-analisis')).toBeNull();
|
||||
}
|
||||
e.page.changeDominio('cama'); e.harness.detectChanges();
|
||||
|
||||
@@ -39,9 +39,9 @@ describe('Secciones compartidas por dominio', () => {
|
||||
http.expectOne('/' + domain + '/indicadores').flush(catalog); harness.detectChanges();
|
||||
const root = harness.routeNativeElement!;
|
||||
const tabs = Array.from(root.querySelectorAll<HTMLButtonElement>('[role="tab"]'));
|
||||
// TEA and CaMa also have Histórico; CaMa labels Seguimiento as Análisis de Riesgos; CaCu keeps its three.
|
||||
// TEA, CaMa and CaCu have Histórico; CaMa labels Seguimiento as Análisis de Riesgos.
|
||||
const esperadas = domain === 'cama' ? ['Resumen', 'Histórico', 'Análisis de Riesgos', 'Datos y definiciones']
|
||||
: domain === 'tea' ? ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'] : ['Resumen', 'Seguimiento', 'Datos y definiciones'];
|
||||
: ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'];
|
||||
expect(tabs.map(t => t.textContent?.trim())).toEqual(esperadas);
|
||||
expect(tabs.map(t => t.getAttribute('aria-selected'))).toEqual(esperadas.map((_, i) => String(i === 0)));
|
||||
const tab = (id: string) => tabs.find(t => t.id === 'tab-' + id)!;
|
||||
|
||||
Reference in New Issue
Block a user