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.

Notifications.ts 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. import BasePageObject from './BasePageObject';
  2. const ASK_TO_UNMUTE_NOTIFICATION_ID = 'notify.hostAskedUnmute';
  3. const JOIN_ONE_TEST_ID = 'notify.connectedOneMember';
  4. const JOIN_TWO_TEST_ID = 'notify.connectedTwoMembers';
  5. const JOIN_MULTIPLE_TEST_ID = 'notify.connectedThreePlusMembers';
  6. const LOBBY_ACCESS_DENIED_TEST_ID = 'lobby.joinRejectedMessage';
  7. const LOBBY_ENABLED_TEST_ID = 'lobby.notificationLobbyEnabled';
  8. const LOBBY_KNOCKING_PARTICIPANT_NOTIFICATION_XPATH
  9. = '//div[@data-testid="notify.participantWantsToJoin"]/div/div/span';
  10. const LOBBY_NOTIFICATIONS_TITLE_TEST_ID = 'lobby.notificationTitle';
  11. const LOBBY_PARTICIPANT_ACCESS_DENIED_TEST_ID = 'lobby.notificationLobbyAccessDenied';
  12. const LOBBY_PARTICIPANT_ACCESS_GRANTED_TEST_ID = 'lobby.notificationLobbyAccessGranted';
  13. const LOBBY_PARTICIPANT_ADMIT_TEST_ID = 'participantsPane.actions.admit';
  14. const LOBBY_PARTICIPANT_REJECT_TEST_ID = 'participantsPane.actions.reject';
  15. const RAISE_HAND_NOTIFICATION_ID = 'notify.raisedHand';
  16. const REENABLE_SELF_VIEW_NOTIFICATION_ID = 'notify.selfViewTitle';
  17. const REENABLE_SELF_VIEW_CLOSE_NOTIFICATION = 'notify.selfViewTitle-dismiss';
  18. /**
  19. * Gathers all notifications logic in the UI and obtaining those.
  20. */
  21. export default class Notifications extends BasePageObject {
  22. /**
  23. * Waits for the raised hand notification to be displayed.
  24. * The notification on moderators page when the participant tries to unmute.
  25. */
  26. async waitForRaisedHandNotification() {
  27. const displayNameEl
  28. = this.participant.driver.$(`div[data-testid="${RAISE_HAND_NOTIFICATION_ID}"]`);
  29. await displayNameEl.waitForExist({ timeout: 2000 });
  30. await displayNameEl.waitForDisplayed();
  31. }
  32. /**
  33. * The notification on participants page when the moderator asks to unmute.
  34. */
  35. async waitForAskToUnmuteNotification() {
  36. const displayNameEl
  37. = this.participant.driver.$(`div[data-testid="${ASK_TO_UNMUTE_NOTIFICATION_ID}"]`);
  38. await displayNameEl.waitForExist({ timeout: 2000 });
  39. await displayNameEl.waitForDisplayed();
  40. }
  41. /**
  42. * Dismisses any join notifications.
  43. */
  44. dismissAnyJoinNotification() {
  45. return Promise.allSettled(
  46. [ `${JOIN_ONE_TEST_ID}-dismiss`, `${JOIN_TWO_TEST_ID}-dismiss`, `${JOIN_MULTIPLE_TEST_ID}-dismiss` ]
  47. .map(id => this.participant.driver.$(`#${id}"]`).click()));
  48. }
  49. /**
  50. * Waits for the self view notification to be displayed.
  51. */
  52. async waitForReEnableSelfViewNotification() {
  53. const el
  54. = this.participant.driver.$(`div[data-testid="${REENABLE_SELF_VIEW_NOTIFICATION_ID}"]`);
  55. await el.waitForExist({ timeout: 2000 });
  56. await el.waitForDisplayed();
  57. }
  58. /**
  59. * Closes the self view notification.
  60. */
  61. closeReEnableSelfViewNotification() {
  62. return this.participant.driver.$(`div[data-testid="${REENABLE_SELF_VIEW_CLOSE_NOTIFICATION}"]`).click();
  63. }
  64. /**
  65. * The notification on participants page when Lobby is being enabled or disabled.
  66. */
  67. getLobbyEnabledText() {
  68. return this.getNotificationText(LOBBY_ENABLED_TEST_ID);
  69. }
  70. /**
  71. * Closes a specific lobby notification.
  72. * @param testId
  73. * @private
  74. */
  75. private async closeLobbyNotification(testId: string) {
  76. const notification = this.participant.driver.$(`[data-testid="${testId}"]`);
  77. await notification.waitForExist();
  78. await notification.waitForStable();
  79. const closeButton
  80. = this.participant.driver.$(`[data-testid="${LOBBY_NOTIFICATIONS_TITLE_TEST_ID}"]`)
  81. .$('#close-notification');
  82. await closeButton.moveTo();
  83. await closeButton.click();
  84. }
  85. /**
  86. * Closes the notification.
  87. */
  88. closeLobbyEnabled() {
  89. return this.closeLobbyNotification(LOBBY_ENABLED_TEST_ID);
  90. }
  91. /**
  92. * Returns the name of the knocking participant (the only one) that is displayed on the notification.
  93. */
  94. async getKnockingParticipantName() {
  95. const knockingParticipantNotification
  96. = this.participant.driver.$('//div[@data-testid="notify.participantWantsToJoin"]/div/div/span');
  97. await knockingParticipantNotification.waitForDisplayed({
  98. timeout: 3000,
  99. timeoutMsg: 'Knocking participant notification not displayed'
  100. });
  101. return await knockingParticipantNotification.getText();
  102. }
  103. /**
  104. * Admits the last knocking participant (it is the only one).
  105. */
  106. async allowLobbyParticipant() {
  107. const admitButton
  108. = this.participant.driver.$(`[data-testid="${LOBBY_PARTICIPANT_ADMIT_TEST_ID}"]`);
  109. await admitButton.waitForExist();
  110. await admitButton.waitForClickable();
  111. await admitButton.click();
  112. }
  113. /**
  114. * The notification that someone's access was approved.
  115. */
  116. getLobbyParticipantAccessGranted() {
  117. return this.getNotificationText(LOBBY_PARTICIPANT_ACCESS_GRANTED_TEST_ID);
  118. }
  119. /**
  120. * Closes the notification.
  121. */
  122. closeLobbyParticipantAccessGranted() {
  123. return this.closeLobbyNotification(LOBBY_PARTICIPANT_ACCESS_GRANTED_TEST_ID);
  124. }
  125. /**
  126. * Returns notification text if the notification is found in the next few seconds.
  127. * @return the notification text.
  128. */
  129. private async getNotificationText(testId: string) {
  130. const notificationElement = this.participant.driver.$(`[data-testid="${testId}"]`);
  131. await notificationElement.waitForExist();
  132. return await notificationElement.getText();
  133. }
  134. /**
  135. * Rejects the last knocking participant (it is the only one).
  136. */
  137. async rejectLobbyParticipant() {
  138. const admitButton
  139. = this.participant.driver.$(`[data-testid="${LOBBY_PARTICIPANT_REJECT_TEST_ID}"]`);
  140. await admitButton.waitForExist();
  141. await admitButton.waitForClickable();
  142. await admitButton.click();
  143. }
  144. /**
  145. * The notification test that someone's access was denied.
  146. */
  147. getLobbyParticipantAccessDenied() {
  148. return this.getNotificationText(LOBBY_PARTICIPANT_ACCESS_DENIED_TEST_ID);
  149. }
  150. /**
  151. * Closes the notification.
  152. */
  153. closeLobbyParticipantAccessDenied() {
  154. return this.closeLobbyNotification(LOBBY_PARTICIPANT_ACCESS_DENIED_TEST_ID);
  155. }
  156. /**
  157. * Waits for the notification for access denied for entering the lobby is shown.
  158. */
  159. async waitForLobbyAccessDeniedNotification() {
  160. const displayNameEl
  161. = this.participant.driver.$(`div[data-testid="${LOBBY_ACCESS_DENIED_TEST_ID}"]`);
  162. await displayNameEl.waitForExist({ timeout: 2000 });
  163. await displayNameEl.waitForDisplayed();
  164. }
  165. /**
  166. * Will wait 3 seconds for the knocking participants to disappear and return true or will return false.
  167. * @return <tt>true</tt> if the knocking participants list was not displayed.
  168. */
  169. waitForHideOfKnockingParticipants() {
  170. return this.participant.driver.$(LOBBY_KNOCKING_PARTICIPANT_NOTIFICATION_XPATH)
  171. .waitForDisplayed({
  172. timeout: 3000,
  173. reverse: true
  174. });
  175. }
  176. /**
  177. * Closes local notification, for the participant that was denied.
  178. */
  179. async closeLocalLobbyAccessDenied() {
  180. await this.participant.driver.$('[data-testid="lobby.joinRejectedMessage"').waitForExist();
  181. const dismissButton
  182. = this.participant.driver.$('[data-testid="lobby.joinRejectedTitle-dismiss"]');
  183. await dismissButton.moveTo();
  184. await dismissButton.click();
  185. }
  186. }