Ensure correct focus configuration for Element Call before allowing users to call. (#31490)

* fixup type

* Validate Element Call foci config

* revert changes

* Split out logic to CallStore so we don't repeat checks.

* Refactor to use CallStore so we only fetch once.

* Add test for useRoomCall

* lint

* Ensure we enable MatrixRTC when configuring element call.

* fix test

* Update @element-hq/element-web-playwright-common to 2.2.2 and enable matrix rtc

* lint

* Ensure call is configured for header test

* type

* Improve coverage

* Update based on feedback

* fix type
This commit is contained in:
Will Hunt
2026-01-09 12:04:31 +00:00
committed by GitHub
parent 239527996a
commit 7ad6b4b411
9 changed files with 290 additions and 20 deletions
@@ -17,6 +17,7 @@ import {
Room,
RoomStateEvent,
RoomMember,
type MatrixClient,
} from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import { CryptoEvent, UserVerificationStatus } from "matrix-js-sdk/src/crypto-api";
@@ -37,7 +38,7 @@ import { type ViewRoomOpts } from "@matrix-org/react-sdk-module-api/lib/lifecycl
import { mocked } from "jest-mock";
import userEvent from "@testing-library/user-event";
import { filterConsole, stubClient } from "../../../../../test-utils";
import { filterConsole, setupAsyncStoreWithClient, stubClient } from "../../../../../test-utils";
import RoomHeader from "../../../../../../src/components/views/rooms/RoomHeader/RoomHeader";
import DMRoomMap from "../../../../../../src/utils/DMRoomMap";
import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg";
@@ -85,12 +86,14 @@ describe("RoomHeader", () => {
emit: jest.fn(),
};
let client: MatrixClient;
let roomContext: RoomContextType;
function getWrapper(): RenderOptions {
return {
wrapper: ({ children }) => (
<MatrixClientContext.Provider value={MatrixClientPeg.safeGet()}>
<MatrixClientContext.Provider value={client}>
<ScopedRoomContextProvider {...roomContext}>{children}</ScopedRoomContextProvider>
</MatrixClientContext.Provider>
),
@@ -98,8 +101,8 @@ describe("RoomHeader", () => {
}
beforeEach(async () => {
stubClient();
room = new Room(ROOM_ID, MatrixClientPeg.get()!, "@alice:example.org", {
client = stubClient();
room = new Room(ROOM_ID, client, "@alice:example.org", {
pendingEventOrdering: PendingEventOrdering.Detached,
});
DMRoomMap.setShared({
@@ -405,12 +408,18 @@ describe("RoomHeader", () => {
});
describe("group call enabled", () => {
beforeEach(() => {
beforeEach(async () => {
SdkConfig.put({
features: {
feature_group_calls: true,
},
});
// Enable Element Call
client._unstable_getRTCTransports = jest
.fn()
.mockResolvedValue([{ type: "livekit", livekit_service_url: "https://example.org" }]);
// And ensure the CallStore has the transports configured.
await setupAsyncStoreWithClient(CallStore.instance, client);
});
afterEach(() => {