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.

InviteDialog.ts 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import BaseDialog from './BaseDialog';
  2. const CONFERENCE_ID = 'conference-id';
  3. const CONFERENCE_URL = 'invite-more-dialog-conference-url';
  4. const DIALOG_CONTAINER = 'invite-more-dialog';
  5. const MORE_NUMBERS = 'more-numbers';
  6. const PHONE_NUMBER = 'phone-number';
  7. /**
  8. * Represents the invite dialog in a particular participant.
  9. */
  10. export default class InviteDialog extends BaseDialog {
  11. /**
  12. * Checks if the dialog is open.
  13. */
  14. isOpen() {
  15. return this.participant.driver.$(`.${DIALOG_CONTAINER}`).isExisting();
  16. }
  17. /**
  18. * Open the invite dialog, if the info dialog is closed.
  19. */
  20. async open() {
  21. if (await this.isOpen()) {
  22. return;
  23. }
  24. await this.participant.getParticipantsPane().clickInvite();
  25. }
  26. /**
  27. * Returns the PIN for the conference.
  28. */
  29. async getPinNumber() {
  30. await this.open();
  31. return (await this.getValueAfterColon(CONFERENCE_ID)).replace(/[# ]/g, '');
  32. }
  33. /**
  34. * Private helper to get values after colons. The invite dialog lists conference specific information
  35. * after a label, followed by a colon.
  36. *
  37. * @param className
  38. * @private
  39. */
  40. private async getValueAfterColon(className: string) {
  41. const elem = this.participant.driver.$(`.${className}`);
  42. await elem.waitForExist({ timeout: 5000 });
  43. const fullText = await elem.getText();
  44. this.participant.log(`Extracted text in invite dialog: ${fullText}`);
  45. return fullText.split(':')[1].trim();
  46. }
  47. /**
  48. * Returns the meeting url displayed in the dialog.
  49. */
  50. async getMeetingURL() {
  51. const elem = this.participant.driver.$(`.${CONFERENCE_URL}`);
  52. await elem.waitForExist();
  53. return (await elem.getText())?.trim();
  54. }
  55. /**
  56. * Waits for the dialog to be open or closed.
  57. * @param reverse
  58. */
  59. async waitTillOpen(reverse = false) {
  60. await this.participant.driver.waitUntil(
  61. /* eslint-disable no-extra-parens */
  62. async () => (reverse ? !await this.isOpen() : await this.isOpen()),
  63. {
  64. timeout: 2_000,
  65. timeoutMsg: `invite dialog did not ${reverse ? 'close' : 'open'}`
  66. }
  67. );
  68. }
  69. /**
  70. * Gets the string that contains the dial in number for the current conference.
  71. */
  72. getDialInNumber() {
  73. return this.getValueAfterColon(PHONE_NUMBER);
  74. }
  75. /**
  76. * Clicks the link to open a page to show all available dial in numbers.
  77. */
  78. async openDialInNumbersPage() {
  79. const moreNumbers = this.participant.driver.$(`.${MORE_NUMBERS}`);
  80. await moreNumbers.waitForExist();
  81. await moreNumbers.waitForClickable();
  82. await moreNumbers.click();
  83. }
  84. }