Resilience fix for homeserver without thread notification support (#9565)
* Notification state resilience * TypeScript strict fixes * Add tests
This commit is contained in:
parent
8ebdcab7d9
commit
ee13e23b15
2 changed files with 30 additions and 20 deletions
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue