feat(create): wizard uploads render as images in display and exports (imageUrl/fileUrl)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { describe } from "vitest";
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
componentTestSuite,
|
||||
type ComponentTestSuiteConfig,
|
||||
} from "../utils/componentTestSuite";
|
||||
import TextBlock from "../../app/components/type/TextBlock";
|
||||
import { screen } from "@testing-library/react";
|
||||
import { renderWithProviders as render } from "../utils/test-utils";
|
||||
|
||||
type Props = React.ComponentProps<typeof TextBlock>;
|
||||
|
||||
@@ -23,4 +25,24 @@ const config: ComponentTestSuiteConfig<Props> = {
|
||||
|
||||
describe("TextBlock", () => {
|
||||
componentTestSuite<Props>(config);
|
||||
|
||||
it("renders labeled row imageUrl as img", () => {
|
||||
render(
|
||||
<TextBlock
|
||||
title="Entry"
|
||||
rows={[
|
||||
{
|
||||
label: "Photo",
|
||||
body: "",
|
||||
imageUrl: "/api/uploads/aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee",
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
const img = screen.getByRole("img", { name: "Photo" });
|
||||
expect(img).toHaveAttribute(
|
||||
"src",
|
||||
"/api/uploads/aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -208,4 +208,44 @@ describe("parsePublishedDocumentForCommunityRuleDisplay", () => {
|
||||
{ label: "Expectations", body: "Answer stored only on field blocks." },
|
||||
]);
|
||||
});
|
||||
|
||||
it("exposes custom upload image blocks with imageUrl for CommunityRule display", () => {
|
||||
const customId = "b7c0a9f3-0000-4000-8000-000000000002";
|
||||
const doc = {
|
||||
sections: [],
|
||||
methodSelections: {
|
||||
communication: [
|
||||
{
|
||||
id: customId,
|
||||
label: "Policy with photo",
|
||||
sections: {
|
||||
corePrinciple: "",
|
||||
logisticsAdmin: "",
|
||||
codeOfConduct: "",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
customMethodCardFieldBlocksById: {
|
||||
[customId]: [
|
||||
{
|
||||
kind: "upload" as const,
|
||||
id: "u1",
|
||||
blockTitle: "Site photo",
|
||||
fileName: "garden.jpg",
|
||||
assetUrl: "/api/uploads/11111111-1111-4111-8111-111111111111",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
const out = parsePublishedDocumentForCommunityRuleDisplay(doc);
|
||||
const comm = out.find((s) => s.categoryName === "Communication");
|
||||
expect(comm?.entries[0]?.blocks).toEqual([
|
||||
{
|
||||
label: "Site photo",
|
||||
body: "",
|
||||
imageUrl: "/api/uploads/11111111-1111-4111-8111-111111111111",
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user