Resilience fix for homeserver without thread notification support (#9565)

* Notification state resilience

* TypeScript strict fixes

* Add tests
This commit is contained in:
Germain 2022-11-10 18:01:19 +00:00 committed by GitHub
parent 8ebdcab7d9
commit ee13e23b15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 20 deletions

View file

@ -16,6 +16,7 @@ limitations under the License.
import { render } from "@testing-library/react";
import { MatrixClient, PendingEventOrdering } from "matrix-js-sdk/src/client";
import { Feature, ServerSupport } from "matrix-js-sdk/src/feature";
import { NotificationCountType, Room } from "matrix-js-sdk/src/models/room";
import React from "react";
@ -34,7 +35,7 @@ describe("RoomHeaderButtons-test.tsx", function() {
stubClient();
client = MatrixClientPeg.get();
room = new Room(ROOM_ID, client, client.getUserId(), {
room = new Room(ROOM_ID, client, client.getUserId() ?? "", {
pendingEventOrdering: PendingEventOrdering.Detached,
});
@ -43,7 +44,7 @@ describe("RoomHeaderButtons-test.tsx", function() {
});
});
function getComponent(room: Room) {
function getComponent(room?: Room) {
return render(<RoomHeaderButtons
room={room}
excludedRightPanelPhaseButtons={[]}
@ -94,4 +95,9 @@ describe("RoomHeaderButtons-test.tsx", function() {
expect(container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")).toBeNull();
});
it("does not explode without a room", () => {
client.canSupport.set(Feature.ThreadUnreadNotifications, ServerSupport.Unsupported);
expect(() => getComponent()).not.toThrow();
});
});