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
+90
@@ -0,0 +1,90 @@
|
||||
/* eslint-disable no-restricted-syntax -- test fixtures use real display strings, not i18n UI descriptors */
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { TaskListModel } from "@hivegrid/view-models";
|
||||
|
||||
import { renderTaskListMock } from "./index.js";
|
||||
|
||||
const model: TaskListModel = {
|
||||
titleKey: "ui.tasks.list.title",
|
||||
emptyHeadlineKey: "ui.tasks.list.empty.headline",
|
||||
emptyBodyKey: "ui.tasks.list.empty.body",
|
||||
canWrite: true,
|
||||
createHref: "/tasks/new",
|
||||
rows: [
|
||||
{
|
||||
id: "task-1",
|
||||
title: "Angebot prüfen",
|
||||
statusKey: "ui.tasks.status.open",
|
||||
priorityKey: "ui.tasks.priority.high",
|
||||
deadlineIso: "2026-07-01T00:00:00.000Z",
|
||||
isOverdue: true,
|
||||
assigneeLabel: "Raffael",
|
||||
detailHref: "/tasks/task-1",
|
||||
},
|
||||
{
|
||||
id: "task-2",
|
||||
title: "Rechnung senden",
|
||||
statusKey: "ui.tasks.status.done",
|
||||
priorityKey: "ui.tasks.priority.low",
|
||||
deadlineIso: null,
|
||||
isOverdue: false,
|
||||
assigneeLabel: null,
|
||||
detailHref: "/tasks/task-2",
|
||||
},
|
||||
],
|
||||
rowCount: 2,
|
||||
};
|
||||
|
||||
describe("renderTaskListMock (mock impl)", () => {
|
||||
test("carries the impl marker, title key and one body row per task", () => {
|
||||
const html = renderTaskListMock(model);
|
||||
expect(html).toContain('data-ui-impl="mock"');
|
||||
expect(html).toContain('data-ui-id="ui.tasks.list"');
|
||||
expect(html).toContain('data-row-count="2"');
|
||||
expect(html).toContain('data-row="head" data-i18n-key="ui.tasks.list.title"');
|
||||
expect(html.match(/data-row="body"/g)).toHaveLength(2);
|
||||
expect(html).not.toContain('data-empty="true"');
|
||||
});
|
||||
|
||||
test("projects status key and the overdue flag onto each row", () => {
|
||||
const html = renderTaskListMock(model);
|
||||
// Overdue task: boolean serialized literally as "true".
|
||||
expect(html).toContain('data-row-id="task-1"');
|
||||
expect(html).toContain('data-status-key="ui.tasks.status.open"');
|
||||
expect(html).toContain('data-overdue="true"');
|
||||
expect(html).toContain("Angebot prüfen");
|
||||
// Non-overdue task: boolean serialized literally as "false".
|
||||
expect(html).toContain('data-row-id="task-2"');
|
||||
expect(html).toContain('data-status-key="ui.tasks.status.done"');
|
||||
expect(html).toContain('data-overdue="false"');
|
||||
});
|
||||
|
||||
test("renders the empty headline marker when there are no rows", () => {
|
||||
const html = renderTaskListMock({ ...model, rows: [], rowCount: 0 });
|
||||
expect(html).toContain('data-row-count="0"');
|
||||
expect(html).toContain('data-empty="true"');
|
||||
expect(html).toContain('data-i18n-key="ui.tasks.list.empty.headline"');
|
||||
expect(html).not.toContain('data-row="body"');
|
||||
});
|
||||
|
||||
test("escapes HTML metacharacters in the task title", () => {
|
||||
const html = renderTaskListMock({
|
||||
...model,
|
||||
rows: [
|
||||
{
|
||||
id: "task-x",
|
||||
title: '<b>"drop"</b> & <i>run</i>',
|
||||
statusKey: "ui.tasks.status.open",
|
||||
priorityKey: "ui.tasks.priority.high",
|
||||
deadlineIso: null,
|
||||
isOverdue: false,
|
||||
assigneeLabel: null,
|
||||
detailHref: "/tasks/task-x",
|
||||
},
|
||||
],
|
||||
rowCount: 1,
|
||||
});
|
||||
expect(html).toContain("<b>"drop"</b> & <i>run</i>");
|
||||
expect(html).not.toContain("<b>");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user