@@ -61,6 +61,7 @@ import { _t } from "../../../../src/languageHandler";
61
61
import * as UseCall from "../../../../src/hooks/useCall" ;
62
62
import { SdkContextClass } from "../../../../src/contexts/SDKContext" ;
63
63
import WidgetStore , { IApp } from "../../../../src/stores/WidgetStore" ;
64
+ import { UIFeature } from "../../../../src/settings/UIFeature" ;
64
65
65
66
jest . mock ( "../../../../src/utils/ShieldUtils" ) ;
66
67
@@ -255,7 +256,47 @@ describe("RoomHeader", () => {
255
256
expect ( queryByLabelText ( container , "Voice call" ) ) . not . toBeInTheDocument ( ) ;
256
257
} ) ;
257
258
259
+ describe ( "UIFeature.Widgets enabled (default)" , ( ) => {
260
+ beforeEach ( ( ) => {
261
+ jest . spyOn ( SettingsStore , "getValue" ) . mockImplementation ( ( feature ) => feature == UIFeature . Widgets ) ;
262
+ } ) ;
263
+
264
+ it ( "should show call buttons in a room with 2 members" , ( ) => {
265
+ mockRoomMembers ( room , 2 ) ;
266
+ const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
267
+ expect ( getByLabelText ( container , "Video call" ) ) . toBeInTheDocument ( ) ;
268
+ } ) ;
269
+
270
+ it ( "should show call buttons in a room with more than 2 members" , ( ) => {
271
+ mockRoomMembers ( room , 3 ) ;
272
+ const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
273
+ expect ( getByLabelText ( container , "Video call" ) ) . toBeInTheDocument ( ) ;
274
+ } ) ;
275
+ } ) ;
276
+
277
+ describe ( "UIFeature.Widgets disabled" , ( ) => {
278
+ beforeEach ( ( ) => {
279
+ jest . spyOn ( SettingsStore , "getValue" ) . mockImplementation ( ( feature ) => false ) ;
280
+ } ) ;
281
+
282
+ it ( "should show call buttons in a room with 2 members" , ( ) => {
283
+ mockRoomMembers ( room , 2 ) ;
284
+ const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
285
+ expect ( getByLabelText ( container , "Video call" ) ) . toBeInTheDocument ( ) ;
286
+ } ) ;
287
+
288
+ it ( "should not show call buttons in a room with more than 2 members" , ( ) => {
289
+ mockRoomMembers ( room , 3 ) ;
290
+ const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
291
+ expect ( queryByLabelText ( container , "Video call" ) ) . not . toBeInTheDocument ( ) ;
292
+ } ) ;
293
+ } ) ;
294
+
258
295
describe ( "groups call disabled" , ( ) => {
296
+ beforeEach ( ( ) => {
297
+ jest . spyOn ( SettingsStore , "getValue" ) . mockImplementation ( ( feature ) => feature == UIFeature . Widgets ) ;
298
+ } ) ;
299
+
259
300
it ( "you can't call if you're alone" , ( ) => {
260
301
mockRoomMembers ( room , 1 ) ;
261
302
const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
@@ -313,7 +354,9 @@ describe("RoomHeader", () => {
313
354
314
355
describe ( "group call enabled" , ( ) => {
315
356
beforeEach ( ( ) => {
316
- jest . spyOn ( SettingsStore , "getValue" ) . mockImplementation ( ( feature ) => feature === "feature_group_calls" ) ;
357
+ jest . spyOn ( SettingsStore , "getValue" ) . mockImplementation (
358
+ ( feature ) => feature === "feature_group_calls" || feature == UIFeature . Widgets ,
359
+ ) ;
317
360
} ) ;
318
361
319
362
it ( "renders only the video call element" , async ( ) => {
@@ -353,7 +396,7 @@ describe("RoomHeader", () => {
353
396
354
397
it ( "clicking on ongoing (unpinned) call re-pins it" , ( ) => {
355
398
mockRoomMembers ( room , 3 ) ;
356
- jest . spyOn ( SettingsStore , "getValue" ) . mockReturnValue ( false ) ;
399
+ jest . spyOn ( SettingsStore , "getValue" ) . mockImplementation ( ( feature ) => feature == UIFeature . Widgets ) ;
357
400
// allow calls
358
401
jest . spyOn ( room . currentState , "mayClientSendStateEvent" ) . mockReturnValue ( true ) ;
359
402
jest . spyOn ( WidgetLayoutStore . instance , "isInContainer" ) . mockReturnValue ( false ) ;
0 commit comments