-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1178 from tchapgouv/1179-remove-notification-powe…
…rlevels TCHAP: remove notification power levels changes
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only | ||
Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { mocked } from "jest-mock"; | ||
import { MatrixEvent, EventType } from "matrix-js-sdk/src/matrix"; | ||
|
||
import { haveRendererForEvent } from "~tchap-web/src/events/EventTileFactory"; | ||
import { stubClient } from "~tchap-web/test/test-utils"; | ||
import { eventTriggersUnreadCount } from "~tchap-web/src/Unread"; | ||
import { MatrixClientPeg } from "~tchap-web/src/MatrixClientPeg"; | ||
|
||
jest.mock("~tchap-web/src/events/EventTileFactory", () => ({ | ||
haveRendererForEvent: jest.fn(), | ||
})); | ||
|
||
describe("Unread", () => { | ||
// A different user. | ||
const aliceId = "@alice:server.org"; | ||
stubClient(); | ||
const client = MatrixClientPeg.safeGet(); | ||
|
||
// :TCHAP: remove-notification-powerlevel-change | ||
describe("Don't show power levels change in notification", () => { | ||
// setup events | ||
const powerLevelEvent = new MatrixEvent({ | ||
type: EventType.RoomPowerLevels, | ||
sender: client.getUserId()!, | ||
}); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
mocked(haveRendererForEvent).mockClear().mockReturnValue(false); | ||
}); | ||
|
||
it("returns false when the event was sent by the current user", () => { | ||
expect(eventTriggersUnreadCount(client, powerLevelEvent)).toBe(false); | ||
// returned early before checking renderer | ||
expect(haveRendererForEvent).not.toHaveBeenCalled(); | ||
}); | ||
|
||
const noUnreadEventTypes = [ | ||
EventType.RoomMember, | ||
EventType.RoomThirdPartyInvite, | ||
EventType.CallAnswer, | ||
EventType.CallHangup, | ||
EventType.RoomCanonicalAlias, | ||
EventType.RoomServerAcl, | ||
EventType.RoomPowerLevels, | ||
]; | ||
|
||
it.each(noUnreadEventTypes)( | ||
"returns false without checking for renderer for events with type %s", | ||
(eventType) => { | ||
const event = new MatrixEvent({ | ||
type: eventType, | ||
sender: aliceId, | ||
}); | ||
expect(eventTriggersUnreadCount(client, event)).toBe(false); | ||
expect(haveRendererForEvent).not.toHaveBeenCalled(); | ||
}, | ||
); | ||
}); | ||
}); |