Voice Broadcast playback (#9372)

* Implement actual voice broadcast playback

* Move PublicInterface type to test

* Implement pausing a voice broadcast playback

* Implement PR feedback

* Remove unnecessary early return
This commit is contained in:
Michael Weimann 2022-10-14 16:48:54 +02:00 committed by GitHub
parent 54008cff58
commit cb5667b4a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 505 additions and 63 deletions

View file

@ -79,7 +79,7 @@ describe("VoiceBroadcastBody", () => {
client = stubClient();
infoEvent = mkVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Started);
testRecording = new VoiceBroadcastRecording(infoEvent, client);
testPlayback = new VoiceBroadcastPlayback(infoEvent);
testPlayback = new VoiceBroadcastPlayback(infoEvent, client);
mocked(VoiceBroadcastRecordingBody).mockImplementation(({ recording }) => {
if (testRecording === recording) {
return <div data-testid="voice-broadcast-recording-body" />;

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import React from "react";
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
import { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";
import { render, RenderResult } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
@ -23,7 +23,6 @@ import {
VoiceBroadcastInfoEventType,
VoiceBroadcastPlayback,
VoiceBroadcastPlaybackBody,
VoiceBroadcastPlaybackState,
} from "../../../../src/voice-broadcast";
import { mkEvent, stubClient } from "../../../test-utils";
@ -38,11 +37,12 @@ jest.mock("../../../../src/components/views/avatars/RoomAvatar", () => ({
describe("VoiceBroadcastPlaybackBody", () => {
const userId = "@user:example.com";
const roomId = "!room:example.com";
let client: MatrixClient;
let infoEvent: MatrixEvent;
let playback: VoiceBroadcastPlayback;
beforeAll(() => {
stubClient();
client = stubClient();
infoEvent = mkEvent({
event: true,
type: VoiceBroadcastInfoEventType,
@ -50,7 +50,8 @@ describe("VoiceBroadcastPlaybackBody", () => {
room: roomId,
user: userId,
});
playback = new VoiceBroadcastPlayback(infoEvent);
playback = new VoiceBroadcastPlayback(infoEvent, client);
jest.spyOn(playback, "toggle");
});
describe("when rendering a broadcast", () => {
@ -69,8 +70,8 @@ describe("VoiceBroadcastPlaybackBody", () => {
await userEvent.click(renderResult.getByLabelText("resume voice broadcast"));
});
it("should stop the recording", () => {
expect(playback.getState()).toBe(VoiceBroadcastPlaybackState.Playing);
it("should toggle the recording", () => {
expect(playback.toggle).toHaveBeenCalled();
});
});
});