All files / src/pages/flowsheet-page/dynamics/results-panel/components ResultStatusMessage.tsx

83.33% Statements 30/36
42.42% Branches 14/33
75% Functions 3/4
95% Lines 19/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72              15x   15x                 15x       8x                     8x       1x         2x 2x 2x 1x                 2x 1x 1x         2x 3x 1x 1x     2x 3x      
import { Spinner } from "@/ahuora-design-system/ui/spinner";
import {
  isResultSummaryFailed,
  isResultSummaryPartial,
  type ResultSummaryStatusPayload,
} from "../utils/resultSummaryStatus";
 
export function ResultLoadingMessage() {
  return (
    <div
      aria-live="polite"
      className="col-span-full rounded-md border border-dashed p-4"
      role="status"
    >
      <div className="flex items-center gap-3">
        <Spinner size="small" />
        <p className="text-sm font-medium">Loading result data.</p>
      </div>
    </div>
  );
}
 
export function ResultEmptyMessage() {
  return (
    <div
      aria-live="polite"
      className="col-span-full rounded-md border border-dashed p-4"
      role="status"
    >
      <p className="text-sm font-medium">No result data is available.</p>
      <p className="mt-1 text-sm text-muted-foreground">
        The selected object did not produce result values for this scenario.
      </p>
    </div>
  );
}
 
export function ResultSummaryStatusMessage({
  status,
}: {
  status: ResultSummaryStatusPayload;
}) {
  const isFailed = isResultSummaryFailed(status);
  const isPartial = isResultSummaryPartial(status);
  const firstError = status.errors?.find((error) => error.message)?.message;
  const isProcessing = !isFailed && !isPartial;
 
  return (
    <div
      aria-live="polite"
      className="col-span-full rounded-md border border-dashed p-4"
      role="status"
    >
      <div className="flex items-center gap-3">
        {isProcessing && <Spinner size="small" />}
        <p className="text-sm font-medium">
          {isPartial
            ? "Some aggregate results could not be calculated."
            : isFailed
              ? "Aggregate results could not be calculated."
              : "Processing aggregate results."}
        </p>
      </div>
      <p className="mt-1 text-sm text-muted-foreground">
        {isFailed || isPartial
          ? (firstError ?? "Open the solver logs for more detail.")
          : "The solve has finished; charts and summary metrics will appear when post-processing completes."}
      </p>
    </div>
  );
}