Respect UIFeature.Voip (#29873)

* respect UIFeature.Voip

* Add unit tests

* reset sdk and mocks

* Update RoomHeader-test.tsx.snap

* use useSettingValue

* lint
This commit is contained in:
David Langley
2025-05-02 16:05:30 +01:00
committed by GitHub
parent 671e55c5a2
commit 9ec54c534d
3 changed files with 40 additions and 8 deletions

View File

@@ -226,6 +226,37 @@ describe("RoomHeader", () => {
expect(screen.queryByRole("button", { name: "Voice call" })).not.toBeInTheDocument();
});
describe("UIFeature.Voip disabled", () => {
beforeEach(() => {
SdkConfig.put({
setting_defaults: {
[UIFeature.Voip]: false,
},
});
});
afterEach(() => {
SdkConfig.reset();
jest.restoreAllMocks();
});
it("should not show call buttons in rooms smaller than 3 members", async () => {
mockRoomMembers(room, 2);
render(<RoomHeader room={room} />, getWrapper());
expect(screen.queryByRole("button", { name: "Video call" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Voice call" })).not.toBeInTheDocument();
});
it("should not show call button in rooms larger than 2 members", async () => {
mockRoomMembers(room, 3);
render(<RoomHeader room={room} />, getWrapper());
expect(screen.queryByRole("button", { name: "Video call" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Voice call" })).not.toBeInTheDocument();
});
});
describe("UIFeature.Widgets enabled (default)", () => {
beforeEach(() => {
SdkConfig.put({

View File

@@ -55,7 +55,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
style="--cpd-icon-button-size: 100%; --cpd-color-icon-tertiary: var(--cpd-color-icon-disabled);"
>
<svg
aria-labelledby="«r1c8»"
aria-labelledby="«r1do»"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@@ -71,7 +71,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
<button
aria-disabled="true"
aria-label="There's no one here to call"
aria-labelledby="«r1cd»"
aria-labelledby="«r1dt»"
class="_icon-button_m2erp_8"
role="button"
style="--cpd-icon-button-size: 32px;"
@@ -96,7 +96,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
</button>
<button
aria-label="Threads"
aria-labelledby="«r1ci»"
aria-labelledby="«r1e2»"
class="_icon-button_m2erp_8"
role="button"
style="--cpd-icon-button-size: 32px;"
@@ -122,7 +122,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
</button>
<button
aria-label="Room info"
aria-labelledby="«r1cn»"
aria-labelledby="«r1e7»"
class="_icon-button_m2erp_8"
role="button"
style="--cpd-icon-button-size: 32px;"