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.

SecurityDialog.ts 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import { Key } from 'webdriverio';
  2. import BaseDialog from './BaseDialog';
  3. const ADD_PASSWORD_LINK = 'add-password';
  4. const ADD_PASSWORD_FIELD = 'info-password-input';
  5. const DIALOG_CONTAINER = 'security-dialog';
  6. const LOCAL_LOCK = 'info-password-local';
  7. const REMOTE_LOCK = 'info-password-remote';
  8. /**
  9. * Page object for the security dialog.
  10. */
  11. export default class SecurityDialog extends BaseDialog {
  12. /**
  13. * Waits for the settings dialog to be visible.
  14. */
  15. waitForDisplay() {
  16. return this.participant.driver.$(`.${DIALOG_CONTAINER}`).waitForDisplayed();
  17. }
  18. /**
  19. * Returns the switch that can be used to detect lobby state or change lobby state.
  20. * @private
  21. */
  22. private getLobbySwitch() {
  23. return this.participant.driver.$('#lobby-section-switch');
  24. }
  25. /**
  26. * Returns is the lobby enabled.
  27. */
  28. isLobbyEnabled() {
  29. return this.getLobbySwitch().isSelected();
  30. }
  31. /**
  32. * Toggles the lobby option from the security dialog.
  33. */
  34. async toggleLobby() {
  35. const lobbySwitch = this.getLobbySwitch();
  36. await lobbySwitch.moveTo();
  37. await lobbySwitch.click();
  38. }
  39. /**
  40. * Checks whether lobby section is present in the UI.
  41. */
  42. isLobbySectionPresent() {
  43. return this.getLobbySwitch().isExisting();
  44. }
  45. /**
  46. * Waits for the lobby to be enabled or disabled.
  47. * @param reverse
  48. */
  49. waitForLobbyEnabled(reverse = false) {
  50. const lobbySwitch = this.getLobbySwitch();
  51. return this.participant.driver.waitUntil(
  52. async () => await lobbySwitch.isSelected() !== reverse,
  53. {
  54. timeout: 5_000, // 30 seconds
  55. timeoutMsg: `Timeout waiting for lobby being ${reverse ? 'disabled' : 'enabled'} for ${
  56. this.participant.name}.`
  57. }
  58. );
  59. }
  60. /**
  61. * Checks if the current conference is locked with a locally set password.
  62. *
  63. * @return {@code true} if the conference is displayed as locked locally in
  64. * the security dialog, {@code false} otherwise.
  65. */
  66. private isLockedLocally() {
  67. return this.participant.driver.$(`.${LOCAL_LOCK}`).isExisting();
  68. }
  69. /**
  70. * Checks if the current conference is locked with a locally set password.
  71. *
  72. * @return {@code true} if the conference is displayed as locked remotely
  73. * in the security dialog, {@code false} otherwise.
  74. */
  75. private isLockedRemotely() {
  76. return this.participant.driver.$(`.${REMOTE_LOCK}`).isExisting();
  77. }
  78. /**
  79. * Checks if the current conference is locked based on the security dialog's
  80. * display state.
  81. *
  82. * @return {@code true} if the conference is displayed as locked in the
  83. * security dialog, {@code false} otherwise.
  84. */
  85. async isLocked() {
  86. return await this.isLockedLocally() || await this.isLockedRemotely();
  87. }
  88. /**
  89. * Sets a password on the current conference to lock it.
  90. *
  91. * @param password - The password to use to lock the conference.
  92. */
  93. async addPassword(password: string) {
  94. const addPasswordLink = this.participant.driver.$(`.${ADD_PASSWORD_LINK}`);
  95. await addPasswordLink.waitForClickable();
  96. await addPasswordLink.click();
  97. const passwordEntry = this.participant.driver.$(`#${ADD_PASSWORD_FIELD}`);
  98. await passwordEntry.waitForDisplayed();
  99. await passwordEntry.click();
  100. await this.participant.driver.keys(password);
  101. await this.participant.driver.$('button=Add').click();
  102. let validationMessage;
  103. // There are two cases here, validation is enabled and the field passwordEntry maybe there
  104. // with validation failed, or maybe successfully hidden after setting the password
  105. // So let's give it some time to act on any of the above
  106. if (!await passwordEntry.isExisting()) {
  107. // validation had failed on password field as it is still on the page
  108. validationMessage = passwordEntry.getAttribute('validationMessage');
  109. }
  110. if (validationMessage) {
  111. await this.participant.driver.keys([ Key.Escape ]);
  112. expect(validationMessage).toBe('');
  113. }
  114. }
  115. }