Voice rooms prototype (#8084)
* Add voice room labs flag Signed-off-by: Robin Townsend <robin@robin.town> * Add more widget actions for interacting with Jitsi Signed-off-by: Robin Townsend <robin@robin.town> * Factor out a more generic Jitsi creation utility Signed-off-by: Robin Townsend <robin@robin.town> * Add utilities for managing voice channels Signed-off-by: Robin Townsend <robin@robin.town> * Enable creation of voice rooms Signed-off-by: Robin Townsend <robin@robin.town> * Force a maximized view of voice channel widgets Signed-off-by: Robin Townsend <robin@robin.town> * Add voice channel store Signed-off-by: Robin Townsend <robin@robin.town> * Factor out a more generic FacePile Signed-off-by: Robin Townsend <robin@robin.town> * Implement room tile changes for voice rooms Signed-off-by: Robin Townsend <robin@robin.town> * Add interactive radio component to the left panel Signed-off-by: Robin Townsend <robin@robin.town> * Test voice rooms Signed-off-by: Robin Townsend <robin@robin.town> * Update name of call room type Signed-off-by: Robin Townsend <robin@robin.town> * Clarify that voice rooms are under development Signed-off-by: Robin Townsend <robin@robin.town> * Use readonly Signed-off-by: Robin Townsend <robin@robin.town> * Move acks to the end of handlers Signed-off-by: Robin Townsend <robin@robin.town> * Add comment about avatar URLs coming from Jitsi Signed-off-by: Robin Townsend <robin@robin.town> * Don't use unicode ellipses for translation reasons? Signed-off-by: Robin Townsend <robin@robin.town> * Fix tests Signed-off-by: Robin Townsend <robin@robin.town> * Fix tests, again Signed-off-by: Robin Townsend <robin@robin.town> * Remove unnecessary export Signed-off-by: Robin Townsend <robin@robin.town> * Ack Jitsi events when we wait for them Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
parent
f416a970ca
commit
cfabcdda35
32 changed files with 1302 additions and 238 deletions
141
test/components/views/voip/VoiceChannelRadio-test.tsx
Normal file
141
test/components/views/voip/VoiceChannelRadio-test.tsx
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
import React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import { act } from "react-dom/test-utils";
|
||||
|
||||
import "../../../skinned-sdk";
|
||||
import { stubClient, mkStubRoom, wrapInMatrixClientContext } from "../../../test-utils";
|
||||
import _VoiceChannelRadio from "../../../../src/components/views/voip/VoiceChannelRadio";
|
||||
import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/VoiceChannelStore";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
|
||||
const VoiceChannelRadio = wrapInMatrixClientContext(_VoiceChannelRadio);
|
||||
|
||||
class StubVoiceChannelStore extends EventEmitter {
|
||||
private _roomId: string;
|
||||
public get roomId(): string { return this._roomId; }
|
||||
private _audioMuted: boolean;
|
||||
public get audioMuted(): boolean { return this._audioMuted; }
|
||||
private _videoMuted: boolean;
|
||||
public get videoMuted(): boolean { return this._videoMuted; }
|
||||
|
||||
public connect = jest.fn().mockImplementation(async (roomId: string) => {
|
||||
this._roomId = roomId;
|
||||
this._audioMuted = true;
|
||||
this._videoMuted = true;
|
||||
this.emit(VoiceChannelEvent.Connect);
|
||||
});
|
||||
public disconnect = jest.fn().mockImplementation(async () => {
|
||||
this._roomId = null;
|
||||
this.emit(VoiceChannelEvent.Disconnect);
|
||||
});
|
||||
public muteAudio = jest.fn().mockImplementation(async () => {
|
||||
this._audioMuted = true;
|
||||
this.emit(VoiceChannelEvent.MuteAudio);
|
||||
});
|
||||
public unmuteAudio = jest.fn().mockImplementation(async () => {
|
||||
this._audioMuted = false;
|
||||
this.emit(VoiceChannelEvent.UnmuteAudio);
|
||||
});
|
||||
public muteVideo = jest.fn().mockImplementation(async () => {
|
||||
this._videoMuted = true;
|
||||
this.emit(VoiceChannelEvent.MuteVideo);
|
||||
});
|
||||
public unmuteVideo = jest.fn().mockImplementation(async () => {
|
||||
this._videoMuted = false;
|
||||
this.emit(VoiceChannelEvent.UnmuteVideo);
|
||||
});
|
||||
}
|
||||
|
||||
describe("VoiceChannelRadio", () => {
|
||||
const room = mkStubRoom("!1:example.org");
|
||||
room.isCallRoom.mockReturnValue(true);
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
DMRoomMap.makeShared();
|
||||
// Stub out the VoiceChannelStore
|
||||
jest.spyOn(VoiceChannelStore, "instance", "get").mockReturnValue(new StubVoiceChannelStore());
|
||||
});
|
||||
|
||||
it("shows when connecting voice", async () => {
|
||||
const radio = mount(<VoiceChannelRadio />);
|
||||
expect(radio.children().children().exists()).toEqual(false);
|
||||
|
||||
act(() => { VoiceChannelStore.instance.connect("!1:example.org"); });
|
||||
radio.update();
|
||||
expect(radio.children().children().exists()).toEqual(true);
|
||||
});
|
||||
|
||||
it("hides when disconnecting voice", () => {
|
||||
VoiceChannelStore.instance.connect("!1:example.org");
|
||||
const radio = mount(<VoiceChannelRadio />);
|
||||
expect(radio.children().children().exists()).toEqual(true);
|
||||
|
||||
act(() => { VoiceChannelStore.instance.disconnect(); });
|
||||
radio.update();
|
||||
expect(radio.children().children().exists()).toEqual(false);
|
||||
});
|
||||
|
||||
describe("disconnect button", () => {
|
||||
it("works", () => {
|
||||
VoiceChannelStore.instance.connect("!1:example.org");
|
||||
const radio = mount(<VoiceChannelRadio />);
|
||||
|
||||
act(() => {
|
||||
radio.find("AccessibleButton.mx_VoiceChannelRadio_disconnectButton").simulate("click");
|
||||
});
|
||||
expect(VoiceChannelStore.instance.disconnect).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("video button", () => {
|
||||
it("works", () => {
|
||||
VoiceChannelStore.instance.connect("!1:example.org");
|
||||
const radio = mount(<VoiceChannelRadio />);
|
||||
|
||||
act(() => {
|
||||
radio.find("AccessibleButton.mx_VoiceChannelRadio_videoButton").simulate("click");
|
||||
});
|
||||
expect(VoiceChannelStore.instance.unmuteVideo).toHaveBeenCalled();
|
||||
|
||||
act(() => {
|
||||
radio.find("AccessibleButton.mx_VoiceChannelRadio_videoButton").simulate("click");
|
||||
});
|
||||
expect(VoiceChannelStore.instance.muteVideo).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("audio button", () => {
|
||||
it("works", () => {
|
||||
VoiceChannelStore.instance.connect("!1:example.org");
|
||||
const radio = mount(<VoiceChannelRadio />);
|
||||
|
||||
act(() => {
|
||||
radio.find("AccessibleButton.mx_VoiceChannelRadio_audioButton").simulate("click");
|
||||
});
|
||||
expect(VoiceChannelStore.instance.unmuteAudio).toHaveBeenCalled();
|
||||
|
||||
act(() => {
|
||||
radio.find("AccessibleButton.mx_VoiceChannelRadio_audioButton").simulate("click");
|
||||
});
|
||||
expect(VoiceChannelStore.instance.muteAudio).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue