Files
community-rule/tests/components/TextBlock.test.tsx
T
adilalloandCursor 511c3efb4c Stop seeding 75% consensus on custom decision cards so wizard copy shows on the published rule.
Wire Back on the final-review chip editor to the same dismiss path as close, instead of a no-op.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 11:28:32 -06:00

62 lines
1.6 KiB
TypeScript

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>;
const config: ComponentTestSuiteConfig<Props> = {
component: TextBlock,
name: "TextBlock",
props: {
title: "Policy title",
body: "Supporting text for the policy.",
} as Props,
requiredProps: ["title"],
testCases: {
renders: true,
accessibility: true,
},
};
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",
);
});
it("renders body paragraphs above labeled rows when both are set", () => {
render(
<TextBlock
title="Forum proposals"
body="Anyone can start a thread."
rows={[{ label: "Quorum", body: "60%" }]}
/>,
);
expect(screen.getByText("Anyone can start a thread.")).toBeInTheDocument();
expect(screen.getByText("Quorum")).toBeInTheDocument();
expect(screen.getByText("60%")).toBeInTheDocument();
});
});