Incoming Element Calls now trigger a regular OS notification (#33499)
* Fix missing OS-level desktop notification for Element Call (MSC4075) * Add Unit-test for textForCallInviteEvent and lint fixes * Refactor call invite notification * prettier fix * Added mock supportsVoip for notifier-test
This commit is contained in:
@@ -131,6 +131,9 @@ describe("Notifier", () => {
|
||||
decryptEventIfNeeded: jest.fn(),
|
||||
getRoom: jest.fn(),
|
||||
getPushActionsForEvent: jest.fn(),
|
||||
// Mock required because TextForEvent now evaluates supportsVoip for RTCNotification to trigger OS popups.
|
||||
// The true/false value is arbitrary here, as this test only verifies the in-app toast creation, not the OS text output.
|
||||
supportsVoip: jest.fn().mockReturnValue(true),
|
||||
supportsThreads: jest.fn().mockReturnValue(false),
|
||||
matrixRTC: {
|
||||
on: jest.fn(),
|
||||
|
||||
@@ -492,6 +492,48 @@ describe("TextForEvent", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("textForCallInviteEvent()", () => {
|
||||
let mockClient: MatrixClient;
|
||||
let callInviteEvent: MatrixEvent;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
mockClient = MatrixClientPeg.safeGet();
|
||||
|
||||
mocked(mockClient.supportsVoip).mockReturnValue(true);
|
||||
|
||||
callInviteEvent = {
|
||||
getSender: jest.fn().mockReturnValue("@alice:matrix.org"),
|
||||
sender: { name: "Alice" },
|
||||
getContent: jest.fn().mockReturnValue({}),
|
||||
getType: jest.fn().mockReturnValue(EventType.CallInvite),
|
||||
isState: jest.fn().mockReturnValue(false),
|
||||
} as unknown as MatrixEvent;
|
||||
});
|
||||
|
||||
it("returns correct message for legacy voice call invite", () => {
|
||||
mocked(callInviteEvent).getContent.mockReturnValue({ offer: { sdp: "m=audio" } });
|
||||
expect(textForEvent(callInviteEvent, mockClient)).toEqual("Alice placed a voice call.");
|
||||
});
|
||||
|
||||
it("returns correct message for legacy video call invite", () => {
|
||||
mocked(callInviteEvent).getContent.mockReturnValue({ offer: { sdp: "m=video" } });
|
||||
expect(textForEvent(callInviteEvent, mockClient)).toEqual("Alice placed a video call.");
|
||||
});
|
||||
|
||||
it("returns correct message for MSC4075 voice call", () => {
|
||||
mocked(callInviteEvent).getType.mockReturnValue(EventType.RTCNotification);
|
||||
mocked(callInviteEvent).getContent.mockReturnValue({ "m.call.intent": "audio" });
|
||||
expect(textForEvent(callInviteEvent, mockClient)).toEqual("Alice placed a voice call.");
|
||||
});
|
||||
|
||||
it("returns correct message for MSC4075 video call", () => {
|
||||
mocked(callInviteEvent).getType.mockReturnValue(EventType.RTCNotification);
|
||||
mocked(callInviteEvent).getContent.mockReturnValue({ "m.call.intent": "video" });
|
||||
expect(textForEvent(callInviteEvent, mockClient)).toEqual("Alice placed a video call.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("textForMemberEvent()", () => {
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
|
||||
Reference in New Issue
Block a user