mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 08:52:21 +00:00
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { fireEvent, render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { PublisherClawScanNote } from "./PublisherClawScanNote";
|
|
|
|
function renderNote(note: string) {
|
|
return render(<PublisherClawScanNote note={note} />);
|
|
}
|
|
|
|
describe("PublisherClawScanNote", () => {
|
|
it("clamps long publisher notes behind an explicit toggle", () => {
|
|
const note = Array.from(
|
|
{ length: 8 },
|
|
(_, index) => `Publisher context paragraph ${index + 1} explaining the scan input.`,
|
|
).join("\n");
|
|
|
|
renderNote(note);
|
|
|
|
const noteText = screen.getByText(/Publisher context paragraph 1/);
|
|
expect(noteText.classList.contains("is-clamped")).toBe(true);
|
|
|
|
const toggle = screen.getByRole("button", { name: "Show more" });
|
|
expect(toggle.getAttribute("aria-expanded")).toBe("false");
|
|
|
|
fireEvent.click(toggle);
|
|
|
|
expect(noteText.classList.contains("is-clamped")).toBe(false);
|
|
expect(screen.getByRole("button", { name: "Show less" }).getAttribute("aria-expanded")).toBe(
|
|
"true",
|
|
);
|
|
});
|
|
|
|
it("renders the note title without the removed help affordance", () => {
|
|
renderNote("Publisher context.");
|
|
|
|
expect(screen.getByRole("heading", { name: "Publisher note" })).toBeTruthy();
|
|
expect(screen.queryByRole("button", { name: /About publisher/i })).toBeNull();
|
|
});
|
|
});
|