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
+48
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { buildRolesListVM, type RolesListData } from "@hivegrid/view-models";
|
||||
import { renderRolesListMock } from "@hivegrid/ui-mock";
|
||||
|
||||
import { rolesListAdapter } from "./rolesList.js";
|
||||
|
||||
const vm: RolesListData = buildRolesListVM({
|
||||
rows: [
|
||||
{ id: "sys", name: "SuperUser", description: "", isDefault: true, tenantId: null, memberCount: 2, permissionCount: 12 },
|
||||
{ id: "r-1", name: "Monteur", description: "", isDefault: false, tenantId: "t-1", memberCount: 3, permissionCount: 4 },
|
||||
{ id: "r-2", name: "Verwaltung", description: "", isDefault: false, tenantId: "t-1", memberCount: 0, permissionCount: 6 },
|
||||
],
|
||||
tenantId: "t-1",
|
||||
canManageRoles: true,
|
||||
}).data!;
|
||||
|
||||
describe("rolesListAdapter hot-swap (M017)", () => {
|
||||
test("normalizes the VM once via toProps", () => {
|
||||
const model = rolesListAdapter.toProps(vm);
|
||||
expect(model.rowCount).toBe(3);
|
||||
expect(model.rows[0]).toMatchObject({ typeLabelKey: "settings.rolesAndPermissions.type.system", canDelete: false });
|
||||
expect(model.rows[1]).toMatchObject({ deleteBlockedInUse: true, canEdit: true });
|
||||
expect(model.rows[2]).toMatchObject({ deleteBlockedInUse: false, canDelete: true });
|
||||
});
|
||||
|
||||
test("swaps the render implementation without changing the data", () => {
|
||||
const defaultHtml = rolesListAdapter.render(vm);
|
||||
const mockHtml = rolesListAdapter.render(vm, renderRolesListMock);
|
||||
|
||||
expect(defaultHtml).toContain('data-ui-impl="subframe"');
|
||||
expect(mockHtml).toContain('data-ui-impl="mock"');
|
||||
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}"`);
|
||||
}
|
||||
// D03 delete blocker travels identically through both implementations.
|
||||
expect(html).toContain('data-delete-blocked="true"');
|
||||
expect(html).toContain('data-can-create="true"');
|
||||
}
|
||||
});
|
||||
|
||||
test("the default renderer is the real subframe implementation", () => {
|
||||
expect(rolesListAdapter.name).toBe("rolesList");
|
||||
expect(rolesListAdapter.render(vm)).toContain('data-ui-id="ui.settings.rolesAndPermissions.roles"');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user