import { describe, expect, it } from "vitest"; import { buildFileBrowserVM, type FileBrowserFilterState, type FileBrowserRow } from "../index.js"; const filter: FileBrowserFilterState = { entityType: null, mimeGroup: null, tags: [], assignedToUserId: null, includeArchived: false, }; const row: FileBrowserRow = { id: "f1", displayName: "foto.jpg", mimeType: "image/jpeg", sizeBytes: 2048, createdAtIso: "2026-06-19T08:00:00.000Z", tags: [], source: "manual_upload", previewStatus: "ready", scanStatus: "clean", thumbnailUrl: "/acme/media/f1/thumb", detailHref: "/acme/files/f1", linkedEntityLabelKey: null, }; describe("buildFileBrowserVM nextCursor default on the non-empty path (file-browser.ts:116)", () => { it("coerces a missing cursor to null when rows are present (last page)", () => { const vm = buildFileBrowserVM({ rows: [row], filter, canWrite: true, canDelete: false }); if (vm.status !== "ready") throw new Error("expected ready"); expect(vm.data.rows).toHaveLength(1); expect(vm.data.nextCursor).toBeNull(); }); it("coerces an explicit null cursor to null on the non-empty path", () => { const vm = buildFileBrowserVM({ rows: [row], filter, canWrite: true, canDelete: false, nextCursor: null }); if (vm.status !== "ready") throw new Error("expected ready"); expect(vm.data.nextCursor).toBeNull(); }); });