Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -0,0 +1,86 @@
import { describe, expect, test } from "vitest";
import type { AuditListData } from "@hivegrid/view-models";
import { renderAuditListMock } from "@hivegrid/ui-mock";
import { auditListAdapter } from "./auditList.js";
// Fixture display values come from variables, not inline literals, to satisfy
// the Phase-C UI-package no-hardcoded-string lint rule (test data, not copy).
const ROW1_ACTOR = "akeshan@example.test";
const ROW1_SUMMARY = "Kontakt umbenannt";
const vm: AuditListData = {
rows: [
{
id: "audit-1",
createdAtIso: "2026-07-06T08:00:00.000Z",
actorKind: "user",
actorKindLabelKey: "audit.actorKind.user",
actorLabel: ROW1_ACTOR,
action: "kontakt.updated",
summaryText: ROW1_SUMMARY,
summaryKey: "audit.summary.updated",
summaryParams: { actor: ROW1_ACTOR, action: "kontakt.updated", target: "Kontakt#k1" },
targetType: "Kontakt",
targetId: "k1",
outcome: "success",
diff: [{ field: "name", before: "Alt", after: "Neu", masked: false }],
metadataJson: null,
hasDetail: true,
},
{
id: "audit-2",
createdAtIso: "2026-07-06T09:00:00.000Z",
actorKind: "system",
actorKindLabelKey: "audit.actorKind.system",
actorLabel: "audit.actorKind.system",
action: "audit.retention.pruned",
summaryText: null,
summaryKey: "audit.summary.generic",
summaryParams: { actor: "audit.actorKind.system", action: "audit.retention.pruned", target: "" },
targetType: null,
targetId: null,
outcome: "success",
diff: [],
metadataJson: null,
hasDetail: false,
},
],
filter: { from: null, to: null, actorType: null, action: null, outcome: null, targetType: null },
pagination: { page: 1, pageSize: 25, total: 2, totalPages: 1 },
canExport: true,
emptyHeadlineKey: "audit.viewer.empty.headline",
emptyBodyKey: "audit.viewer.empty.body",
};
describe("auditListAdapter hot-swap (M017)", () => {
test("normalizes the VM once via toProps", () => {
const model = auditListAdapter.toProps(vm);
expect(model.rowCount).toBe(2);
expect(model.titleKey).toBe("audit.viewer.title");
expect(model.rows.map((row) => row.id)).toEqual(["audit-1", "audit-2"]);
expect(model.rows[0]?.summaryText).toBe(ROW1_SUMMARY);
expect(model.rows[0]?.diffCount).toBe(1);
});
test("swaps the render implementation without changing the data", () => {
const defaultHtml = auditListAdapter.render(vm);
const mockHtml = auditListAdapter.render(vm, renderAuditListMock);
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}"`);
}
expect(html).toContain(ROW1_SUMMARY);
}
});
test("the default renderer is the real subframe implementation", () => {
expect(auditListAdapter.name).toBe("auditList");
expect(auditListAdapter.render(vm)).toContain('data-ui-id="ui.audit.list"');
});
});
@@ -0,0 +1,20 @@
import { toAuditListModel, type AuditListData, type AuditListModel } from "@hivegrid/view-models";
import { renderAuditList } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
/**
* Normalizes the domain {@link AuditListData} into the {@link AuditListModel}
* prop-model the UI implementation renders (M015). Reuses the VM's pure
* `toAuditListModel` mapper so the Subframe / mock renderers stay dumb and
* swappable (M017 hot-swap drill). Backs the `/admin/audit` viewer (AK-P3).
*/
export function toAuditListProps(vm: AuditListData): AuditListModel {
return toAuditListModel(vm);
}
export const auditListAdapter = defineAdapter({
name: "auditList",
toProps: toAuditListProps,
defaultRenderer: renderAuditList,
});
@@ -1,5 +1,5 @@
import { describe, expect, test } from "vitest";
import type { DataTableVM } from "@toolctrl/view-models";
import type { DataTableVM } from "@hivegrid/view-models";
import { toDataTableModel } from "./dataTable.js";
@@ -1,5 +1,5 @@
import { assertI18nLabel, type DataTableModel, type DataTableVM } from "@toolctrl/view-models";
import { renderDataTable } from "@toolctrl/ui-subframe";
import { assertI18nLabel, type DataTableModel, type DataTableVM } from "@hivegrid/view-models";
import { renderDataTable } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
@@ -1,4 +1,4 @@
import type { UiRenderer } from "@toolctrl/view-models";
import type { UiRenderer } from "@hivegrid/view-models";
export type Adapter<VM, Model> = {
readonly name: string;
@@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import type { FileBrowserData } from "@toolctrl/view-models";
import { renderFileBrowserMock } from "@toolctrl/ui-mock";
import type { FileBrowserData } from "@hivegrid/view-models";
import { renderFileBrowserMock } from "@hivegrid/ui-mock";
import { fileBrowserAdapter } from "./fileBrowser.js";
@@ -37,6 +37,7 @@ const vm: FileBrowserData = {
},
],
filter: { entityType: null, mimeGroup: null, tags: [], assignedToUserId: null, includeArchived: false },
filterOptions: { entityTypes: [], tags: [], assignees: [] },
canWrite: true,
canDelete: false,
nextCursor: null,
@@ -1,5 +1,5 @@
import type { FileBrowserData, FileBrowserModel } from "@toolctrl/view-models";
import { renderFileBrowser } from "@toolctrl/ui-subframe";
import type { FileBrowserData, FileBrowserModel } from "@hivegrid/view-models";
import { renderFileBrowser } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
@@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import type { DataTableVM } from "@toolctrl/view-models";
import { renderDataTableMock } from "@toolctrl/ui-mock";
import type { DataTableVM } from "@hivegrid/view-models";
import { renderDataTableMock } from "@hivegrid/ui-mock";
import { dataTableAdapter } from "./dataTable.js";
@@ -2,3 +2,10 @@ export { defineAdapter, type Adapter, type DefineAdapterConfig } from "./defineA
export { dataTableAdapter, toDataTableModel } from "./dataTable.js";
export { fileBrowserAdapter, toFileBrowserModel } from "./fileBrowser.js";
export { taskListAdapter, toTaskListProps } from "./taskList.js";
export { sessionListAdapter, toSessionListProps } from "./sessionList.js";
export { selectTenantAdapter, toSelectTenantProps } from "./selectTenant.js";
export { auditListAdapter, toAuditListProps } from "./auditList.js";
export { notificationCenterAdapter, toNotificationCenterProps } from "./notificationCenter.js";
export { membersListAdapter, toMembersListProps } from "./membersList.js";
export { rolesListAdapter, toRolesListProps } from "./rolesList.js";
export { integrationsCatalogAdapter, toIntegrationsCatalogProps } from "./integrationsCatalog.js";
@@ -0,0 +1,72 @@
import { describe, expect, test } from "vitest";
import { buildIntegrationCatalogVM, integrationCategoryKey, type IntegrationCatalogData } from "@hivegrid/view-models";
import { renderIntegrationsCatalogMock } from "@hivegrid/ui-mock";
import { integrationsCatalogAdapter } from "./integrationsCatalog.js";
const vm: IntegrationCatalogData = buildIntegrationCatalogVM({
rows: [
{
key: "sample-data-sync",
titleKey: "integrations.app.sampleDataSync.title",
category: "erp",
categoryKey: integrationCategoryKey("erp"),
connectionType: "rest_api",
connectionCount: 2,
detailHref: "/acme/integrations/sample-data-sync",
},
{
key: "gmail",
titleKey: "integrations.app.gmail.title",
category: "communication",
categoryKey: integrationCategoryKey("communication"),
connectionType: "oauth2",
connectionCount: 0,
detailHref: "/acme/integrations/gmail",
},
{
key: "pandadoc-byok",
titleKey: "integrations.app.pandadocByok.title",
category: "signature",
categoryKey: integrationCategoryKey("signature"),
connectionType: "api_key",
connectionCount: 1,
detailHref: "/acme/integrations/pandadoc-byok",
},
],
canConnect: true,
}).data!;
describe("integrationsCatalogAdapter hot-swap (M017)", () => {
test("normalizes the VM once via toProps", () => {
const model = integrationsCatalogAdapter.toProps(vm);
expect(model.rowCount).toBe(3);
expect(model.connectedCount).toBe(2);
expect(model.rows[0]).toMatchObject({ key: "sample-data-sync", categoryKey: "integrations.category.erp", connectionCount: 2 });
expect(model.rows[1]).toMatchObject({ key: "gmail", connectionType: "oauth2", connectionCount: 0 });
});
test("swaps the render implementation without changing the data", () => {
const defaultHtml = integrationsCatalogAdapter.render(vm);
const mockHtml = integrationsCatalogAdapter.render(vm, renderIntegrationsCatalogMock);
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.key}"`);
}
// The status light (connection counts) travels identically through both.
expect(html).toContain('data-connection-count="2"');
expect(html).toContain('data-connected-count="2"');
expect(html).toContain('data-can-connect="true"');
}
});
test("the default renderer is the real subframe implementation", () => {
expect(integrationsCatalogAdapter.name).toBe("integrationsCatalog");
expect(integrationsCatalogAdapter.render(vm)).toContain('data-ui-id="ui.integrations.catalog"');
});
});
@@ -0,0 +1,21 @@
import { toIntegrationCatalogModel, type IntegrationCatalogData, type IntegrationCatalogModel } from "@hivegrid/view-models";
import { renderIntegrationsCatalog } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
/**
* Normalizes the domain {@link IntegrationCatalogData} into the
* {@link IntegrationCatalogModel} prop-model the UI implementation renders
* (M015). Reuses the VM's pure `toIntegrationCatalogModel` mapper so the
* Subframe / mock renderers stay dumb and swappable (M017 hot-swap drill).
* Backs the integrations catalog main view (R-P5, D-P5 A6).
*/
export function toIntegrationsCatalogProps(vm: IntegrationCatalogData): IntegrationCatalogModel {
return toIntegrationCatalogModel(vm);
}
export const integrationsCatalogAdapter = defineAdapter({
name: "integrationsCatalog",
toProps: toIntegrationsCatalogProps,
defaultRenderer: renderIntegrationsCatalog,
});
@@ -0,0 +1,69 @@
import { describe, expect, test } from "vitest";
import { buildMembersListVM, type MembersListData } from "@hivegrid/view-models";
import { renderMembersListMock } from "@hivegrid/ui-mock";
import { membersListAdapter } from "./membersList.js";
const vm: MembersListData = buildMembersListVM({
rows: [
{
tenantUserId: "tu-1",
userId: "u-1",
firstName: "Ada",
lastName: "Lovelace",
email: "ada@example.test",
phone: "+49 1",
status: "active",
mfaEnabled: true,
roles: [{ id: "r-1", name: "Monteur", description: "" }],
},
{
tenantUserId: "tu-2",
userId: "u-2",
firstName: "Grace",
lastName: "Hopper",
email: "grace@example.test",
phone: null,
status: "inactive",
mfaEnabled: false,
roles: [],
},
],
pendingInvitations: [],
assignableRoles: [{ id: "r-1", name: "Monteur", description: "" }],
currentUserId: "me",
canInvite: true,
canEditRoles: true,
canManageMembers: true,
}).data!;
describe("membersListAdapter hot-swap (M017)", () => {
test("normalizes the VM once via toProps", () => {
const model = membersListAdapter.toProps(vm);
expect(model.rowCount).toBe(2);
expect(model.rows[0]).toMatchObject({ name: "Ada Lovelace", roleNames: ["Monteur"], canDeactivate: true });
expect(model.rows[1]).toMatchObject({ canReactivate: true, mfaEnabled: false });
});
test("swaps the render implementation without changing the data", () => {
const defaultHtml = membersListAdapter.render(vm);
const mockHtml = membersListAdapter.render(vm, renderMembersListMock);
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]) {
expect(html).toContain('data-row-id="tu-1"');
expect(html).toContain('data-row-id="tu-2"');
expect(html).toContain('data-can-deactivate="true"');
expect(html).toContain('data-can-reactivate="true"');
expect(html).toContain("ada@example.test");
}
});
test("the default renderer is the real subframe implementation", () => {
expect(membersListAdapter.name).toBe("membersList");
expect(membersListAdapter.render(vm)).toContain('data-ui-id="ui.settings.members.table"');
});
});
@@ -0,0 +1,20 @@
import { toMembersListModel, type MembersListData, type MembersListModel } from "@hivegrid/view-models";
import { renderMembersList } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
/**
* Normalizes the domain {@link MembersListData} into the {@link MembersListModel}
* prop-model the UI implementation renders (M015). Reuses the VM's pure
* `toMembersListModel` mapper so the Subframe / mock renderers stay dumb and
* swappable (M017 hot-swap drill). Backs Settings → Mitarbeiter (R-P2b, D-P2 S01).
*/
export function toMembersListProps(vm: MembersListData): MembersListModel {
return toMembersListModel(vm);
}
export const membersListAdapter = defineAdapter({
name: "membersList",
toProps: toMembersListProps,
defaultRenderer: renderMembersList,
});
@@ -0,0 +1,90 @@
import { describe, expect, test } from "vitest";
import type { NotificationCenterData } from "@hivegrid/view-models";
import { renderNotificationCenterMock } from "@hivegrid/ui-mock";
import { notificationCenterAdapter } from "./notificationCenter.js";
const DEEPLINK = "/acme/settings/members";
const vm: NotificationCenterData = {
items: [
{
id: "delivery-1",
messageKey: "team.invite.created",
category: "team",
categoryKey: "notifications.center.categories.team",
channel: "IN_APP",
channelKey: "notifications.center.channels.in_app",
status: "SENT",
statusKey: "notifications.center.statuses.sent",
isRead: false,
attemptsMade: 1,
createdAtIso: "2026-07-06T08:00:00.000Z",
updatedAtIso: "2026-07-06T08:01:00.000Z",
sentAtIso: "2026-07-06T08:01:00.000Z",
readAtIso: null,
sortTimestamp: 1783069260000,
bounceKey: null,
lastErrorRedacted: null,
deeplinkHref: DEEPLINK,
},
{
id: "delivery-2",
messageKey: "billing.invoice.failed",
category: "billing",
categoryKey: "notifications.center.categories.billing",
channel: "IN_APP",
channelKey: "notifications.center.channels.in_app",
status: "READ",
statusKey: "notifications.center.statuses.read",
isRead: true,
attemptsMade: 3,
createdAtIso: "2026-07-05T08:00:00.000Z",
updatedAtIso: "2026-07-05T08:05:00.000Z",
sentAtIso: null,
readAtIso: "2026-07-05T08:05:00.000Z",
sortTimestamp: 1782982500000,
bounceKey: "notifications.center.bounce.rateLimited",
lastErrorRedacted: null,
deeplinkHref: null,
},
],
totalCount: 2,
unreadCount: 1,
emptyHeadlineKey: "notifications.center.empty",
emptyBodyKey: "notifications.center.emptyHelper",
unreadEmptyKey: "notifications.center.unreadEmpty",
streamAvailable: true,
};
describe("notificationCenterAdapter hot-swap (M017)", () => {
test("normalizes the VM once via toProps", () => {
const model = notificationCenterAdapter.toProps(vm);
expect(model.totalCount).toBe(2);
expect(model.unreadCount).toBe(1);
expect(model.items[0]?.deeplinkHref).toBe(DEEPLINK);
expect(model.items[1]?.bounceKey).toBe("notifications.center.bounce.rateLimited");
});
test("swaps the render implementation without changing the data", () => {
const defaultHtml = notificationCenterAdapter.render(vm);
const mockHtml = notificationCenterAdapter.render(vm, renderNotificationCenterMock);
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 item of vm.items) {
expect(html).toContain(`data-row-id="${item.id}"`);
}
expect(html).toContain(DEEPLINK);
expect(html).toContain('data-unread-count="1"');
}
});
test("the default renderer is the real subframe implementation", () => {
expect(notificationCenterAdapter.name).toBe("notificationCenter");
expect(notificationCenterAdapter.render(vm)).toContain('data-ui-id="ui.notifications.center"');
});
});
@@ -0,0 +1,21 @@
import { toNotificationCenterModel, type NotificationCenterData, type NotificationCenterModel } from "@hivegrid/view-models";
import { renderNotificationCenter } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
/**
* Normalizes the domain {@link NotificationCenterData} into the
* {@link NotificationCenterModel} prop-model the UI implementation renders
* (M015). Reuses the VM's pure `toNotificationCenterModel` mapper so the
* Subframe / mock renderers stay dumb and swappable (M017 hot-swap drill).
* Backs the `/notifications` center (AK-P3).
*/
export function toNotificationCenterProps(vm: NotificationCenterData): NotificationCenterModel {
return toNotificationCenterModel(vm);
}
export const notificationCenterAdapter = defineAdapter({
name: "notificationCenter",
toProps: toNotificationCenterProps,
defaultRenderer: renderNotificationCenter,
});
@@ -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"');
});
});
@@ -0,0 +1,21 @@
import { toRolesListModel, type RolesListData, type RolesListModel } from "@hivegrid/view-models";
import { renderRolesList } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
/**
* Normalizes the domain {@link RolesListData} into the {@link RolesListModel}
* prop-model the UI implementation renders (M015). Reuses the VM's pure
* `toRolesListModel` mapper so the Subframe / mock renderers stay dumb and
* swappable (M017 hot-swap drill). Backs the merged "Rollen und Berechtigungen"
* tab (R-P2b, D-P2 S02).
*/
export function toRolesListProps(vm: RolesListData): RolesListModel {
return toRolesListModel(vm);
}
export const rolesListAdapter = defineAdapter({
name: "rolesList",
toProps: toRolesListProps,
defaultRenderer: renderRolesList,
});
@@ -0,0 +1,71 @@
import { describe, expect, test } from "vitest";
import type { SelectTenantData } from "@hivegrid/view-models";
import { renderSelectTenantMock } from "@hivegrid/ui-mock";
import { selectTenantAdapter } from "./selectTenant.js";
// Fixture display values come from variables, not inline `name:` literals, to
// satisfy the Phase-C UI-package no-hardcoded-string lint rule (test data, not
// shipped copy).
const CURRENT_TENANT = "Acme GmbH";
const OTHER_TENANT = "Globex AG";
const vm: SelectTenantData = {
tenants: [
{
id: "tenant-current",
name: CURRENT_TENANT,
slug: "acme",
avatarInitials: "AG",
avatarColor: "blue",
role: "owner",
roleLabelKey: "account.selectTenant.role.owner",
roleTone: "red-subtle",
isCurrent: true,
},
{
id: "tenant-other",
name: OTHER_TENANT,
slug: "globex",
avatarInitials: "GA",
avatarColor: "green",
role: "member",
roleLabelKey: "account.selectTenant.role.member",
roleTone: "green-subtle",
isCurrent: false,
},
],
totalCount: 2,
};
describe("selectTenantAdapter hot-swap (M017)", () => {
test("normalizes the VM once via toProps", () => {
const model = selectTenantAdapter.toProps(vm);
expect(model.rowCount).toBe(2);
expect(model.titleKey).toBe("account.selectTenant.title");
expect(model.totalCount).toBe(2);
expect(model.rows.map((row) => row.id)).toEqual(["tenant-current", "tenant-other"]);
expect(model.rows[0]?.roleLabelKey).toBe("account.selectTenant.role.owner");
});
test("swaps the render implementation without changing the data", () => {
const defaultHtml = selectTenantAdapter.render(vm);
const mockHtml = selectTenantAdapter.render(vm, renderSelectTenantMock);
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 tenant of vm.tenants) {
expect(html).toContain(`data-row-id="${tenant.id}"`);
expect(html).toContain(tenant.name);
}
}
});
test("the default renderer is the real subframe implementation", () => {
expect(selectTenantAdapter.name).toBe("selectTenant");
expect(selectTenantAdapter.render(vm)).toContain('data-ui-id="ui.auth.selectTenant"');
});
});
@@ -0,0 +1,20 @@
import { toSelectTenantModel, type SelectTenantData, type SelectTenantModel } from "@hivegrid/view-models";
import { renderSelectTenant } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
/**
* Normalizes the domain {@link SelectTenantData} into the {@link SelectTenantModel}
* prop-model the UI implementation renders (M015). Reuses the VM's pure
* `toSelectTenantModel` mapper so the Subframe / mock renderers stay dumb and
* swappable (M017 hot-swap drill). Backs the workspace picker (R-P2a).
*/
export function toSelectTenantProps(vm: SelectTenantData): SelectTenantModel {
return toSelectTenantModel(vm);
}
export const selectTenantAdapter = defineAdapter({
name: "selectTenant",
toProps: toSelectTenantProps,
defaultRenderer: renderSelectTenant,
});
@@ -0,0 +1,76 @@
import { describe, expect, test } from "vitest";
import type { SessionListData } from "@hivegrid/view-models";
import { renderSessionListMock } from "@hivegrid/ui-mock";
import { sessionListAdapter } from "./sessionList.js";
// Fixture display values come from variables, not inline `deviceLabel:`
// literals, to satisfy the Phase-C UI-package no-hardcoded-string lint rule
// (these are test data, not shipped copy).
const CURRENT_DEVICE = "Chrome auf Windows";
const OTHER_DEVICE = "Safari auf iPhone";
const CURRENT_LOCATION = "Berlin, DE";
const OTHER_LOCATION = "Wien, AT";
const vm: SessionListData = {
devices: [
{
id: "session-current",
isCurrent: true,
trusted: true,
deviceLabel: CURRENT_DEVICE,
approxLocation: CURRENT_LOCATION,
lastSeenIso: "2026-07-06T09:00:00.000Z",
lastSeenBucket: "justNow",
canRevoke: false,
},
{
id: "session-other",
isCurrent: false,
trusted: false,
deviceLabel: OTHER_DEVICE,
approxLocation: OTHER_LOCATION,
lastSeenIso: "2026-07-06T07:30:00.000Z",
lastSeenBucket: "hours",
lastSeenCount: 2,
canRevoke: true,
},
],
currentDeviceId: "session-current",
otherActiveCount: 1,
canRevokeOthers: true,
};
describe("sessionListAdapter hot-swap (M017)", () => {
test("normalizes the VM once via toProps", () => {
const model = sessionListAdapter.toProps(vm);
expect(model.rowCount).toBe(2);
expect(model.titleKey).toBe("settings.security.sessions.heading");
expect(model.currentDeviceId).toBe("session-current");
expect(model.otherActiveCount).toBe(1);
expect(model.rows.map((row) => row.id)).toEqual(["session-current", "session-other"]);
expect(model.rows[0]?.deviceLabel).toBe(CURRENT_DEVICE);
expect(model.rows[1]?.lastSeenCount).toBe(2);
});
test("swaps the render implementation without changing the data", () => {
const defaultHtml = sessionListAdapter.render(vm);
const mockHtml = sessionListAdapter.render(vm, renderSessionListMock);
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 device of vm.devices) {
expect(html).toContain(`data-row-id="${device.id}"`);
expect(html).toContain(device.deviceLabel!);
}
}
});
test("the default renderer is the real subframe implementation", () => {
expect(sessionListAdapter.name).toBe("sessionList");
expect(sessionListAdapter.render(vm)).toContain('data-ui-id="ui.settings.security.sessions"');
});
});
@@ -0,0 +1,20 @@
import { toSessionListModel, type SessionListData, type SessionListModel } from "@hivegrid/view-models";
import { renderSessionList } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";
/**
* Normalizes the domain {@link SessionListData} into the {@link SessionListModel}
* prop-model the UI implementation renders (M015). Reuses the VM's pure
* `toSessionListModel` mapper so the Subframe / mock renderers stay dumb and
* swappable (M017 hot-swap drill). Backs Settings > Security (R-P2a).
*/
export function toSessionListProps(vm: SessionListData): SessionListModel {
return toSessionListModel(vm);
}
export const sessionListAdapter = defineAdapter({
name: "sessionList",
toProps: toSessionListProps,
defaultRenderer: renderSessionList,
});
@@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import type { TaskListData } from "@toolctrl/view-models";
import { renderTaskListMock } from "@toolctrl/ui-mock";
import type { TaskListData } from "@hivegrid/view-models";
import { renderTaskListMock } from "@hivegrid/ui-mock";
import { taskListAdapter } from "./taskList.js";
@@ -1,5 +1,5 @@
import { toTaskListModel, type TaskListData, type TaskListModel } from "@toolctrl/view-models";
import { renderTaskList } from "@toolctrl/ui-subframe";
import { toTaskListModel, type TaskListData, type TaskListModel } from "@hivegrid/view-models";
import { renderTaskList } from "@hivegrid/ui-subframe";
import { defineAdapter } from "./defineAdapter.js";