Gobernanza: view the results of one EDF and its ADOS-2 report without storing them, with Guardar como PDF
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/** Pins the preview dialog: it shows the unsaved notice and the server's notices, and prints only itself.
|
||||
* Fixtures: a minimal summary without ADOS-2 or EEG, so the shared record view renders its empty states. */
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { EegPreviewDialog, PRINT_CLASS } from './eeg-preview-dialog';
|
||||
|
||||
function create() {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [provideHttpClient(), provideHttpClientTesting(), {
|
||||
provide: MAT_DIALOG_DATA,
|
||||
useValue: { archivo: 'estudio.edf', avisos: ['No se pudo leer el ADOS-2 del PDF.'],
|
||||
detalle: { simulado: true, id_seudonimo: 'vista-previa', grupo_edad: '', ados2: null, eeg: null } },
|
||||
}],
|
||||
});
|
||||
const fixture = TestBed.createComponent(EegPreviewDialog);
|
||||
fixture.detectChanges();
|
||||
return fixture;
|
||||
}
|
||||
|
||||
describe('EegPreviewDialog', () => {
|
||||
/** Fails if the dialog stops saying the analysis was not stored, hides a server notice, or asks the server for the record. */
|
||||
it('says nothing was saved and lists the notices without requesting a patient', () => {
|
||||
const text = create().nativeElement.textContent as string;
|
||||
expect(text).toContain('estudio.edf');
|
||||
expect(text).toContain('No se guardó en la base de datos');
|
||||
expect(text).toContain('No se pudo leer el ADOS-2 del PDF.');
|
||||
expect(text).toContain('Sin evaluación ADOS-2 registrada.');
|
||||
});
|
||||
|
||||
/** Fails if printing leaves the page marked after it ends, or never marks it, which would print the whole app. */
|
||||
it('marks the page for printing and clears it afterwards', async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const fixture = create();
|
||||
const view = TestBed.inject(DOCUMENT).defaultView!;
|
||||
const print = vi.spyOn(view, 'print').mockImplementation(() => undefined);
|
||||
const pending = fixture.componentInstance.savePdf();
|
||||
expect(TestBed.inject(DOCUMENT).body.classList.contains(PRINT_CLASS)).toBe(true);
|
||||
await vi.advanceTimersByTimeAsync(600);
|
||||
await pending;
|
||||
expect(print).toHaveBeenCalledOnce();
|
||||
view.dispatchEvent(new Event('afterprint'));
|
||||
expect(TestBed.inject(DOCUMENT).body.classList.contains(PRINT_CLASS)).toBe(false);
|
||||
} finally { vi.useRealTimers(); }
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user