Revert 'Hide the names of banned users behind a spoiler tag#32424' (#32635)
* Revert 'Hide the names of banned users behind a spoiler tag#32424' * Empty commit to trigger test re-run
This commit is contained in:
@@ -20,7 +20,6 @@ import { KnownMembership } from "matrix-js-sdk/src/types";
|
||||
import { render } from "jest-matrix-react";
|
||||
import { type ReactElement } from "react";
|
||||
import { type Mocked, mocked } from "jest-mock";
|
||||
import React from "react";
|
||||
|
||||
import { hasText, textForEvent } from "../../src/TextForEvent";
|
||||
import SettingsStore from "../../src/settings/SettingsStore";
|
||||
@@ -29,7 +28,6 @@ import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||
import UserIdentifierCustomisations from "../../src/customisations/UserIdentifier";
|
||||
import { getSenderName } from "../../src/utils/event/getSenderName";
|
||||
import { ElementCallEventType } from "../../src/call-types";
|
||||
import Spoiler from "../../src/components/views/elements/Spoiler";
|
||||
|
||||
jest.mock("../../src/settings/SettingsStore");
|
||||
jest.mock("../../src/customisations/UserIdentifier", () => ({
|
||||
@@ -564,50 +562,6 @@ describe("TextForEvent", () => {
|
||||
),
|
||||
).toMatchInlineSnapshot(`"Member rejected the invitation: I don't want to be in this room."`);
|
||||
});
|
||||
|
||||
it("shows single-user bans with a spoiler on display name", () => {
|
||||
mocked(mockClient.getRoom).mockReturnValue({
|
||||
getMember: jest.fn().mockImplementation((userId) => {
|
||||
return { rawDisplayName: userId === "@admin:example.com" ? "Admin" : "Bad User" };
|
||||
}),
|
||||
} as unknown as Mocked<Room>);
|
||||
|
||||
expect(textForEvent(banEventWithReason(), mockClient, true)).toEqual(
|
||||
<span>
|
||||
Admin banned <Spoiler>Bad User</Spoiler>: bad behaviour
|
||||
</span>,
|
||||
);
|
||||
});
|
||||
|
||||
it("hides user name for single-user bans with reason when JSX is not allowed", () => {
|
||||
mocked(mockClient.getRoom).mockReturnValue({
|
||||
getMember: jest.fn().mockImplementation((userId) => {
|
||||
return { rawDisplayName: userId === "@admin:example.com" ? "Admin" : "Bad User" };
|
||||
}),
|
||||
} as unknown as Mocked<Room>);
|
||||
|
||||
expect(textForEvent(banEventWithReason(), mockClient)).toEqual("Admin banned a user: bad behaviour");
|
||||
});
|
||||
|
||||
it("shows single-user bans with a spoiler on user ID", () => {
|
||||
mocked(mockClient.getRoom).mockReturnValue({
|
||||
getMember: jest.fn().mockReturnValue({ rawDisplayName: undefined }),
|
||||
} as unknown as Mocked<Room>);
|
||||
|
||||
expect(textForEvent(banEvent(), mockClient, true)).toEqual(
|
||||
<span>
|
||||
@admin:example.com banned <Spoiler>@bad_name:bad_server.co</Spoiler>
|
||||
</span>,
|
||||
);
|
||||
});
|
||||
|
||||
it("hides user name for single-user bans when JSX is not allowed", () => {
|
||||
mocked(mockClient.getRoom).mockReturnValue({
|
||||
getMember: jest.fn().mockReturnValue({ rawDisplayName: undefined }),
|
||||
} as unknown as Mocked<Room>);
|
||||
|
||||
expect(textForEvent(banEvent(), mockClient)).toEqual("@admin:example.com banned a user");
|
||||
});
|
||||
});
|
||||
|
||||
describe("textForJoinRulesEvent()", () => {
|
||||
@@ -763,26 +717,3 @@ describe("TextForEvent", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function banEvent(): MatrixEvent {
|
||||
return new MatrixEvent({
|
||||
type: "m.room.member",
|
||||
sender: "@admin:example.com",
|
||||
content: {
|
||||
membership: KnownMembership.Ban,
|
||||
},
|
||||
state_key: "@bad_name:bad_server.co",
|
||||
});
|
||||
}
|
||||
|
||||
function banEventWithReason(): MatrixEvent {
|
||||
return new MatrixEvent({
|
||||
type: "m.room.member",
|
||||
sender: "@admin:example.com",
|
||||
content: {
|
||||
membership: KnownMembership.Ban,
|
||||
reason: "bad behaviour",
|
||||
},
|
||||
state_key: "@bad_name:bad_server.co",
|
||||
});
|
||||
}
|
||||
|
||||
+1
-3
@@ -120,9 +120,7 @@ exports[`MessagePanel should handle lots of membership events quickly 1`] = `
|
||||
<span
|
||||
class="mx_TextualEvent mx_GenericEventListSummary_summary"
|
||||
>
|
||||
<span>
|
||||
@user:id made no changes 100 times
|
||||
</span>
|
||||
@user:id made no changes 100 times
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -265,12 +265,7 @@ describe("EventListSummary", function () {
|
||||
|
||||
const { container } = renderComponent(props);
|
||||
const summary = container.querySelector(".mx_GenericEventListSummary_summary");
|
||||
|
||||
// The sequence was summarised correctly
|
||||
expect(summary).toHaveTextContent("user_1 was unbanned, joined and left 7 times and was invited");
|
||||
|
||||
// And there is no spoiler on the user's name since they were not banned
|
||||
expect(summary).not.toContainHTML("mx_EventTile_spoiler_content");
|
||||
});
|
||||
|
||||
it("truncates multiple sequences of repetitions with other events between", function () {
|
||||
@@ -314,14 +309,9 @@ describe("EventListSummary", function () {
|
||||
|
||||
const { container } = renderComponent(props);
|
||||
const summary = container.querySelector(".mx_GenericEventListSummary_summary");
|
||||
|
||||
// The sequence was summarised correctly
|
||||
expect(summary).toHaveTextContent(
|
||||
"user_1 was unbanned, joined and left 2 times, was banned, joined and left 3 times and was invited",
|
||||
"user_1 was unbanned, joined and left 2 times, was banned, " + "joined and left 3 times and was invited",
|
||||
);
|
||||
|
||||
// And the banned user's name is hidden within a spoiler
|
||||
expect(summary).toContainHTML('<span class="mx_EventTile_spoiler_content">user_1</span>');
|
||||
});
|
||||
|
||||
it("handles multiple users following the same sequence of memberships", function () {
|
||||
@@ -371,14 +361,9 @@ describe("EventListSummary", function () {
|
||||
|
||||
const { container } = renderComponent(props);
|
||||
const summary = container.querySelector(".mx_GenericEventListSummary_summary");
|
||||
|
||||
// The sequence was summarised correctly
|
||||
expect(summary).toHaveTextContent(
|
||||
"user_1 and one other were unbanned, joined and left 2 times and were banned",
|
||||
);
|
||||
|
||||
// And the banned user's name is hidden within a spoiler
|
||||
expect(summary).toContainHTML('<span class="mx_EventTile_spoiler_content">user_1</span>');
|
||||
});
|
||||
|
||||
it("handles many users following the same sequence of memberships", function () {
|
||||
@@ -408,14 +393,9 @@ describe("EventListSummary", function () {
|
||||
|
||||
const { container } = renderComponent(props);
|
||||
const summary = container.querySelector(".mx_GenericEventListSummary_summary");
|
||||
|
||||
// The sequence was summarised correctly
|
||||
expect(summary).toHaveTextContent(
|
||||
"user_0 and 19 others were unbanned, joined and left 2 times and were banned",
|
||||
);
|
||||
|
||||
// And the banned user's name is hidden within a spoiler
|
||||
expect(summary).toContainHTML('<span class="mx_EventTile_spoiler_content">user_0</span>');
|
||||
});
|
||||
|
||||
it("correctly orders sequences of transitions by the order of their first event", function () {
|
||||
|
||||
Reference in New Issue
Block a user