Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+77
@@ -0,0 +1,77 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { FileBrowserData } from "@toolctrl/view-models";
|
||||
import { renderFileBrowserMock } from "@toolctrl/ui-mock";
|
||||
|
||||
import { fileBrowserAdapter } from "./fileBrowser.js";
|
||||
|
||||
const vm: FileBrowserData = {
|
||||
viewMode: "table",
|
||||
rows: [
|
||||
{
|
||||
id: "file-1",
|
||||
displayName: "invoice.pdf",
|
||||
mimeType: "application/pdf",
|
||||
sizeBytes: 1024,
|
||||
createdAtIso: "2026-06-20T00:00:00.000Z",
|
||||
tags: [],
|
||||
source: "manual_upload",
|
||||
previewStatus: "ready",
|
||||
scanStatus: "clean",
|
||||
thumbnailUrl: "/acme/media/file-1/thumb",
|
||||
detailHref: "/acme/files/file-1",
|
||||
linkedEntityLabelKey: null,
|
||||
},
|
||||
{
|
||||
id: "file-2",
|
||||
displayName: "photo.heic",
|
||||
mimeType: "image/heic",
|
||||
sizeBytes: 2048,
|
||||
createdAtIso: "2026-06-20T00:00:00.000Z",
|
||||
tags: ["site"],
|
||||
source: "manual_upload",
|
||||
previewStatus: "pending",
|
||||
scanStatus: "pending",
|
||||
thumbnailUrl: null,
|
||||
detailHref: "/acme/files/file-2",
|
||||
linkedEntityLabelKey: null,
|
||||
},
|
||||
],
|
||||
filter: { entityType: null, mimeGroup: null, tags: [], assignedToUserId: null, includeArchived: false },
|
||||
canWrite: true,
|
||||
canDelete: false,
|
||||
nextCursor: null,
|
||||
emptyHeadlineKey: "files.browser.empty.headline",
|
||||
emptyBodyKey: "files.browser.empty.body",
|
||||
};
|
||||
|
||||
describe("fileBrowserAdapter hot-swap (M017)", () => {
|
||||
test("normalizes the VM once via toProps", () => {
|
||||
const model = fileBrowserAdapter.toProps(vm);
|
||||
expect(model.rowCount).toBe(2);
|
||||
expect(model.titleKey).toBe("files.browser.title");
|
||||
expect(model.rows.map((row) => row.id)).toEqual(["file-1", "file-2"]);
|
||||
});
|
||||
|
||||
test("swaps the render implementation without changing the data", () => {
|
||||
const defaultHtml = fileBrowserAdapter.render(vm);
|
||||
const mockHtml = fileBrowserAdapter.render(vm, renderFileBrowserMock);
|
||||
|
||||
expect(defaultHtml).toContain('data-ui-impl="subframe"');
|
||||
expect(defaultHtml).not.toContain('data-ui-impl="mock"');
|
||||
expect(mockHtml).toContain('data-ui-impl="mock"');
|
||||
expect(mockHtml).not.toContain('data-ui-impl="subframe"');
|
||||
expect(defaultHtml).not.toBe(mockHtml);
|
||||
|
||||
for (const html of [defaultHtml, mockHtml]) {
|
||||
for (const row of vm.rows) {
|
||||
expect(html).toContain(`data-row-id="${row.id}"`);
|
||||
expect(html).toContain(row.displayName);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("the default renderer is the real subframe implementation", () => {
|
||||
expect(fileBrowserAdapter.name).toBe("fileBrowser");
|
||||
expect(fileBrowserAdapter.render(vm)).toContain('data-ui-id="ui.files.browser"');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user