You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

audioVideoModeration.spec.ts 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. import { Participant } from '../../helpers/Participant';
  2. import {
  3. ensureOneParticipant,
  4. ensureThreeParticipants, ensureTwoParticipants,
  5. unmuteAudioAndCheck,
  6. unmuteVideoAndCheck
  7. } from '../../helpers/participants';
  8. describe('AVModeration', () => {
  9. it('check for moderators', async () => {
  10. // if all 3 participants are moderators, skip this test
  11. await ensureThreeParticipants(ctx);
  12. const { p1, p2, p3 } = ctx;
  13. if (!await p1.isModerator()
  14. || (await p1.isModerator() && await p2.isModerator() && await p3.isModerator())) {
  15. ctx.skipSuiteTests = true;
  16. }
  17. });
  18. it('check audio enable/disable', async () => {
  19. const { p1, p3 } = ctx;
  20. const p1ParticipantsPane = p1.getParticipantsPane();
  21. await p1ParticipantsPane.clickContextMenuButton();
  22. await p1ParticipantsPane.getAVModerationMenu().clickStartAudioModeration();
  23. await p1ParticipantsPane.close();
  24. // Here we want to try unmuting and check that we are still muted.
  25. await tryToAudioUnmuteAndCheck(p3, p1);
  26. await p1ParticipantsPane.clickContextMenuButton();
  27. await p1ParticipantsPane.getAVModerationMenu().clickStopAudioModeration();
  28. await p1ParticipantsPane.close();
  29. await unmuteAudioAndCheck(p3, p1);
  30. });
  31. it('check video enable/disable', async () => {
  32. const { p1, p3 } = ctx;
  33. const p1ParticipantsPane = p1.getParticipantsPane();
  34. await p1ParticipantsPane.clickContextMenuButton();
  35. await p1ParticipantsPane.getAVModerationMenu().clickStartVideoModeration();
  36. await p1ParticipantsPane.close();
  37. // Here we want to try unmuting and check that we are still muted.
  38. await tryToVideoUnmuteAndCheck(p3, p1);
  39. await p1ParticipantsPane.clickContextMenuButton();
  40. await p1ParticipantsPane.getAVModerationMenu().clickStopVideoModeration();
  41. await p1ParticipantsPane.close();
  42. await unmuteVideoAndCheck(p3, p1);
  43. });
  44. it('unmute by moderator', async () => {
  45. const { p1, p2, p3 } = ctx;
  46. await unmuteByModerator(p1, p3, true, true);
  47. // moderation is stopped at this point, make sure participants 1 & 2 are also unmuted,
  48. // participant3 was unmuted by unmuteByModerator
  49. await unmuteAudioAndCheck(p2, p1);
  50. await unmuteVideoAndCheck(p2, p1);
  51. await unmuteAudioAndCheck(p1, p2);
  52. await unmuteVideoAndCheck(p1, p2);
  53. });
  54. it('hangup and change moderator', async () => {
  55. await Promise.all([ ctx.p2.hangup(), ctx.p3.hangup() ]);
  56. await ensureThreeParticipants(ctx);
  57. const { p1, p2, p3 } = ctx;
  58. await p2.getToolbar().clickAudioMuteButton();
  59. await p3.getToolbar().clickAudioMuteButton();
  60. const p1ParticipantsPane = p1.getParticipantsPane();
  61. await p1ParticipantsPane.clickContextMenuButton();
  62. await p1ParticipantsPane.getAVModerationMenu().clickStartAudioModeration();
  63. await p1ParticipantsPane.getAVModerationMenu().clickStartVideoModeration();
  64. await p2.getToolbar().clickRaiseHandButton();
  65. await p3.getToolbar().clickRaiseHandButton();
  66. await p1.hangup();
  67. // we don't use ensureThreeParticipants to avoid all meeting join checks
  68. // all participants are muted and checks for media will fail
  69. await ensureOneParticipant(ctx);
  70. // After p1 re-joins either p2 or p3 is promoted to moderator. They should still be muted.
  71. const isP2Moderator = await p2.isModerator();
  72. const moderator = isP2Moderator ? p2 : p3;
  73. const nonModerator = isP2Moderator ? p3 : p2;
  74. const moderatorParticipantsPane = moderator.getParticipantsPane();
  75. const nonModeratorParticipantsPane = nonModerator.getParticipantsPane();
  76. await moderatorParticipantsPane.assertVideoMuteIconIsDisplayed(moderator);
  77. await nonModeratorParticipantsPane.assertVideoMuteIconIsDisplayed(nonModerator);
  78. await moderatorParticipantsPane.allowVideo(nonModerator);
  79. await moderatorParticipantsPane.askToUnmute(nonModerator, false);
  80. await nonModerator.getNotifications().waitForAskToUnmuteNotification();
  81. await unmuteAudioAndCheck(nonModerator, p1);
  82. await unmuteVideoAndCheck(nonModerator, p1);
  83. await moderatorParticipantsPane.clickContextMenuButton();
  84. await moderatorParticipantsPane.getAVModerationMenu().clickStopAudioModeration();
  85. await moderatorParticipantsPane.getAVModerationMenu().clickStopVideoModeration();
  86. });
  87. it('grant moderator', async () => {
  88. await Promise.all([ ctx.p1.hangup(), ctx.p2.hangup(), ctx.p3.hangup() ]);
  89. await ensureThreeParticipants(ctx);
  90. const { p1, p2, p3 } = ctx;
  91. const p1ParticipantsPane = p1.getParticipantsPane();
  92. await p1ParticipantsPane.clickContextMenuButton();
  93. await p1ParticipantsPane.getAVModerationMenu().clickStartAudioModeration();
  94. await p1ParticipantsPane.getAVModerationMenu().clickStartVideoModeration();
  95. await p1.getFilmstrip().grantModerator(p3);
  96. await p3.driver.waitUntil(
  97. () => p3.isModerator(), {
  98. timeout: 5000,
  99. timeoutMsg: `${p3.name} is not moderator`
  100. });
  101. await unmuteByModerator(p3, p2, false, true);
  102. });
  103. it('ask to unmute', async () => {
  104. await Promise.all([ ctx.p1.hangup(), ctx.p2.hangup(), ctx.p3.hangup() ]);
  105. await ensureTwoParticipants(ctx);
  106. const { p1, p2 } = ctx;
  107. // mute p2
  108. await p2.getToolbar().clickAudioMuteButton();
  109. // ask p2 to unmute
  110. await p1.getParticipantsPane().askToUnmute(p2, true);
  111. await p2.getNotifications().waitForAskToUnmuteNotification();
  112. await p1.getParticipantsPane().close();
  113. });
  114. it('remove from whitelist', async () => {
  115. const { p1, p2 } = ctx;
  116. await unmuteByModerator(p1, p2, true, false);
  117. // p1 mute audio on p2 and check
  118. await p1.getParticipantsPane().muteAudio(p2);
  119. await p1.getFilmstrip().assertAudioMuteIconIsDisplayed(p2);
  120. await p2.getFilmstrip().assertAudioMuteIconIsDisplayed(p2);
  121. // we try to unmute and test it that it was still muted
  122. await tryToAudioUnmuteAndCheck(p2, p1);
  123. // stop video and check
  124. await p1.getFilmstrip().muteVideo(p2);
  125. await p1.getParticipantsPane().assertVideoMuteIconIsDisplayed(p2);
  126. await p2.getParticipantsPane().assertVideoMuteIconIsDisplayed(p2);
  127. await tryToVideoUnmuteAndCheck(p2, p1);
  128. });
  129. it('join moderated', async () => {
  130. await Promise.all([ ctx.p1.hangup(), ctx.p2.hangup(), ctx.p3.hangup() ]);
  131. await ensureOneParticipant(ctx);
  132. const p1ParticipantsPane = ctx.p1.getParticipantsPane();
  133. await p1ParticipantsPane.clickContextMenuButton();
  134. await p1ParticipantsPane.getAVModerationMenu().clickStartAudioModeration();
  135. await p1ParticipantsPane.getAVModerationMenu().clickStartVideoModeration();
  136. await p1ParticipantsPane.close();
  137. // join with second participant and check
  138. await ensureTwoParticipants(ctx, {
  139. skipInMeetingChecks: true
  140. });
  141. const { p1, p2 } = ctx;
  142. await tryToAudioUnmuteAndCheck(p2, p1);
  143. await tryToVideoUnmuteAndCheck(p2, p1);
  144. // asked to unmute and check
  145. await unmuteByModerator(p1, p2, false, false);
  146. // mute and check
  147. await p1.getParticipantsPane().muteAudio(p2);
  148. await p1.getFilmstrip().assertAudioMuteIconIsDisplayed(p2);
  149. await p2.getFilmstrip().assertAudioMuteIconIsDisplayed(p2);
  150. await tryToAudioUnmuteAndCheck(p2, p1);
  151. });
  152. });
  153. /**
  154. * Checks a user can unmute after being asked by moderator.
  155. * @param moderator - The participant that is moderator.
  156. * @param participant - The participant being asked to unmute.
  157. * @param turnOnModeration - if we want to turn on moderation before testing (when it is currently off).
  158. * @param stopModeration - true if moderation to be stopped when done.
  159. */
  160. async function unmuteByModerator(
  161. moderator: Participant,
  162. participant: Participant,
  163. turnOnModeration: boolean,
  164. stopModeration: boolean) {
  165. const moderatorParticipantsPane = moderator.getParticipantsPane();
  166. if (turnOnModeration) {
  167. await moderatorParticipantsPane.clickContextMenuButton();
  168. await moderatorParticipantsPane.getAVModerationMenu().clickStartAudioModeration();
  169. await moderatorParticipantsPane.getAVModerationMenu().clickStartVideoModeration();
  170. await moderatorParticipantsPane.close();
  171. }
  172. // raise hand to speak
  173. await participant.getToolbar().clickRaiseHandButton();
  174. await moderator.getNotifications().waitForRaisedHandNotification();
  175. // ask participant to unmute
  176. await moderatorParticipantsPane.allowVideo(participant);
  177. await moderatorParticipantsPane.askToUnmute(participant, false);
  178. await participant.getNotifications().waitForAskToUnmuteNotification();
  179. await unmuteAudioAndCheck(participant, moderator);
  180. await unmuteVideoAndCheck(participant, moderator);
  181. if (stopModeration) {
  182. await moderatorParticipantsPane.clickContextMenuButton();
  183. await moderatorParticipantsPane.getAVModerationMenu().clickStopAudioModeration();
  184. await moderatorParticipantsPane.getAVModerationMenu().clickStopVideoModeration();
  185. await moderatorParticipantsPane.close();
  186. }
  187. }
  188. /**
  189. * In case of moderation, tries to audio unmute but stays muted.
  190. * Checks locally and remotely that this is still the case.
  191. * @param participant
  192. * @param observer
  193. */
  194. async function tryToAudioUnmuteAndCheck(participant: Participant, observer: Participant) {
  195. // try to audio unmute and check
  196. await participant.getToolbar().clickAudioUnmuteButton();
  197. // Check local audio muted icon state
  198. await participant.getFilmstrip().assertAudioMuteIconIsDisplayed(participant);
  199. await observer.getFilmstrip().assertAudioMuteIconIsDisplayed(participant);
  200. }
  201. /**
  202. * In case of moderation, tries to video unmute but stays muted.
  203. * Checks locally and remotely that this is still the case.
  204. * @param participant
  205. * @param observer
  206. */
  207. async function tryToVideoUnmuteAndCheck(participant: Participant, observer: Participant) {
  208. // try to video unmute and check
  209. await participant.getToolbar().clickVideoUnmuteButton();
  210. // Check local audio muted icon state
  211. await participant.getParticipantsPane().assertVideoMuteIconIsDisplayed(participant);
  212. await observer.getParticipantsPane().assertVideoMuteIconIsDisplayed(participant);
  213. }