diff --git a/src/components/views/messages/RoomCreate.tsx b/src/components/views/messages/RoomPredecessorTile.tsx similarity index 92% rename from src/components/views/messages/RoomCreate.tsx rename to src/components/views/messages/RoomPredecessorTile.tsx index ffeb10f3efe..5c47cda56fe 100644 --- a/src/components/views/messages/RoomCreate.tsx +++ b/src/components/views/messages/RoomPredecessorTile.tsx @@ -40,7 +40,7 @@ interface IProps { * A message tile showing that this room was created as an upgrade of a previous * room. */ -export const RoomCreate: React.FC = ({ mxEvent, timestamp }) => { +export const RoomPredecessorTile: React.FC = ({ mxEvent, timestamp }) => { const msc3946ProcessDynamicPredecessor = SettingsStore.getValue("feature_dynamic_room_predecessors"); // Note: we ask the room for its predecessor here, instead of directly using @@ -74,13 +74,14 @@ export const RoomCreate: React.FC = ({ mxEvent, timestamp }) => { if (!roomContext.room || roomContext.room.roomId !== mxEvent.getRoomId()) { logger.warn( - "RoomCreate unexpectedly used outside of the context of the room containing this m.room.create event.", + "RoomPredecessorTile unexpectedly used outside of the context of the" + + "room containing this m.room.create event.", ); return <>; } if (!predecessor) { - logger.warn("RoomCreate unexpectedly used in a room with no predecessor."); + logger.warn("RoomPredecessorTile unexpectedly used in a room with no predecessor."); return
; } diff --git a/src/events/EventTileFactory.tsx b/src/events/EventTileFactory.tsx index 95e41395ac3..7f1a31518ad 100644 --- a/src/events/EventTileFactory.tsx +++ b/src/events/EventTileFactory.tsx @@ -34,7 +34,7 @@ import LegacyCallEvent from "../components/views/messages/LegacyCallEvent"; import { CallEvent } from "../components/views/messages/CallEvent"; import TextualEvent from "../components/views/messages/TextualEvent"; import EncryptionEvent from "../components/views/messages/EncryptionEvent"; -import { RoomCreate } from "../components/views/messages/RoomCreate"; +import { RoomPredecessorTile } from "../components/views/messages/RoomPredecessorTile"; import RoomAvatarEvent from "../components/views/messages/RoomAvatarEvent"; import { WIDGET_LAYOUT_EVENT_TYPE } from "../stores/widgets/WidgetLayoutStore"; import { ALL_RULE_TYPES } from "../mjolnir/BanList"; @@ -92,7 +92,7 @@ const HiddenEventFactory: Factory = (ref, props) => ; export const JSONEventFactory: Factory = (ref, props) => ; -export const RoomCreateEventFactory: Factory = (ref, props) => ; +export const RoomCreateEventFactory: Factory = (_ref, props) => ; const EVENT_TILE_TYPES = new Map([ [EventType.RoomMessage, MessageEventFactory], // note that verification requests are handled in pickFactory() diff --git a/test/components/views/messages/RoomCreate-test.tsx b/test/components/views/messages/RoomPredecessorTile-test.tsx similarity index 91% rename from test/components/views/messages/RoomCreate-test.tsx rename to test/components/views/messages/RoomPredecessorTile-test.tsx index cd5afa7ee2e..61bf8e82c5a 100644 --- a/test/components/views/messages/RoomCreate-test.tsx +++ b/test/components/views/messages/RoomPredecessorTile-test.tsx @@ -22,7 +22,7 @@ import { EventType, MatrixEvent, Room } from "matrix-js-sdk/src/matrix"; import dis from "../../../../src/dispatcher/dispatcher"; import SettingsStore from "../../../../src/settings/SettingsStore"; -import { RoomCreate } from "../../../../src/components/views/messages/RoomCreate"; +import { RoomPredecessorTile } from "../../../../src/components/views/messages/RoomPredecessorTile"; import { stubClient, upsertRoomStateEvents } from "../../../test-utils/test-utils"; import { Action } from "../../../../src/dispatcher/actions"; import RoomContext from "../../../../src/contexts/RoomContext"; @@ -31,7 +31,7 @@ import { MatrixClientPeg } from "../../../../src/MatrixClientPeg"; jest.mock("../../../../src/dispatcher/dispatcher"); -describe("", () => { +describe("", () => { const userId = "@alice:server.org"; const roomId = "!room:server.org"; const createEvent = new MatrixEvent({ @@ -97,21 +97,21 @@ describe("", () => { jest.spyOn(SettingsStore, "setValue").mockRestore(); }); - function renderRoomCreate(room: Room) { + function renderTile(room: Room) { return render( - + , ); } it("Renders as expected", () => { - const roomCreate = renderRoomCreate(roomJustCreate); + const roomCreate = renderTile(roomJustCreate); expect(roomCreate.asFragment()).toMatchSnapshot(); }); it("Links to the old version of the room", () => { - renderRoomCreate(roomJustCreate); + renderTile(roomJustCreate); expect(screen.getByText("Click here to see older messages.")).toHaveAttribute( "href", "https://matrix.to/#/old_room_id/tombstone_event_id", @@ -119,12 +119,12 @@ describe("", () => { }); it("Shows an empty div if there is no predecessor", () => { - renderRoomCreate(roomNoPredecessors); + renderTile(roomNoPredecessors); expect(screen.queryByText("Click here to see older messages.", { exact: false })).toBeNull(); }); it("Opens the old room on click", async () => { - renderRoomCreate(roomJustCreate); + renderTile(roomJustCreate); const link = screen.getByText("Click here to see older messages."); await act(() => userEvent.click(link)); @@ -142,7 +142,7 @@ describe("", () => { }); it("Ignores m.predecessor if labs flag is off", () => { - renderRoomCreate(roomCreateAndPredecessor); + renderTile(roomCreateAndPredecessor); expect(screen.getByText("Click here to see older messages.")).toHaveAttribute( "href", "https://matrix.to/#/old_room_id/tombstone_event_id", @@ -161,7 +161,7 @@ describe("", () => { }); it("Uses the create event if there is no m.predecessor", () => { - renderRoomCreate(roomJustCreate); + renderTile(roomJustCreate); expect(screen.getByText("Click here to see older messages.")).toHaveAttribute( "href", "https://matrix.to/#/old_room_id/tombstone_event_id", @@ -169,7 +169,7 @@ describe("", () => { }); it("Uses m.predecessor when it's there", () => { - renderRoomCreate(roomCreateAndPredecessor); + renderTile(roomCreateAndPredecessor); expect(screen.getByText("Click here to see older messages.")).toHaveAttribute( "href", "https://matrix.to/#/old_room_id_from_predecessor", @@ -177,7 +177,7 @@ describe("", () => { }); it("Links to the event in the room if event ID is provided", () => { - renderRoomCreate(roomCreateAndPredecessorWithEventId); + renderTile(roomCreateAndPredecessorWithEventId); expect(screen.getByText("Click here to see older messages.")).toHaveAttribute( "href", "https://matrix.to/#/old_room_id_from_predecessor/tombstone_event_id_from_predecessor", diff --git a/test/components/views/messages/__snapshots__/RoomCreate-test.tsx.snap b/test/components/views/messages/__snapshots__/RoomPredecessorTile-test.tsx.snap similarity index 88% rename from test/components/views/messages/__snapshots__/RoomCreate-test.tsx.snap rename to test/components/views/messages/__snapshots__/RoomPredecessorTile-test.tsx.snap index 97c1cee66f6..5e692de3fd5 100644 --- a/test/components/views/messages/__snapshots__/RoomCreate-test.tsx.snap +++ b/test/components/views/messages/__snapshots__/RoomPredecessorTile-test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` Renders as expected 1`] = ` +exports[` Renders as expected 1`] = `