Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
+25
@@ -39,10 +39,30 @@ export interface FileBrowserFilterState {
|
||||
readonly includeArchived: boolean;
|
||||
}
|
||||
|
||||
/** A selectable assignee (Verantwortlicher) filter option. */
|
||||
export interface FileAssigneeOption {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The option lists that populate the browser filter dropdowns. Built once by the
|
||||
* loader (tenant-scoped) and passed in; the VM stays pure. `entityTypes` are raw
|
||||
* enum keys — the UI maps them to i18n labels.
|
||||
*/
|
||||
export interface FileBrowserFilterOptions {
|
||||
readonly entityTypes: readonly string[];
|
||||
readonly tags: readonly string[];
|
||||
readonly assignees: readonly FileAssigneeOption[];
|
||||
}
|
||||
|
||||
const EMPTY_FILTER_OPTIONS: FileBrowserFilterOptions = { entityTypes: [], tags: [], assignees: [] };
|
||||
|
||||
export interface FileBrowserData {
|
||||
readonly viewMode: FileViewMode;
|
||||
readonly rows: readonly FileBrowserRow[];
|
||||
readonly filter: FileBrowserFilterState;
|
||||
readonly filterOptions: FileBrowserFilterOptions;
|
||||
readonly canWrite: boolean;
|
||||
readonly canDelete: boolean;
|
||||
/** Cursor of the next page (null = last page). */
|
||||
@@ -80,6 +100,8 @@ export interface BuildFileBrowserVMInput {
|
||||
readonly viewMode?: FileViewMode;
|
||||
readonly rows: readonly FileBrowserRow[];
|
||||
readonly filter: FileBrowserFilterState;
|
||||
/** Option lists for the filter dropdowns. Defaults to empty when omitted. */
|
||||
readonly filterOptions?: FileBrowserFilterOptions;
|
||||
readonly canWrite: boolean;
|
||||
readonly canDelete: boolean;
|
||||
readonly nextCursor?: string | null;
|
||||
@@ -87,6 +109,7 @@ export interface BuildFileBrowserVMInput {
|
||||
|
||||
export function buildFileBrowserVM(input: BuildFileBrowserVMInput): FileBrowserVM {
|
||||
const viewMode: FileViewMode = input.viewMode ?? "table";
|
||||
const filterOptions = input.filterOptions ?? EMPTY_FILTER_OPTIONS;
|
||||
if (input.rows.length === 0) {
|
||||
// Empty stays a `ready` state with a plain-text empty state (DoD 23) so the
|
||||
// filter/toggle bar and upload CTA remain visible.
|
||||
@@ -96,6 +119,7 @@ export function buildFileBrowserVM(input: BuildFileBrowserVMInput): FileBrowserV
|
||||
viewMode,
|
||||
rows: [],
|
||||
filter: input.filter,
|
||||
filterOptions,
|
||||
canWrite: input.canWrite,
|
||||
canDelete: input.canDelete,
|
||||
nextCursor: null,
|
||||
@@ -111,6 +135,7 @@ export function buildFileBrowserVM(input: BuildFileBrowserVMInput): FileBrowserV
|
||||
viewMode,
|
||||
rows: input.rows,
|
||||
filter: input.filter,
|
||||
filterOptions,
|
||||
canWrite: input.canWrite,
|
||||
canDelete: input.canDelete,
|
||||
nextCursor: input.nextCursor ?? null,
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildFileDetailVM, type BuildFileDetailVMInput } from "../index.js";
|
||||
|
||||
const base: BuildFileDetailVMInput = {
|
||||
id: "f1",
|
||||
displayName: "vertrag.pdf",
|
||||
mimeType: "application/pdf",
|
||||
sizeBytes: 9999,
|
||||
createdAtIso: "2026-06-19T08:00:00.000Z",
|
||||
tags: [],
|
||||
notes: null,
|
||||
source: "manual_upload",
|
||||
previewStatus: "ready",
|
||||
scanStatus: "clean",
|
||||
previewUrl: "/acme/media/f1/preview",
|
||||
downloadUrl: "/acme/media/f1/original",
|
||||
assignedToUserId: null,
|
||||
linkedEntities: [],
|
||||
canWrite: true,
|
||||
canDelete: false,
|
||||
canAdmin: false,
|
||||
};
|
||||
|
||||
describe("previewFallbackKey pending/generating branch (file-detail.ts:69)", () => {
|
||||
it.each(["pending", "generating"] as const)("emits the pending hint while preview status is %s", (previewStatus) => {
|
||||
const vm = buildFileDetailVM({ ...base, previewStatus, previewUrl: null });
|
||||
if (vm.status !== "ready") throw new Error("expected ready");
|
||||
expect(vm.data.previewFallbackKey).toBe("files.detail.preview.pending");
|
||||
// A still-generating preview is never regenerable (only a failed one is).
|
||||
expect(vm.data.canRegeneratePreview).toBe(false);
|
||||
});
|
||||
|
||||
it("emits no fallback key once the preview is ready", () => {
|
||||
const vm = buildFileDetailVM({ ...base, previewStatus: "ready" });
|
||||
if (vm.status !== "ready") throw new Error("expected ready");
|
||||
expect(vm.data.previewFallbackKey).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("scanNoticeKey pending branch (file-detail.ts:75)", () => {
|
||||
it("notes a still-pending virus scan and keeps the preview URL (not infected)", () => {
|
||||
const vm = buildFileDetailVM({ ...base, scanStatus: "pending" });
|
||||
if (vm.status !== "ready") throw new Error("expected ready");
|
||||
expect(vm.data.scanNoticeKey).toBe("files.detail.scan.pending");
|
||||
expect(vm.data.previewUrl).toBe("/acme/media/f1/preview");
|
||||
});
|
||||
|
||||
it("emits no scan notice for a clean file", () => {
|
||||
const vm = buildFileDetailVM({ ...base, scanStatus: "clean" });
|
||||
if (vm.status !== "ready") throw new Error("expected ready");
|
||||
expect(vm.data.scanNoticeKey).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user