Bail out of RoomSettingsDialog
when room is not found (#10662)
* hack to fix console noise from unfaked timers and clearAllModals * remove old debug logging in AsyncWrapper * pass room to room settings tabs * add errorboundary for roomsettingsdialog * apply strictnullchecks to tabs/room * dedupe code to set toom in roomsettingdialog * add unit tests * test SecurityRoomSettingsTab * remove snapshot * strict fixes * more tests * 2% more test coverage * remove roomName from RoomSettingsDialogs state
This commit is contained in:
parent
f6e8ffe750
commit
223892bf0e
19 changed files with 1077 additions and 121 deletions
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { fireEvent, render, RenderResult } from "@testing-library/react";
|
||||
import { fireEvent, render, RenderResult, screen } from "@testing-library/react";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { mocked } from "jest-mock";
|
||||
|
@ -36,7 +36,7 @@ describe("AdvancedRoomSettingsTab", () => {
|
|||
let room: Room;
|
||||
|
||||
const renderTab = (): RenderResult => {
|
||||
return render(<AdvancedRoomSettingsTab roomId={roomId} closeSettingsFn={jest.fn()} />);
|
||||
return render(<AdvancedRoomSettingsTab room={room} closeSettingsFn={jest.fn()} />);
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -69,6 +69,22 @@ describe("AdvancedRoomSettingsTab", () => {
|
|||
tab.getByText("custom_room_version_1");
|
||||
});
|
||||
|
||||
it("displays message when room cannot federate", () => {
|
||||
const createEvent = new MatrixEvent({
|
||||
sender: "@a:b.com",
|
||||
type: EventType.RoomCreate,
|
||||
content: { "m.federate": false },
|
||||
room_id: room.roomId,
|
||||
state_key: "",
|
||||
});
|
||||
jest.spyOn(room.currentState, "getStateEvents").mockImplementation((type) =>
|
||||
type === EventType.RoomCreate ? createEvent : null,
|
||||
);
|
||||
|
||||
renderTab();
|
||||
expect(screen.getByText("This room is not accessible by remote Matrix servers")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
function mockStateEvents(room: Room) {
|
||||
const createEvent = mkEvent({
|
||||
event: true,
|
||||
|
@ -143,5 +159,16 @@ describe("AdvancedRoomSettingsTab", () => {
|
|||
metricsViaKeyboard: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("handles when room is a space", async () => {
|
||||
mockStateEvents(room);
|
||||
jest.spyOn(room, "isSpaceRoom").mockReturnValue(true);
|
||||
|
||||
mockStateEvents(room);
|
||||
const tab = renderTab();
|
||||
const link = await tab.findByText("View older version of test room.");
|
||||
expect(link).toBeInTheDocument();
|
||||
expect(screen.getByText("Space information")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue