Update tests based on new js-sdk changes
(no more legacy notify event)
This commit is contained in:
@@ -5,10 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { type IRTCNotificationContent } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
type ICallNotifyContent,
|
|
||||||
type IRTCNotificationContent,
|
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
|
||||||
import { describe, it } from "vitest";
|
import { describe, it } from "vitest";
|
||||||
import {
|
import {
|
||||||
EventType,
|
EventType,
|
||||||
@@ -30,7 +27,6 @@ import {
|
|||||||
} from "./CallNotificationLifecycle";
|
} from "./CallNotificationLifecycle";
|
||||||
import { trackEpoch } from "../ObservableScope";
|
import { trackEpoch } from "../ObservableScope";
|
||||||
|
|
||||||
const mockLegacyRingEvent = {} as { event_id: string } & ICallNotifyContent;
|
|
||||||
function mockRingEvent(
|
function mockRingEvent(
|
||||||
eventId: string,
|
eventId: string,
|
||||||
lifetimeMs: number | undefined,
|
lifetimeMs: number | undefined,
|
||||||
@@ -54,7 +50,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
behavior("a", { a: [] }).pipe(trackEpoch()),
|
behavior("a", { a: [] }).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$notif1", 30), mockLegacyRingEvent],
|
a: [mockRingEvent("$notif1", 30)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -86,7 +82,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("5ms a", {
|
sentCallNotification$: hot("5ms a", {
|
||||||
a: [mockRingEvent("$notif2", 100), mockLegacyRingEvent],
|
a: [mockRingEvent("$notif2", 100)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -115,7 +111,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("20ms a", {
|
sentCallNotification$: hot("20ms a", {
|
||||||
a: [mockRingEvent("$notif2", 50), mockLegacyRingEvent],
|
a: [mockRingEvent("$notif2", 50)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -142,7 +138,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$notif2", undefined), mockLegacyRingEvent],
|
a: [mockRingEvent("$notif2", undefined)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -171,7 +167,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$notif5", 30), mockLegacyRingEvent],
|
a: [mockRingEvent("$notif5", 30)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -210,7 +206,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$decl1", 50), mockLegacyRingEvent],
|
a: [mockRingEvent("$decl1", 50)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot("40ms d", {
|
receivedDecline$: hot("40ms d", {
|
||||||
d: [
|
d: [
|
||||||
@@ -254,7 +250,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$decl", 20), mockLegacyRingEvent],
|
a: [mockRingEvent("$decl", 20)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot("40ms d", {
|
receivedDecline$: hot("40ms d", {
|
||||||
d: [
|
d: [
|
||||||
@@ -305,7 +301,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$right", 50), mockLegacyRingEvent],
|
a: [mockRingEvent("$right", 50)],
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot("20ms d", {
|
receivedDecline$: hot("20ms d", {
|
||||||
d: [
|
d: [
|
||||||
|
|||||||
@@ -140,9 +140,9 @@ export function createCallNotificationLifecycle$({
|
|||||||
scope.behavior(
|
scope.behavior(
|
||||||
sentCallNotification$.pipe(
|
sentCallNotification$.pipe(
|
||||||
filter(
|
filter(
|
||||||
(newAndLegacyEvents) =>
|
(notificationEventArgs) =>
|
||||||
// only care about new events (legacy do not have decline pattern)
|
// only care about new events (legacy do not have decline pattern)
|
||||||
newAndLegacyEvents?.[0].notification_type === "ring",
|
notificationEventArgs?.[0].notification_type === "ring",
|
||||||
),
|
),
|
||||||
map((e) => e as CallNotificationWrapper),
|
map((e) => e as CallNotificationWrapper),
|
||||||
switchMap(([notificationEvent]) => {
|
switchMap(([notificationEvent]) => {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import {
|
|||||||
Status,
|
Status,
|
||||||
type CallMembership,
|
type CallMembership,
|
||||||
type IRTCNotificationContent,
|
type IRTCNotificationContent,
|
||||||
type ICallNotifyContent,
|
|
||||||
MatrixRTCSessionEvent,
|
MatrixRTCSessionEvent,
|
||||||
type LivekitTransport,
|
type LivekitTransport,
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
@@ -232,10 +231,6 @@ function mockRingEvent(
|
|||||||
} as unknown as { event_id: string } & IRTCNotificationContent;
|
} as unknown as { event_id: string } & IRTCNotificationContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The app doesn't really care about the content of these legacy events, we just
|
|
||||||
// need a value to fill in for them when emitting notifications
|
|
||||||
const mockLegacyRingEvent = {} as { event_id: string } & ICallNotifyContent;
|
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
[MatrixRTCMode.Legacy],
|
[MatrixRTCMode.Legacy],
|
||||||
[MatrixRTCMode.Compatibility],
|
[MatrixRTCMode.Compatibility],
|
||||||
@@ -1109,7 +1104,6 @@ describe.each([
|
|||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
mockRingEvent("$notif1", 30),
|
mockRingEvent("$notif1", 30),
|
||||||
mockLegacyRingEvent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1151,7 +1145,6 @@ describe.each([
|
|||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
mockRingEvent("$notif2", 100),
|
mockRingEvent("$notif2", 100),
|
||||||
mockLegacyRingEvent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
d: () => {
|
d: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user