Fix tests
This commit is contained in:
@@ -245,6 +245,21 @@ function summarizeLayout$(l$: Observable<Layout>): Observable<LayoutSummary> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mockRingEvent(
|
||||||
|
eventId: string,
|
||||||
|
lifetimeMs: number | undefined,
|
||||||
|
): { event_id: string } & IRTCNotificationContent {
|
||||||
|
return {
|
||||||
|
event_id: eventId,
|
||||||
|
...(lifetimeMs === undefined ? {} : { lifetime: lifetimeMs }),
|
||||||
|
notification_type: "ring",
|
||||||
|
} 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;
|
||||||
|
|
||||||
interface CallViewModelInputs {
|
interface CallViewModelInputs {
|
||||||
remoteParticipants$: Behavior<RemoteParticipant[]>;
|
remoteParticipants$: Behavior<RemoteParticipant[]>;
|
||||||
rtcMembers$: Behavior<Partial<CallMembership>[]>;
|
rtcMembers$: Behavior<Partial<CallMembership>[]>;
|
||||||
@@ -1213,12 +1228,8 @@ describe("waitForCallPickup$", () => {
|
|||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{ event_id: "$notif1", lifetime: 30 } as unknown as {
|
mockRingEvent("$notif1", 30),
|
||||||
event_id: string;
|
mockLegacyRingEvent,
|
||||||
} & IRTCNotificationContent,
|
|
||||||
{ event_id: "$notif1" } as unknown as {
|
|
||||||
event_id: string;
|
|
||||||
} & ICallNotifyContent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1257,15 +1268,8 @@ describe("waitForCallPickup$", () => {
|
|||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{
|
mockRingEvent("$notif2", 100),
|
||||||
event_id: "$notif2",
|
mockLegacyRingEvent,
|
||||||
lifetime: 100,
|
|
||||||
} as unknown as IRTCNotificationContent & {
|
|
||||||
event_id: string;
|
|
||||||
},
|
|
||||||
{ event_id: "$notif2" } as unknown as ICallNotifyContent & {
|
|
||||||
event_id: string;
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1303,12 +1307,8 @@ describe("waitForCallPickup$", () => {
|
|||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{ event_id: "$notif3", lifetime: 50 } as unknown as {
|
mockRingEvent("$notif3", 50),
|
||||||
event_id: string;
|
mockLegacyRingEvent,
|
||||||
} & IRTCNotificationContent,
|
|
||||||
{ event_id: "$notif3" } as unknown as {
|
|
||||||
event_id: string;
|
|
||||||
} & ICallNotifyContent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1334,12 +1334,8 @@ describe("waitForCallPickup$", () => {
|
|||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{ event_id: "$notif4" } as unknown as {
|
mockRingEvent("$notif4", undefined),
|
||||||
event_id: string;
|
mockLegacyRingEvent,
|
||||||
} & IRTCNotificationContent, // no lifetime
|
|
||||||
{ event_id: "$notif4" } as unknown as {
|
|
||||||
event_id: string;
|
|
||||||
} & ICallNotifyContent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1374,12 +1370,8 @@ describe("waitForCallPickup$", () => {
|
|||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{ event_id: "$notif5", lifetime: 30 } as unknown as {
|
mockRingEvent("$notif5", 30),
|
||||||
event_id: string;
|
mockLegacyRingEvent,
|
||||||
} & IRTCNotificationContent,
|
|
||||||
{ event_id: "$notif5" } as unknown as {
|
|
||||||
event_id: string;
|
|
||||||
} & ICallNotifyContent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1396,25 +1388,17 @@ describe("waitForCallPickup$", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("decline before timeout window ends -> decline", () => {
|
test("decline before timeout window ends -> decline", () => {
|
||||||
withTestScheduler(({ hot, schedule, expectObservable, scope }) => {
|
withTestScheduler(({ schedule, expectObservable }) => {
|
||||||
withCallViewModel(
|
withCallViewModel(
|
||||||
{
|
{},
|
||||||
remoteParticipants$: scope.behavior(hot("a", { a: [] }), []),
|
|
||||||
rtcMembers$: scope.behavior(hot("a", { a: [localRtcMember] }), []),
|
|
||||||
connectionState$: of(ConnectionState.Connected),
|
|
||||||
},
|
|
||||||
(vm, rtcSession) => {
|
(vm, rtcSession) => {
|
||||||
// Notify at 10ms with 50ms lifetime, decline at 40ms with matching id
|
// Notify at 10ms with 50ms lifetime, decline at 40ms with matching id
|
||||||
schedule(" 10ms r 29ms d", {
|
schedule(" 10ms r 29ms d", {
|
||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{ event_id: "$decl1", lifetime: 50 } as unknown as {
|
mockRingEvent("$decl1", 50),
|
||||||
event_id: string;
|
mockLegacyRingEvent,
|
||||||
} & IRTCNotificationContent,
|
|
||||||
{ event_id: "$decl1" } as unknown as {
|
|
||||||
event_id: string;
|
|
||||||
} & ICallNotifyContent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
d: () => {
|
d: () => {
|
||||||
@@ -1454,23 +1438,15 @@ describe("waitForCallPickup$", () => {
|
|||||||
test("decline after timeout window ends -> stays timeout", () => {
|
test("decline after timeout window ends -> stays timeout", () => {
|
||||||
withTestScheduler(({ hot, schedule, expectObservable, scope }) => {
|
withTestScheduler(({ hot, schedule, expectObservable, scope }) => {
|
||||||
withCallViewModel(
|
withCallViewModel(
|
||||||
{
|
{},
|
||||||
remoteParticipants$: scope.behavior(hot("a", { a: [] }), []),
|
|
||||||
rtcMembers$: scope.behavior(hot("a", { a: [localRtcMember] }), []),
|
|
||||||
connectionState$: of(ConnectionState.Connected),
|
|
||||||
},
|
|
||||||
(vm, rtcSession) => {
|
(vm, rtcSession) => {
|
||||||
// Notify at 10ms with 20ms lifetime (timeout at 30ms), decline at 40ms
|
// Notify at 10ms with 20ms lifetime (timeout at 30ms), decline at 40ms
|
||||||
schedule(" 10ms r 20ms t 10ms d", {
|
schedule(" 10ms r 20ms t 10ms d", {
|
||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{ event_id: "$decl2", lifetime: 20 } as unknown as {
|
mockRingEvent("$decl2", 20),
|
||||||
event_id: string;
|
mockLegacyRingEvent,
|
||||||
} & IRTCNotificationContent,
|
|
||||||
{ event_id: "$decl2" } as unknown as {
|
|
||||||
event_id: string;
|
|
||||||
} & ICallNotifyContent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
t: () => {},
|
t: () => {},
|
||||||
@@ -1502,23 +1478,15 @@ describe("waitForCallPickup$", () => {
|
|||||||
test("decline with wrong id is ignored (stays ringing)", () => {
|
test("decline with wrong id is ignored (stays ringing)", () => {
|
||||||
withTestScheduler(({ hot, schedule, expectObservable, scope }) => {
|
withTestScheduler(({ hot, schedule, expectObservable, scope }) => {
|
||||||
withCallViewModel(
|
withCallViewModel(
|
||||||
{
|
{},
|
||||||
remoteParticipants$: scope.behavior(hot("a", { a: [] }), []),
|
|
||||||
rtcMembers$: scope.behavior(hot("a", { a: [localRtcMember] }), []),
|
|
||||||
connectionState$: of(ConnectionState.Connected),
|
|
||||||
},
|
|
||||||
(vm, rtcSession) => {
|
(vm, rtcSession) => {
|
||||||
// Notify at 10ms with id A, decline arrives at 20ms with id B
|
// Notify at 10ms with id A, decline arrives at 20ms with id B
|
||||||
schedule(" 10ms r 10ms d", {
|
schedule(" 10ms r 10ms d", {
|
||||||
r: () => {
|
r: () => {
|
||||||
rtcSession.emit(
|
rtcSession.emit(
|
||||||
MatrixRTCSessionEvent.DidSendCallNotification,
|
MatrixRTCSessionEvent.DidSendCallNotification,
|
||||||
{ event_id: "$right", lifetime: 50 } as unknown as {
|
mockRingEvent("$right", 50),
|
||||||
event_id: string;
|
mockLegacyRingEvent,
|
||||||
} & IRTCNotificationContent,
|
|
||||||
{ event_id: "$right" } as unknown as {
|
|
||||||
event_id: string;
|
|
||||||
} & ICallNotifyContent,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
d: () => {
|
d: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user