/** @jest-environment jsdom */
import { buildSelectedElementContext } from "./pageContext";
describe("selected element context", () => {
it("sends only the selected subtree and redacts active content and values", () => {
document.body.innerHTML = `
Never include me
`;
const selected = document.querySelector("#selected")!;
const context = buildSelectedElementContext(selected, {
route: "assessments",
rootSelector: "#selected",
request: "Make this clearer",
userContext: "This is an assessment card.",
});
expect(context.selectedHtml).toContain("Selected text");
expect(context.selectedHtml).not.toContain("Never include me");
expect(context.selectedHtml).not.toContain("student@example.test");
expect(context.selectedHtml).not.toContain("onclick");
expect(context.selectedHtml).not.toContain("data-session");
expect(context.selectedHtml).not.toContain("