b291885b97
- The EEG preview dialog gets "Guardar como PDF": previewPdfContent is a
pure function (verdict, checks, metrics with scores per electrode and
zone, ADOS-2 classification/CSS and items by their Core titles,
warnings), downloadPreviewPdf a thin wrapper over export/pdf; the file
is tea-gobernanza-<day>.pdf. Unit-tested without mocks.
- e2e/pages.spec.ts now holds only the TEA page tests (the CaCu/CaMa
cases needed fixtures P7 removed): every indicator tab, the follow-up
xlsx export, the patient record and risk page with their PDFs, and
every Gobernanza section in sync mode including the preview PDF. Each
download is checked for a file and a name without a record number.
- Fixes the page tests found: the TEA xlsx name ('seguimiento-tea') failed
validateName, so the export always threw; it is now tea-<page>-<day>.
ng serve crashed on every Plotly page (has-hover reads 'global'): the
build defines global as globalThis. Record numbers repeated once per
source identifier; they are deduplicated. A refused bundle export showed
'{}': the blob error body is now read for the API's detail.
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
import { HttpErrorResponse } from '@angular/common/http';
|
|
import { exportErrorText, verifiedImport } from './bundles';
|
|
|
|
const hash = 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad';
|
|
|
|
describe('bundle import', () => {
|
|
beforeEach(() => {
|
|
const bytes = Uint8Array.from(hash.match(/../g)!, (hex) => parseInt(hex, 16));
|
|
vi.stubGlobal('crypto', { subtle: { digest: vi.fn().mockResolvedValue(bytes.buffer) } });
|
|
});
|
|
|
|
afterEach(() => vi.unstubAllGlobals());
|
|
|
|
it('refuses to upload a file with a different SHA-256', async () => {
|
|
const file = new Blob([new Uint8Array([97, 98, 99])]);
|
|
const upload = vi.fn();
|
|
await expect(verifiedImport(file, '0'.repeat(64), upload)).rejects.toThrow('no coincide');
|
|
expect(upload).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('submits the verified digest', async () => {
|
|
const file = new Blob([new Uint8Array([97, 98, 99])]);
|
|
const upload = vi.fn().mockResolvedValue({ run_id: 'run-1' });
|
|
await expect(verifiedImport(file, hash.toUpperCase(), upload)).resolves.toEqual({
|
|
run_id: 'run-1',
|
|
});
|
|
expect(upload).toHaveBeenCalledExactlyOnceWith(hash);
|
|
});
|
|
});
|
|
|
|
describe('bundle export', () => {
|
|
const failed = (body: string) =>
|
|
new HttpErrorResponse({ status: 409, error: new Blob([body], { type: 'application/json' }) });
|
|
|
|
it("shows the API's detail from a blob error body", async () => {
|
|
await expect(
|
|
exportErrorText(failed('{"detail":"nothing to export: no version selected"}')),
|
|
).resolves.toBe('nothing to export: no version selected');
|
|
});
|
|
|
|
it('shows a body that is not JSON as it came', async () => {
|
|
await expect(exportErrorText(failed('Bad gateway'))).resolves.toBe('Bad gateway');
|
|
});
|
|
});
|