Use server side relations for voice broadcasts (#9534)

This commit is contained in:
Michael Weimann 2022-11-07 15:19:49 +01:00 committed by GitHub
parent 3747464b41
commit 36a574a14f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 396 additions and 192 deletions

View file

@ -35,6 +35,8 @@ import { mkVoiceBroadcastInfoStateEvent } from "../utils/test-utils";
describe("VoiceBroadcastPlaybacksStore", () => {
const roomId = "!room:example.com";
let client: MatrixClient;
let userId: string;
let deviceId: string;
let room: Room;
let infoEvent1: MatrixEvent;
let infoEvent2: MatrixEvent;
@ -45,24 +47,31 @@ describe("VoiceBroadcastPlaybacksStore", () => {
beforeEach(() => {
client = stubClient();
userId = client.getUserId() || "";
deviceId = client.getDeviceId() || "";
mocked(client.relations).mockClear();
mocked(client.relations).mockResolvedValue({ events: [] });
room = mkStubRoom(roomId, "test room", client);
mocked(client.getRoom).mockImplementation((roomId: string) => {
mocked(client.getRoom).mockImplementation((roomId: string): Room | null => {
if (roomId === room.roomId) {
return room;
}
return null;
});
infoEvent1 = mkVoiceBroadcastInfoStateEvent(
roomId,
VoiceBroadcastInfoState.Started,
client.getUserId(),
client.getDeviceId(),
userId,
deviceId,
);
infoEvent2 = mkVoiceBroadcastInfoStateEvent(
roomId,
VoiceBroadcastInfoState.Started,
client.getUserId(),
client.getDeviceId(),
userId,
deviceId,
);
playback1 = new VoiceBroadcastPlayback(infoEvent1, client);
jest.spyOn(playback1, "off");