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
|
@ -38,24 +38,46 @@ describe("<RoomSettingsDialog />", () => {
|
|||
|
||||
const roomId = "!room:server.org";
|
||||
const room = new Room(roomId, mockClient, userId);
|
||||
room.name = "Test Room";
|
||||
const room2 = new Room("!room2:server.org", mockClient, userId);
|
||||
room2.name = "Another Room";
|
||||
|
||||
jest.spyOn(SettingsStore, "getValue");
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
mockClient.getRoom.mockReturnValue(room);
|
||||
mockClient.getRoom.mockImplementation((roomId) => {
|
||||
if (roomId === room.roomId) return room;
|
||||
if (roomId === room2.roomId) return room2;
|
||||
return null;
|
||||
});
|
||||
|
||||
jest.spyOn(SettingsStore, "getValue").mockReset().mockReturnValue(false);
|
||||
});
|
||||
|
||||
const getComponent = (onFinished = jest.fn()) =>
|
||||
render(<RoomSettingsDialog roomId={roomId} onFinished={onFinished} />, {
|
||||
const getComponent = (onFinished = jest.fn(), propRoomId = roomId) =>
|
||||
render(<RoomSettingsDialog roomId={propRoomId} onFinished={onFinished} />, {
|
||||
wrapper: ({ children }) => (
|
||||
<MatrixClientContext.Provider value={mockClient}>{children}</MatrixClientContext.Provider>
|
||||
),
|
||||
});
|
||||
|
||||
it("catches errors when room is not found", () => {
|
||||
getComponent(undefined, "!room-that-does-not-exist");
|
||||
expect(screen.getByText("Something went wrong!")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("updates when roomId prop changes", () => {
|
||||
const { rerender, getByText } = getComponent(undefined, roomId);
|
||||
|
||||
expect(getByText(`Room Settings - ${room.name}`)).toBeInTheDocument();
|
||||
|
||||
rerender(<RoomSettingsDialog roomId={room2.roomId} onFinished={jest.fn()} />);
|
||||
|
||||
expect(getByText(`Room Settings - ${room2.name}`)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe("Settings tabs", () => {
|
||||
it("renders default tabs correctly", () => {
|
||||
const { container } = getComponent();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue