Home Manual Reference Source

src/controllers/web/availability.controller.js

import * as WebPageObjects from "../../page_objects/web/webPageObjects.js";
import BaseController from "./base.controller.js";

/**
 * @class AvailabilityController
 * @extends BaseController
 */
class AvailabilityController extends BaseController {
  /**
   * Adds the browser to the controller from the Base Controller constructor.
   * This then gets pushed into the various page objects
   * and is ultimately used there to make calls to the actual browser.
   * @param {args} args Args from client
   */
  constructor(args) {
    super(args);
    this.headerPanel = new WebPageObjects.HeaderPanel(args);
  }

  /** Changes account status to 'Available' for calls/chats */
  async changeStatusAvailable() {
    await this.headerPanel.availabilityDropdown().click();
    await this.headerPanel.availableOption().click();
  }

  /** Changes account status to 'Do Not Disturb' for calls/chats */
  async changeStatusDND() {
    await this.headerPanel.availabilityDropdown().click();
    await this.headerPanel.dndOption().click();
  }

  /** Gets the availability status of the user
   * @return {String} String containing status(AVAILABLE/DO_NOT_DISTURB)*/
  async getStatus() {
    const statusElement = await this.headerPanel.clientStatus();
    const statusClass = await statusElement.getAttribute("class");
    const status = await statusClass[2].match(
      /components-Header-AvailabilityDropdown__(.+)--/
    );
    return status[1];
  }
}

export default AvailabilityController;