Home Manual Reference Source

src/page_objects/web/call/inCall.modal.js

import BasePage from "../../base.page.js";

/**
 * InCallModal
 * @extends BasePage
 */
class InCallModal extends BasePage {
  /**
   * @param {args} args Args from controller
   */
  constructor(args) {
    super(args);
  }

  // PAGE ELEMENTS
  /* eslint-disable require-jsdoc, max-len */
  primaryVideo() {
    return this.element("video#videoPrimary");
  }

  secondaryVideo() {
    return this.element("video#videoSecondary");
  }

  turtleArrow() {
    return this.element("span#icon-turtle-arrow");
  }

  videoFooterPip() {
    return this.element("video#videoFooterPip");
  }

  muteMicButton() {
    return this.element("button[data-lsqa=mute-audio]");
  }

  muteVideoButton() {
    return this.element("button[data-lsqa=mute-video]");
  }

  startRecordingButton() {
    return this.element("button[data-lsqa=start-recording]");
  }

  stopRecordingButton() {
    return this.element("button[data-lsqa=stop-recording]");
  }

  startPresentationButton() {
    return this.element("button[data-lsqa=start-presentation]");
  }

  stopPresentationButton() {
    return this.element("button[data-lsqa=stop-presentation]");
  }

  presentationPip() {
    return this.element("video#videoPresentationPip");
  }

  endCallButton() {
    return this.element("button[data-lsqa=end-call]");
  }

  callDetailsContanier() {
    return this.element("[class^='components-InCall-CallDetails__container']");
  }

  viewCallDetailsPanelButton() {
    return this.element("button.icon-info");
  }

  participantsListContainer() {
    return this.element(
      "[class^='components-InCall-InCallParticipantList-InCallParticipantList__participantListContainer']"
    );
  }

  viewParticipantsListPanelButton() {
    return this.element(
      "[class*='InCallDrawerHolder__openButton'].icon-meeting"
    );
  }

  addParticipantPanelContainer() {
    return this.element(
      "[class^='components-AddParticipantDrawer-AddParticipantDrawer__container']"
    );
  }

  viewAddParticipantPanelButton() {
    return this.element("button.icon-incall-add");
  }

  closeRightHandPanelButton() {
    return this.element("button#closeDrawerButton");
  }

  loadingHeader() {
    return this.element(
      "header[class^='components-InCall-InCallParticipantList-InCallParticipantList__loadingHeader']"
    );
  }

  // PAGE FUNCTIONS
  /* eslint-enable require-jsdoc */
  /**
   * End the current call
   */
  async endCall() {
    await this.endCallButton().click();
  }

  /**
   * Get the tooltip text by hovering over the presentation button.
   * Checks to see if you are presenting
   * or not to determine the correct selector
   * @returns {String} Text of tooltip
   */
  async getPresentationTooltipText() {
    let tooltip;

    if (await this.startPresentationButton().isVisible()) {
      tooltip = await this.startPresentationButton().element(
        "div[class^=components-Tooltip-Tooltip__tool-tip]"
      );
      await this.startPresentationButton().hover();
    } else {
      tooltip = await this.stopPresentationButton().element(
        "div[class^=components-Tooltip-Tooltip__tool-tip]"
      );
      await this.stopPresentationButton().hover();
    }

    await this.browser.pause(1000);
    await tooltip.waitForVisible();
    return await tooltip.getText();
  }

  /**
   * Checks if receiving presentation
   * @return {Boolean} true if receiving, false if not
   */
  async isReceivingPresentation() {
    const primaryVideoVisible = await this.primaryVideo().isVisible();
    const secondaryVideoVisible = await this.secondaryVideo().isVisible();
    const presentationButtonEnabled = await this.startPresentationButton().isEnabled(); // eslint-disable-line max-len
    const presentationPipVisible = await this.presentationPip().isVisible();

    return (
      primaryVideoVisible &&
      secondaryVideoVisible &&
      !presentationButtonEnabled &&
      !presentationPipVisible
    );
  }

  /**
   * Checks if sending presentation
   * @return {Boolean} true if sending, false if not
   */
  async isSendingPresentation() {
    const primaryVideoVisible = await this.primaryVideo().isVisible();
    const presentationPipVisible = await this.presentationPip().isVisible();
    const presentationIconActive = await this._isPresentationIconActive();
    return (
      primaryVideoVisible && presentationPipVisible && presentationIconActive
    );
  }

  /**
   * Checks if presentation icon is active (green colored)
   * @return {Boolean} true if active, false if not
   */
  async _isPresentationIconActive() {
    await this.stopPresentationButton().waitForVisible(15000);
    const className = await this.stopPresentationButton().getAttribute("class");
    return className.includes("inCallButtonPresentationActive");
  }

  /**
 * Clicks on in call call info button if the panel is not opened
 */
  async viewCallDetails() {
    const containerClass = await this.callDetailsContanier().getAttribute(
      "class"
    );
    if (containerClass.includes("hiddenDrawer")) {
      await this.viewCallDetailsPanelButton().click();
    }
    await this.callDetailsContanier().waitForVisible(5000);
  }

  /**
   * Clicks on incall participants list button if the view is not open
   */
  async viewParticipantsList() {
    const containerClass = await this.participantsListContainer().getAttribute(
      "class"
    );
    if (containerClass.includes("hiddenDrawer")) {
      await this.viewParticipantsListPanelButton().click();
    }
    await this.participantsListContainer().waitForVisible(5000);
  }

  /**
   * Clicks on incall add participant panel if the view is not open
   */
  async viewAddParticipantPanel() {
    const containerClass = await this.addParticipantPanelContainer().getAttribute(
      "class"
    );
    if (containerClass.includes("hiddenDrawer")) {
      await this.viewAddParticipantPanelButton().click();
    }
    await this.addParticipantPanelContainer().waitForVisible(5000);
  }

  /**
   * Clicks on right hand panel X button
   */
  async closeRightHandPanel() {
    await this.closeRightHandPanelButton().click();
    await this.browser.pause(2000);
  }

  /**
   * Returns whether the call is recorded or not
   * @return {Boolean} all recording state
   */
  async isCallRecorded() {
    return await this.stopRecordingButton().isVisible();
  }

  /**
   * Gets recording button tool tip text by hovering on the button
   * @return {String} recording button tool tip text
   */
  async getRecordingTooltipText() {
    let tooltip;

    if (await this.startRecordingButton().isVisible()) {
      tooltip = await this.startRecordingButton().element(
        "div[class^=components-Tooltip-Tooltip__tool-tip]"
      );
      await this.startRecordingButton().hover();
    } else {
      tooltip = await this.stopRecordingButton().element(
        "div[class^=components-Tooltip-Tooltip__tool-tip]"
      );
      await this.stopRecordingButton().hover();
    }
    await this.browser.pause(1000);
    await tooltip.waitForVisible();
    return await tooltip.getText();
  }
}

export default InCallModal;