@@ -62,8 +62,9 @@ describe("AddMembersDialog", () => {
6262
6363 const setup = ( options ?: {
6464 customRoomAuthorization ?: RoomAuthorizationRefs ;
65- schoolRole ?: RoleName . Teacher | RoleName . Student ;
65+ schoolRole ?: RoleName . Teacher | RoleName . Student | RoleName . Administrator ;
6666 isOpen ?: boolean ;
67+ isAdminMode ?: boolean ;
6768 } ) => {
6869 const configDefaults = {
6970 canAddRoomMembers : true ,
@@ -96,6 +97,7 @@ describe("AddMembersDialog", () => {
9697 wrapper = mount ( AddMembersDialog , {
9798 props : {
9899 modelValue : options ?. isOpen ?? true ,
100+ isAdminMode : options ?. isAdminMode ?? false ,
99101 } ,
100102 attachTo : document . body ,
101103 global : {
@@ -206,139 +208,6 @@ describe("AddMembersDialog", () => {
206208 } ) ;
207209 } ) ;
208210
209- describe ( "when school is changed" , ( ) => {
210- it ( "should call resetPotentialMembers" , async ( ) => {
211- const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
212- const selectedSchool = roomMembersSchools [ 1 ] . id ;
213- const schoolComponent = wrapper . getComponent ( {
214- ref : "autoCompleteSchool" ,
215- } ) ;
216-
217- await schoolComponent . setValue ( selectedSchool ) ;
218-
219- expect ( roomMembersStore . resetPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
220- } ) ;
221-
222- it ( "should reset selectedUsers" , async ( ) => {
223- const { wrapper } = setup ( ) ;
224- const schoolComponent = wrapper . getComponent ( {
225- ref : "autoCompleteSchool" ,
226- } ) ;
227-
228- const userComponent = wrapper . getComponent ( {
229- ref : "autoCompleteUsers" ,
230- } ) ;
231-
232- await schoolComponent . setValue ( "schoolId" ) ;
233-
234- expect ( userComponent . props ( "modelValue" ) ) . toEqual ( [ ] ) ;
235- } ) ;
236-
237- it ( "should call getPotentialMembers for set role" , async ( ) => {
238- const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
239- const selectedSchool = roomMembersSchools [ 1 ] . id ;
240- const schoolComponent = wrapper . getComponent ( {
241- ref : "autoCompleteSchool" ,
242- } ) ;
243- const roleComponent = wrapper . getComponent ( {
244- ref : "selectRole" ,
245- } ) ;
246- const selectedRole = roleComponent . props ( "modelValue" ) ;
247-
248- await schoolComponent . setValue ( selectedSchool ) ;
249-
250- expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
251- expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledWith ( selectedRole , selectedSchool ) ;
252- } ) ;
253- } ) ;
254-
255- describe ( "when userRole is changed" , ( ) => {
256- it ( "should call resetPotentialMembers" , async ( ) => {
257- const { wrapper, roomMembersStore } = setup ( ) ;
258- const selectedRole = RoleName . Student ;
259- const roleComponent = wrapper . getComponent ( {
260- ref : "selectRole" ,
261- } ) ;
262-
263- await roleComponent . setValue ( selectedRole ) ;
264-
265- expect ( roomMembersStore . resetPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
266- } ) ;
267-
268- it ( "should reset selectedUsers" , async ( ) => {
269- const { wrapper } = setup ( ) ;
270- const roleComponent = wrapper . getComponent ( {
271- ref : "selectRole" ,
272- } ) ;
273-
274- const userComponent = wrapper . getComponent ( {
275- ref : "autoCompleteUsers" ,
276- } ) ;
277-
278- await roleComponent . setValue ( RoleName . Roomeditor ) ;
279-
280- expect ( userComponent . props ( "modelValue" ) ) . toEqual ( [ ] ) ;
281- } ) ;
282-
283- describe ( "and the role is set to student" , ( ) => {
284- it ( "should call getPotentialMembers for student role" , async ( ) => {
285- const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
286- const selectedRole = RoleName . Student ;
287- const roleComponent = wrapper . getComponent ( {
288- ref : "selectRole" ,
289- } ) ;
290-
291- await roleComponent . setValue ( selectedRole ) ;
292-
293- expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
294- expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledWith ( selectedRole , roomMembersSchools [ 0 ] . id ) ;
295- } ) ;
296-
297- it ( "should render an icon with text for student role" , async ( ) => {
298- const { wrapper } = setup ( ) ;
299-
300- const roleComponent = wrapper . getComponent ( {
301- ref : "selectRole" ,
302- } ) ;
303- await roleComponent . setValue ( RoleName . Student ) ;
304-
305- const roleIcon = roleComponent . findComponent ( VIcon ) ;
306-
307- expect ( roleIcon . props ( "icon" ) ) . toBe ( mdiAccountOutline ) ;
308- expect ( roleComponent . text ( ) ) . toContain ( "common.labels.student.neutral" ) ;
309- } ) ;
310- } ) ;
311-
312- describe ( "and the role is set to teacher" , ( ) => {
313- it ( "should call getPotentialMembers for teacher role" , async ( ) => {
314- const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
315- const selectedRole = RoleName . Teacher ;
316- const roleComponent = wrapper . getComponent ( {
317- ref : "selectRole" ,
318- } ) ;
319-
320- await roleComponent . setValue ( selectedRole ) ;
321-
322- expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
323- expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledWith ( selectedRole , roomMembersSchools [ 0 ] . id ) ;
324- } ) ;
325-
326- it ( "should render an icon with text for teacher role" , async ( ) => {
327- const { wrapper } = setup ( ) ;
328-
329- const roleComponent = wrapper . getComponent ( {
330- ref : "selectRole" ,
331- } ) ;
332-
333- await roleComponent . setValue ( RoleName . Teacher ) ;
334- const roleIcon = roleComponent . findComponent ( VIcon ) ;
335-
336- expect ( roleIcon . props ( "icon" ) ) . toBe ( mdiAccountSchoolOutline ) ;
337- expect ( roleComponent . text ( ) ) . toContain ( "common.labels.teacher.neutral" ) ;
338- } ) ;
339- } ) ;
340- } ) ;
341-
342211 describe ( "when user(s) selected" , ( ) => {
343212 it ( "should add user to selectedUsers" , async ( ) => {
344213 const { wrapper, potentialRoomMembers } = setup ( ) ;
@@ -619,6 +488,171 @@ describe("AddMembersDialog", () => {
619488 } ) ;
620489 } ) ;
621490
491+ describe ( "when it is used by an administrator in the room administration" , ( ) => {
492+ it ( "should not allow the school role to be changed" , ( ) => {
493+ const { wrapper } = setup ( { schoolRole : RoleName . Administrator , isOpen : true , isAdminMode : true } ) ;
494+ const roleSelect = wrapper . getComponent ( {
495+ ref : "selectRole" ,
496+ } ) ;
497+
498+ expect ( roleSelect . props ( "readonly" ) ) . toBe ( true ) ;
499+ expect ( roleSelect . props ( "menuIcon" ) ) . toBe ( "" ) ;
500+ } ) ;
501+ it ( "the school role should be set to teacher" , ( ) => {
502+ const { wrapper } = setup ( { schoolRole : RoleName . Administrator , isOpen : true , isAdminMode : true } ) ;
503+ const roleSelect = wrapper . getComponent ( {
504+ ref : "selectRole" ,
505+ } ) ;
506+
507+ expect ( roleSelect . props ( "modelValue" ) ) . toBe ( RoleName . Teacher ) ;
508+ } ) ;
509+ } ) ;
510+
511+ describe ( "when it is used by a teacher in the room management" , ( ) => {
512+ it ( "should allow the school role to be changed" , ( ) => {
513+ const { wrapper } = setup ( { schoolRole : RoleName . Teacher , isOpen : true , isAdminMode : false } ) ;
514+ const roleSelect = wrapper . getComponent ( {
515+ ref : "selectRole" ,
516+ } ) ;
517+
518+ expect ( roleSelect . props ( "readonly" ) ) . toBe ( false ) ;
519+ expect ( roleSelect . props ( "menuIcon" ) ) . not . toBe ( "" ) ;
520+ } ) ;
521+
522+ describe ( "when school is changed" , ( ) => {
523+ it ( "should call resetPotentialMembers" , async ( ) => {
524+ const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
525+ const selectedSchool = roomMembersSchools [ 1 ] . id ;
526+ const schoolComponent = wrapper . getComponent ( {
527+ ref : "autoCompleteSchool" ,
528+ } ) ;
529+
530+ await schoolComponent . setValue ( selectedSchool ) ;
531+
532+ expect ( roomMembersStore . resetPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
533+ } ) ;
534+
535+ it ( "should reset selectedUsers" , async ( ) => {
536+ const { wrapper } = setup ( ) ;
537+ const schoolComponent = wrapper . getComponent ( {
538+ ref : "autoCompleteSchool" ,
539+ } ) ;
540+
541+ const userComponent = wrapper . getComponent ( {
542+ ref : "autoCompleteUsers" ,
543+ } ) ;
544+
545+ await schoolComponent . setValue ( "schoolId" ) ;
546+
547+ expect ( userComponent . props ( "modelValue" ) ) . toEqual ( [ ] ) ;
548+ } ) ;
549+
550+ it ( "should call getPotentialMembers for set role" , async ( ) => {
551+ const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
552+ const selectedSchool = roomMembersSchools [ 1 ] . id ;
553+ const schoolComponent = wrapper . getComponent ( {
554+ ref : "autoCompleteSchool" ,
555+ } ) ;
556+ const roleComponent = wrapper . getComponent ( {
557+ ref : "selectRole" ,
558+ } ) ;
559+ const selectedRole = roleComponent . props ( "modelValue" ) ;
560+
561+ await schoolComponent . setValue ( selectedSchool ) ;
562+
563+ expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
564+ expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledWith ( selectedRole , selectedSchool ) ;
565+ } ) ;
566+ } ) ;
567+
568+ describe ( "when userRole is changed" , ( ) => {
569+ it ( "should call resetPotentialMembers" , async ( ) => {
570+ const { wrapper, roomMembersStore } = setup ( ) ;
571+ const selectedRole = RoleName . Student ;
572+ const roleComponent = wrapper . getComponent ( {
573+ ref : "selectRole" ,
574+ } ) ;
575+
576+ await roleComponent . setValue ( selectedRole ) ;
577+
578+ expect ( roomMembersStore . resetPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
579+ } ) ;
580+
581+ it ( "should reset selectedUsers" , async ( ) => {
582+ const { wrapper } = setup ( ) ;
583+ const roleComponent = wrapper . getComponent ( {
584+ ref : "selectRole" ,
585+ } ) ;
586+
587+ const userComponent = wrapper . getComponent ( {
588+ ref : "autoCompleteUsers" ,
589+ } ) ;
590+
591+ await roleComponent . setValue ( RoleName . Roomeditor ) ;
592+
593+ expect ( userComponent . props ( "modelValue" ) ) . toEqual ( [ ] ) ;
594+ } ) ;
595+
596+ describe ( "and the role is set to student" , ( ) => {
597+ it ( "should call getPotentialMembers for student role" , async ( ) => {
598+ const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
599+ const selectedRole = RoleName . Student ;
600+ const roleComponent = wrapper . getComponent ( {
601+ ref : "selectRole" ,
602+ } ) ;
603+
604+ await roleComponent . setValue ( selectedRole ) ;
605+
606+ expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
607+ expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledWith ( selectedRole , roomMembersSchools [ 0 ] . id ) ;
608+ } ) ;
609+
610+ it ( "should render an icon with text for student role" , async ( ) => {
611+ const { wrapper } = setup ( ) ;
612+
613+ const roleComponent = wrapper . getComponent ( {
614+ ref : "selectRole" ,
615+ } ) ;
616+ await roleComponent . setValue ( RoleName . Student ) ;
617+
618+ const roleIcon = roleComponent . findComponent ( VIcon ) ;
619+
620+ expect ( roleIcon . props ( "icon" ) ) . toBe ( mdiAccountOutline ) ;
621+ expect ( roleComponent . text ( ) ) . toContain ( "common.labels.student.neutral" ) ;
622+ } ) ;
623+ } ) ;
624+
625+ describe ( "and the role is set to teacher" , ( ) => {
626+ it ( "should call getPotentialMembers for teacher role" , async ( ) => {
627+ const { wrapper, roomMembersSchools, roomMembersStore } = setup ( ) ;
628+ const selectedRole = RoleName . Teacher ;
629+ const roleComponent = wrapper . getComponent ( {
630+ ref : "selectRole" ,
631+ } ) ;
632+
633+ await roleComponent . setValue ( selectedRole ) ;
634+
635+ expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledTimes ( 1 ) ;
636+ expect ( roomMembersStore . getPotentialMembers ) . toHaveBeenCalledWith ( selectedRole , roomMembersSchools [ 0 ] . id ) ;
637+ } ) ;
638+
639+ it ( "should render an icon with text for teacher role" , async ( ) => {
640+ const { wrapper } = setup ( ) ;
641+
642+ const roleComponent = wrapper . getComponent ( {
643+ ref : "selectRole" ,
644+ } ) ;
645+
646+ await roleComponent . setValue ( RoleName . Teacher ) ;
647+ const roleIcon = roleComponent . findComponent ( VIcon ) ;
648+
649+ expect ( roleIcon . props ( "icon" ) ) . toBe ( mdiAccountSchoolOutline ) ;
650+ expect ( roleComponent . text ( ) ) . toContain ( "common.labels.teacher.neutral" ) ;
651+ } ) ;
652+ } ) ;
653+ } ) ;
654+ } ) ;
655+
622656 describe ( "when current user is a student admin" , ( ) => {
623657 it ( "should disable the school selection with current users school selected" , ( ) => {
624658 const { mockedMe, wrapper } = setup ( { schoolRole : RoleName . Student } ) ;
0 commit comments