mirror of https://github.com/vector-im/riot-web
Avoid rendering view-message link in RoomKnocksBar unnecessarily (#11598)
Signed-off-by: Charly Nguyen <charly.nguyen@nordeck.net>t3chguy/dedup-icons-17oct
parent
3c6d8a2a28
commit
bb91df1d3c
|
@ -112,7 +112,7 @@ export const RoomKnocksBar: VFC<{ room: Room }> = ({ room }) => {
|
|||
</>
|
||||
);
|
||||
names = `${knockMembers[0].name} (${knockMembers[0].userId})`;
|
||||
link = (
|
||||
link = knockMembers[0].events.member?.getContent().reason && (
|
||||
<AccessibleButton
|
||||
className="mx_RoomKnocksBar_link"
|
||||
element="a"
|
||||
|
|
|
@ -165,7 +165,21 @@ describe("RoomKnocksBar", () => {
|
|||
expect(screen.getByRole("paragraph")).toHaveTextContent(`${bob.name} (${bob.userId})`);
|
||||
});
|
||||
|
||||
describe("when a knock reason is not provided", () => {
|
||||
it("does not render a link to open the room settings people tab", () => {
|
||||
getComponent(room);
|
||||
expect(screen.queryByRole("button", { name: "View message" })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a knock reason is provided", () => {
|
||||
it("renders a link to open the room settings people tab", () => {
|
||||
bob.setMembershipEvent(
|
||||
new MatrixEvent({
|
||||
content: { displayname: "Bob", membership: "knock", reason: "some reason" },
|
||||
type: EventType.RoomMember,
|
||||
}),
|
||||
);
|
||||
getComponent(room);
|
||||
fireEvent.click(getButton("View message"));
|
||||
expect(dis.dispatch).toHaveBeenCalledWith({
|
||||
|
@ -174,6 +188,7 @@ describe("RoomKnocksBar", () => {
|
|||
room_id: roomId,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
type TestCase = [string, ButtonNames, () => void];
|
||||
it.each<TestCase>([
|
||||
|
|
Loading…
Reference in New Issue