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.

SettingsDialog.ts 3.6KB

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