Fixes around URL tooltips and in-app matrix.to link handling (#9139)

* Add regression test for tooltipify exposing raw HTML

* Handle m.to links involving children better

* Comments

* Fix mistaken assertion
This commit is contained in:
Michael Telatynski 2022-08-09 15:37:55 +01:00 committed by GitHub
parent 48ae16b5a5
commit e63072e21f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 19 deletions

View file

@ -57,4 +57,19 @@ describe('tooltipify', () => {
expect(containers).toHaveLength(0);
expect(root.outerHTML).toEqual(originalHtml);
});
it("does not re-wrap if called multiple times", () => {
const component = mount(<div><a href="/foo">click</a></div>);
const root = component.getDOMNode();
const containers: Element[] = [];
tooltipifyLinks([root], [], containers);
tooltipifyLinks([root], [], containers);
tooltipifyLinks([root], [], containers);
tooltipifyLinks([root], [], containers);
expect(containers).toHaveLength(1);
const anchor = root.querySelector("a");
expect(anchor?.getAttribute("href")).toEqual("/foo");
const tooltip = anchor.querySelector(".mx_TextWithTooltip_target");
expect(tooltip).toBeDefined();
});
});