Gobernanza preview saved as PDF; Playwright TEA page tests

- 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.
This commit is contained in:
2026-11-30 19:17:46 -06:00
parent b847e04697
commit b291885b97
14 changed files with 419 additions and 113 deletions
+13 -5
View File
@@ -1,3 +1,4 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, inject, input, model, output, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
@@ -22,6 +23,17 @@ export async function verifiedImport<T>(
return upload(sha256);
}
export async function exportErrorText(error: unknown): Promise<string> {
if (!(error instanceof HttpErrorResponse && error.error instanceof Blob)) return errorText(error);
const text = await error.error.text();
try {
const detail = JSON.parse(text).detail;
return typeof detail === 'string' ? detail : text;
} catch {
return text;
}
}
export function download(blob: Blob, filename: string): void {
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
@@ -92,11 +104,7 @@ export class Bundles {
this.exportedHash.set(sha256);
download(response.body, `${domain}-models-${sha256.slice(0, 12)}.zip`);
} catch (error) {
if (error instanceof Error && 'error' in error && error.error instanceof Blob) {
this.message.set(await error.error.text());
} else {
this.message.set(errorText(error));
}
this.message.set(await exportErrorText(error));
} finally {
this.exporting.set(false);
}