53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import type { IntegrationCatalogModel } from "@hivegrid/view-models";
|
|
|
|
import { renderIntegrationsCatalogMock } from "./index.js";
|
|
|
|
const model: IntegrationCatalogModel = {
|
|
titleKey: "integrations.catalog.title",
|
|
emptyHeadlineKey: "integrations.catalog.empty.headline",
|
|
emptyBodyKey: "integrations.catalog.empty.body",
|
|
canConnect: true,
|
|
rowCount: 2,
|
|
connectedCount: 1,
|
|
rows: [
|
|
{
|
|
key: "sample-data-sync",
|
|
titleKey: "integrations.app.sampleDataSync.title",
|
|
category: "erp",
|
|
categoryKey: "integrations.category.erp",
|
|
connectionType: "rest_api",
|
|
connectionCount: 2,
|
|
detailHref: "/acme/integrations/sample-data-sync",
|
|
},
|
|
{
|
|
key: "gmail",
|
|
titleKey: "integrations.app.gmail.title",
|
|
category: "communication",
|
|
categoryKey: "integrations.category.communication",
|
|
connectionType: "oauth2",
|
|
connectionCount: 0,
|
|
detailHref: "/acme/integrations/gmail",
|
|
},
|
|
],
|
|
};
|
|
|
|
describe("renderIntegrationsCatalogMock (M017)", () => {
|
|
test("renders normalized app rows with catalog data-attributes", () => {
|
|
const html = renderIntegrationsCatalogMock(model);
|
|
expect(html).toContain('data-ui-impl="mock"');
|
|
expect(html).toContain('data-ui-id="ui.integrations.catalog"');
|
|
expect(html).toContain('data-row-id="sample-data-sync"');
|
|
expect(html).toContain('data-category-key="integrations.category.communication"');
|
|
expect(html).toContain('data-connection-count="2"');
|
|
expect(html).toContain('data-connected-count="1"');
|
|
expect(html).toContain('data-can-connect="true"');
|
|
});
|
|
|
|
test("renders the empty state as an i18n key", () => {
|
|
const html = renderIntegrationsCatalogMock({ ...model, rows: [], rowCount: 0, connectedCount: 0 });
|
|
expect(html).toContain('data-empty="true"');
|
|
expect(html).toContain('data-i18n-key="integrations.catalog.empty.headline"');
|
|
});
|
|
});
|