Improve live voice broadcast detection by testing if the started event has been redacted (#9780)

This commit is contained in:
Michael Weimann 2022-12-22 11:37:07 +01:00 committed by GitHub
parent fbc3228143
commit b81582d045
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 365 additions and 83 deletions

View file

@ -34,6 +34,7 @@ import {
wrapInMatrixClientContext,
wrapInSdkContext,
mkRoomCreateEvent,
flushPromises,
} from "../../../test-utils";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import { CallStore } from "../../../../src/stores/CallStore";
@ -70,6 +71,12 @@ describe("PipView", () => {
let voiceBroadcastPreRecordingStore: VoiceBroadcastPreRecordingStore;
let voiceBroadcastPlaybacksStore: VoiceBroadcastPlaybacksStore;
const actFlushPromises = async () => {
await act(async () => {
await flushPromises();
});
};
beforeEach(async () => {
stubClient();
client = mocked(MatrixClientPeg.get());
@ -264,10 +271,11 @@ describe("PipView", () => {
});
describe("when there is a voice broadcast recording and pre-recording", () => {
beforeEach(() => {
beforeEach(async () => {
setUpVoiceBroadcastPreRecording();
setUpVoiceBroadcastRecording();
renderPip();
await actFlushPromises();
});
it("should render the voice broadcast recording PiP", () => {
@ -277,10 +285,11 @@ describe("PipView", () => {
});
describe("when there is a voice broadcast playback and pre-recording", () => {
beforeEach(() => {
beforeEach(async () => {
mkVoiceBroadcast(room);
setUpVoiceBroadcastPreRecording();
renderPip();
await actFlushPromises();
});
it("should render the voice broadcast pre-recording PiP", () => {
@ -290,9 +299,10 @@ describe("PipView", () => {
});
describe("when there is a voice broadcast pre-recording", () => {
beforeEach(() => {
beforeEach(async () => {
setUpVoiceBroadcastPreRecording();
renderPip();
await actFlushPromises();
});
it("should render the voice broadcast pre-recording PiP", () => {
@ -306,6 +316,10 @@ describe("PipView", () => {
setUpRoomViewStore();
viewRoom(room.roomId);
mkVoiceBroadcast(room);
await actFlushPromises();
expect(voiceBroadcastPlaybacksStore.getCurrent()).toBeTruthy();
await voiceBroadcastPlaybacksStore.getCurrent()?.start();
viewRoom(room2.roomId);
renderPip();
@ -322,11 +336,12 @@ describe("PipView", () => {
describe("when viewing a room with a live voice broadcast", () => {
let startEvent!: MatrixEvent;
beforeEach(() => {
beforeEach(async () => {
setUpRoomViewStore();
viewRoom(room.roomId);
startEvent = mkVoiceBroadcast(room);
renderPip();
await actFlushPromises();
});
it("should render the voice broadcast playback pip", () => {
@ -335,15 +350,16 @@ describe("PipView", () => {
});
describe("and the broadcast stops", () => {
beforeEach(() => {
act(() => {
const stopEvent = mkVoiceBroadcastInfoStateEvent(
room.roomId,
VoiceBroadcastInfoState.Stopped,
alice.userId,
client.getDeviceId() || "",
startEvent,
);
beforeEach(async () => {
const stopEvent = mkVoiceBroadcastInfoStateEvent(
room.roomId,
VoiceBroadcastInfoState.Stopped,
alice.userId,
client.getDeviceId() || "",
startEvent,
);
await act(async () => {
room.currentState.setStateEvents([stopEvent]);
defaultDispatcher.dispatch<IRoomStateEventsActionPayload>(
{
@ -354,6 +370,7 @@ describe("PipView", () => {
},
true,
);
await flushPromises();
});
});
@ -364,9 +381,10 @@ describe("PipView", () => {
});
describe("and leaving the room", () => {
beforeEach(() => {
act(() => {
beforeEach(async () => {
await act(async () => {
viewRoom(room2.roomId);
await flushPromises();
});
});