Files
HealthLog/src/components/documents/__tests__/use-document-upload-settle.test.ts
T
Marc-André Bombeck 542ca91be5 Finish the wiring polish: verbosity gate, upload flash, /about links, dead settings slugs
- The Coach verbosity picker is disabled while the concise tone forces
  brief, with a hint saying so, instead of a live control that silently
  does nothing.
- A fresh document upload flashes its new row like the duplicate path
  always did; the settle decision is a pure exported helper with a test.
- /about gains its two inbound links: the /privacy footer and a
  Settings→About credits row (the GeoLite2 EULA wants the attribution
  reachable from the running app).
- The eight settings slugs shadowed by permanent redirects (the seven
  layout children + sharing) leave the slug registry: no more
  prerendering unreachable pages, no dead component wirings, and the
  SectionPlaceholder fallback that could never render is gone. The
  redirects, section components, and layout-hub subpages are unchanged.
2026-08-14 05:31:33 +02:00

45 lines
1.4 KiB
TypeScript

/**
* The upload manager's settle decision (§3.2 + the fresh-upload flash).
*
* Watched red: with `settleDecision` returning `flashId: null` on the
* non-duplicate branch (the pre-v1.37.19 behaviour — only the duplicate
* path flashed the row), the fresh-upload case below fails. A fresh upload
* used to give no feedback beyond its queue row disappearing.
*/
import { describe, expect, it } from "vitest";
import { settleDecision } from "../use-document-upload";
import type { UploadResult } from "../vault-utils";
function success(duplicate: boolean): UploadResult {
return {
ok: true,
duplicate,
document: { id: "doc-1" },
} as unknown as UploadResult;
}
describe("settleDecision", () => {
it("flashes the NEW row on a fresh upload (no toast)", () => {
expect(settleDecision(success(false))).toEqual({
removeFromQueue: true,
toastDuplicate: false,
flashId: "doc-1",
});
});
it("flashes the EXISTING row and toasts on a duplicate", () => {
expect(settleDecision(success(true))).toEqual({
removeFromQueue: true,
toastDuplicate: true,
flashId: "doc-1",
});
});
it("keeps a failed upload in the queue with no flash", () => {
expect(
settleDecision({ ok: false, reason: "generic" } as UploadResult),
).toEqual({ removeFromQueue: false, toastDuplicate: false, flashId: null });
});
});