Agrupar las tarjetas de CaMa y elegir el periodo en Trazabilidad

This commit is contained in:
2026-12-03 22:21:59 -06:00
parent 84769cb0f4
commit 2a84eb56ca
12 changed files with 142 additions and 120 deletions
@@ -0,0 +1,51 @@
import { TestBed } from '@angular/core/testing';
import type { Measure } from 'fhir/r4';
import { Fhir } from '../fhir';
import { HISTORY } from './pages';
import { TabTrazabilidad } from './tab-trazabilidad';
describe('Trazabilidad: periodo seleccionado', () => {
for (const domain of ['cama', 'cacu']) {
it(`applies a monthly and semester period to the ${domain} queries`, async () => {
const requests: Record<string, string>[] = [];
await TestBed.configureTestingModule({
imports: [TabTrazabilidad],
providers: [
{
provide: Fhir,
useValue: {
all: async (_domain: string, _resource: string, params: Record<string, string>) => {
requests.push(params);
return [{ resourceType: 'Bundle', type: 'searchset', entry: [] }];
},
},
},
],
}).compileComponents();
const fixture = TestBed.createComponent(TabTrazabilidad);
fixture.componentRef.setInput('domain', domain);
fixture.componentRef.setInput('measures', [
{ resourceType: 'Measure', id: 'test', name: HISTORY[domain].panels[0].measure },
] as Measure[]);
fixture.detectChanges();
await fixture.whenStable();
const component = fixture.componentInstance as any;
component.chosen.set('2025-03');
fixture.detectChanges();
(fixture.nativeElement.querySelector('button[mat-flat-button]') as HTMLButtonElement).click();
fixture.detectChanges();
await fixture.whenStable();
expect(requests.at(-1)?.['reporting-period'].split(',').at(-1)).toBe('2025-03');
expect(requests.at(-1)?.['as-of']).toBeUndefined();
component.setType('semester');
fixture.detectChanges();
await fixture.whenStable();
component.chosen.set('2024-S1');
fixture.detectChanges();
(fixture.nativeElement.querySelector('button[mat-flat-button]') as HTMLButtonElement).click();
fixture.detectChanges();
await fixture.whenStable();
expect(requests.at(-1)?.['reporting-period'].split(',').at(-1)).toBe('2024-S1');
});
}
});