Merge branch 'develop' into travis/remove-skinning
This commit is contained in:
commit
4057833036
74 changed files with 1412 additions and 1717 deletions
|
@ -28,20 +28,19 @@ import {
|
|||
mkEvent,
|
||||
stubVoiceChannelStore,
|
||||
} from "../../../test-utils";
|
||||
import { stubVideoChannelStore } from "../../../test-utils/video";
|
||||
import RoomTile from "../../../../src/components/views/rooms/RoomTile";
|
||||
import MemberAvatar from "../../../../src/components/views/avatars/MemberAvatar";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/VoiceChannelStore";
|
||||
import { DefaultTagID } from "../../../../src/stores/room-list/models";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
import { VOICE_CHANNEL_MEMBER } from "../../../../src/utils/VoiceChannelUtils";
|
||||
import { VIDEO_CHANNEL_MEMBER } from "../../../../src/utils/VideoChannelUtils";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import PlatformPeg from "../../../../src/PlatformPeg";
|
||||
import BasePlatform from "../../../../src/BasePlatform";
|
||||
|
||||
const mkVoiceChannelMember = (userId: string, devices: string[]): MatrixEvent => mkEvent({
|
||||
const mkVideoChannelMember = (userId: string, devices: string[]): MatrixEvent => mkEvent({
|
||||
event: true,
|
||||
type: VOICE_CHANNEL_MEMBER,
|
||||
type: VIDEO_CHANNEL_MEMBER,
|
||||
room: "!1:example.org",
|
||||
user: userId,
|
||||
skey: userId,
|
||||
|
@ -58,36 +57,25 @@ describe("RoomTile", () => {
|
|||
beforeEach(() => {
|
||||
const realGetValue = SettingsStore.getValue;
|
||||
SettingsStore.getValue = <T, >(name: string, roomId?: string): T => {
|
||||
if (name === "feature_voice_rooms") {
|
||||
if (name === "feature_video_rooms") {
|
||||
return true as unknown as T;
|
||||
}
|
||||
return realGetValue(name, roomId);
|
||||
};
|
||||
|
||||
stubClient();
|
||||
stubVoiceChannelStore();
|
||||
DMRoomMap.makeShared();
|
||||
|
||||
cli = mocked(MatrixClientPeg.get());
|
||||
store = VoiceChannelStore.instance;
|
||||
store = stubVideoChannelStore();
|
||||
DMRoomMap.makeShared();
|
||||
});
|
||||
|
||||
afterEach(() => jest.clearAllMocks());
|
||||
|
||||
describe("voice rooms", () => {
|
||||
describe("video rooms", () => {
|
||||
const room = mkRoom(cli, "!1:example.org");
|
||||
room.isCallRoom.mockReturnValue(true);
|
||||
|
||||
it("tracks connection state", async () => {
|
||||
// Insert a breakpoint in the connect method, so we can see the intermediate connecting state
|
||||
let continueJoin;
|
||||
const breakpoint = new Promise(resolve => continueJoin = resolve);
|
||||
const realConnect = store.connect;
|
||||
store.connect = async () => {
|
||||
await breakpoint;
|
||||
await realConnect();
|
||||
};
|
||||
room.isElementVideoRoom.mockReturnValue(true);
|
||||
|
||||
it("tracks connection state", () => {
|
||||
const tile = mount(
|
||||
<RoomTile
|
||||
room={room}
|
||||
|
@ -96,39 +84,25 @@ describe("RoomTile", () => {
|
|||
tag={DefaultTagID.Untagged}
|
||||
/>,
|
||||
);
|
||||
expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Voice room");
|
||||
expect(tile.find(".mx_RoomTile_videoIndicator").text()).toEqual("Video");
|
||||
|
||||
act(() => { tile.simulate("click"); });
|
||||
act(() => { store.connect("!1:example.org"); });
|
||||
tile.update();
|
||||
expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Connecting...");
|
||||
|
||||
// Now we confirm the join and wait for the store to update
|
||||
const waitForConnect = new Promise<void>(resolve =>
|
||||
store.once(VoiceChannelEvent.Connect, resolve),
|
||||
);
|
||||
continueJoin();
|
||||
await waitForConnect;
|
||||
// Wait exactly 2 ticks for the room tile to update
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
expect(tile.find(".mx_RoomTile_videoIndicator").text()).toEqual("Connected");
|
||||
|
||||
act(() => { store.disconnect(); });
|
||||
tile.update();
|
||||
expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Connected");
|
||||
|
||||
await store.disconnect();
|
||||
|
||||
tile.update();
|
||||
expect(tile.find(".mx_RoomTile_voiceIndicator").text()).toEqual("Voice room");
|
||||
expect(tile.find(".mx_RoomTile_videoIndicator").text()).toEqual("Video");
|
||||
});
|
||||
|
||||
it("displays connected members", async () => {
|
||||
it("displays connected members", () => {
|
||||
mocked(room.currentState).getStateEvents.mockImplementation(mockStateEventImplementation([
|
||||
// A user connected from 2 devices
|
||||
mkVoiceChannelMember("@alice:example.org", ["device 1", "device 2"]),
|
||||
mkVideoChannelMember("@alice:example.org", ["device 1", "device 2"]),
|
||||
// A disconnected user
|
||||
mkVoiceChannelMember("@bob:example.org", []),
|
||||
mkVideoChannelMember("@bob:example.org", []),
|
||||
// A user that claims to have a connected device, but has left the room
|
||||
mkVoiceChannelMember("@chris:example.org", ["device 1"]),
|
||||
mkVideoChannelMember("@chris:example.org", ["device 1"]),
|
||||
]));
|
||||
|
||||
mocked(room.currentState).getMember.mockImplementation(userId => ({
|
||||
|
@ -151,9 +125,8 @@ describe("RoomTile", () => {
|
|||
);
|
||||
|
||||
// Only Alice should display as connected
|
||||
const avatar = tile.find(MemberAvatar);
|
||||
expect(avatar.length).toEqual(1);
|
||||
expect(avatar.props().member.userId).toEqual("@alice:example.org");
|
||||
const participants = tile.find(".mx_RoomTile_videoParticipants");
|
||||
expect(participants.text()).toEqual("1");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
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 React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import { act } from "react-dom/test-utils";
|
||||
import { mocked } from "jest-mock";
|
||||
|
||||
import {
|
||||
stubClient,
|
||||
mkStubRoom,
|
||||
wrapInMatrixClientContext,
|
||||
stubVoiceChannelStore,
|
||||
} from "../../../test-utils";
|
||||
import _VoiceChannelRadio from "../../../../src/components/views/voip/VoiceChannelRadio";
|
||||
import VoiceChannelStore from "../../../../src/stores/VoiceChannelStore";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
|
||||
const VoiceChannelRadio = wrapInMatrixClientContext(_VoiceChannelRadio);
|
||||
|
||||
describe("VoiceChannelRadio", () => {
|
||||
const cli = mocked(MatrixClientPeg.get());
|
||||
const room = mkStubRoom("!1:example.org", "voice channel", cli);
|
||||
room.isCallRoom = () => true;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
stubVoiceChannelStore();
|
||||
DMRoomMap.makeShared();
|
||||
});
|
||||
|
||||
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