Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

SettingsDialog.ts 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import BaseDialog from './BaseDialog';
  2. const EMAIL_FIELD = '#setEmail';
  3. const FOLLOW_ME_CHECKBOX = '//input[@name="follow-me"]';
  4. const HIDE_SELF_VIEW_CHECKBOX = '//input[@name="hide-self-view"]';
  5. const SETTINGS_DIALOG_CONTENT = '.settings-pane';
  6. const START_AUDIO_MUTED_CHECKBOX = '//input[@name="start-audio-muted"]';
  7. const START_VIDEO_MUTED_CHECKBOX = '//input[@name="start-video-muted"]';
  8. const X_PATH_MODERATOR_TAB = '//div[contains(@class, "settings-dialog")]//*[text()="Moderator"]';
  9. const X_PATH_MORE_TAB = '//div[contains(@class, "settings-dialog")]//*[text()="General"]';
  10. const X_PATH_PROFILE_TAB = '//div[contains(@class, "settings-dialog")]//*[text()="Profile"]';
  11. /**
  12. * The settings dialog.
  13. */
  14. export default class SettingsDialog extends BaseDialog {
  15. /**
  16. * Waits for the settings dialog to be visible.
  17. */
  18. waitForDisplay() {
  19. return this.participant.driver.$(SETTINGS_DIALOG_CONTENT).waitForDisplayed();
  20. }
  21. /**
  22. * Displays a specific tab in the settings dialog.
  23. * @param xpath
  24. * @private
  25. */
  26. private async openTab(xpath: string) {
  27. const elem = this.participant.driver.$(xpath);
  28. await elem.waitForClickable();
  29. await elem.click();
  30. }
  31. /**
  32. * Selects the Profile tab to be displayed.
  33. */
  34. openProfileTab() {
  35. return this.openTab(X_PATH_PROFILE_TAB);
  36. }
  37. /**
  38. * Selects the More tab to be displayed.
  39. */
  40. openMoreTab() {
  41. return this.openTab(X_PATH_MORE_TAB);
  42. }
  43. /**
  44. * Selects the moderator tab to be displayed.
  45. */
  46. openModeratorTab() {
  47. return this.openTab(X_PATH_MODERATOR_TAB);
  48. }
  49. /**
  50. * Enters the passed in email into the email field.
  51. * @param email
  52. */
  53. async setEmail(email: string) {
  54. await this.openProfileTab();
  55. await this.participant.driver.$(EMAIL_FIELD).setValue(email);
  56. }
  57. /**
  58. * Returns the participant's email displayed in the settings dialog.
  59. */
  60. async getEmail() {
  61. await this.openProfileTab();
  62. return await this.participant.driver.$(EMAIL_FIELD).getValue();
  63. }
  64. /**
  65. * Clicks the OK button on the settings dialog to close the dialog and save any changes made.
  66. */
  67. submit() {
  68. return this.clickOkButton();
  69. }
  70. /**
  71. * Sets the start audio muted feature to enabled/disabled.
  72. * @param {boolean} enable - true for enabled and false for disabled.
  73. * @returns {Promise<void>}
  74. */
  75. async setStartAudioMuted(enable: boolean) {
  76. await this.openModeratorTab();
  77. await this.setCheckbox(START_AUDIO_MUTED_CHECKBOX, enable);
  78. }
  79. /**
  80. * Sets the start video muted feature to enabled/disabled.
  81. * @param {boolean} enable - true for enabled and false for disabled.
  82. * @returns {Promise<void>}
  83. */
  84. async setStartVideoMuted(enable: boolean) {
  85. await this.openModeratorTab();
  86. await this.setCheckbox(START_VIDEO_MUTED_CHECKBOX, enable);
  87. }
  88. /**
  89. * Sets the state checked/selected of a checkbox in the settings dialog.
  90. */
  91. async setHideSelfView(hideSelfView: boolean) {
  92. await this.openMoreTab();
  93. await this.setCheckbox(HIDE_SELF_VIEW_CHECKBOX, hideSelfView);
  94. }
  95. /**
  96. * Sets the follow me feature to enabled/disabled.
  97. * @param enable
  98. */
  99. async setFollowMe(enable: boolean) {
  100. await this.openModeratorTab();
  101. await this.setCheckbox(FOLLOW_ME_CHECKBOX, enable);
  102. }
  103. /**
  104. * Returns true if the follow me checkbox is displayed in the settings dialog.
  105. */
  106. async isFollowMeDisplayed() {
  107. const elem = this.participant.driver.$(X_PATH_MODERATOR_TAB);
  108. if (!await elem.isExisting()) {
  109. return false;
  110. }
  111. await this.openModeratorTab();
  112. return await this.participant.driver.$$(FOLLOW_ME_CHECKBOX).length > 0;
  113. }
  114. /**
  115. * Sets the state of a checkbox.
  116. * @param selector
  117. * @param enable
  118. * @private
  119. */
  120. private async setCheckbox(selector: string, enable: boolean) {
  121. const checkbox = this.participant.driver.$(selector);
  122. await checkbox.waitForExist();
  123. if (enable !== await checkbox.isSelected()) {
  124. // we show a div with svg and text after the input and those elements grab the click
  125. // so we need to click on the parent element
  126. await this.participant.driver.$(`${selector}//ancestor::div[1]`).click();
  127. }
  128. }
  129. }