All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.cjs.cypress-utils.utils.navigation.js Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.navigationUtils = void 0;
var _routes = require("../constants/routes");
var _common = require("../constants/selectors/common");
var _navigation = require("../constants/selectors/navigation");
var _common2 = require("../constants/texts/common");
var _navigation2 = require("../constants/texts/navigation");
/* eslint-disable xss/no-location-href-assign */

var verifyTabMenu = function verifyTabMenu(_ref) {
  var tabSelector = _ref.tabSelector,
    _ref$alias = _ref.alias,
    alias = _ref$alias === void 0 ? "fetchData" : _ref$alias,
    _ref$requestCount = _ref.requestCount,
    requestCount = _ref$requestCount === void 0 ? 1 : _ref$requestCount;
  requestCount && cy.interceptApi(alias, requestCount);
  cy.get(tabSelector).click();
  requestCount && cy.waitForMultipleRequest("@".concat(alias), requestCount);
  cy.verifyAttribute({
    selector: tabSelector,
    attr: "class",
    value: "active"
  });
};
var clickOnHelpSubTab = function clickOnHelpSubTab(tabSelector, tabText) {
  _openProfileOrHelpCenter({
    tabSelector: _navigation.helpIconSelectors.helpButton,
    subTabLink: _navigation.helpIconSelectors.whatsNewButton,
    count: 5
  });
  cy.get(tabSelector).should("have.text", tabText).invoke("click");
};
var verifyHelpDocumentationLink = function verifyHelpDocumentationLink(_ref2) {
  var articleTitle = _ref2.articleTitle,
    alias = _ref2.alias,
    _ref2$requestCount = _ref2.requestCount,
    requestCount = _ref2$requestCount === void 0 ? 3 : _ref2$requestCount;
  _openProfileOrHelpCenter({
    tabSelector: _navigation.helpIconSelectors.helpButton,
    subTabLink: _navigation.helpIconSelectors.whatsNewButton,
    count: 5
  });
  cy.clickByRemoveTargetAttr(_navigation.helpIconSelectors.documentationButton);
  cy.get(_common.commonSelectors.articlePageTitle, {
    timeout: 10000
  }).should("have.text", articleTitle);
  cy.interceptApi(alias, requestCount);
  cy.go("back");
  cy.waitForMultipleRequest("@".concat(alias), requestCount);
};
var verifyKeyboardShortcutsPane = function verifyKeyboardShortcutsPane() {
  clickOnHelpSubTab(_navigation.helpIconSelectors.keyboardShortcutButton, _navigation2.helpIconTexts.keyboardShortcuts);
  cy.get(_navigation.helpIconSelectors.keyboardShortcutPaneHeading).should("have.text", _navigation2.helpIconTexts.keyboardShortcuts);
  cy.get(_navigation.helpIconSelectors.keyboardShortcutPaneCrossIcon).click();
};
var verifyWhatsNewTab = function verifyWhatsNewTab(whatsNewHeading) {
  _openProfileOrHelpCenter({
    tabSelector: _navigation.helpIconSelectors.helpButton,
    subTabLink: _navigation.helpIconSelectors.whatsNewButton,
    count: 5
  });
  cy.get(_navigation.helpIconSelectors.whatsNewButton).should("contain.text", _navigation2.helpIconTexts.whatsNew);
  _openWhatsNewPane();
  cy.get(_navigation.helpIconSelectors.whatsNewWidgetInfo).should("have.text", whatsNewHeading);
  cy.get(_navigation.helpIconSelectors.whatsNewWidgetCloseButton).last().click();
  cy.get(_navigation.helpIconSelectors.whatsNewWidgetInfo).should("not.exist");
};
var _waitForChatWidget = function waitForChatWidget() {
  var timeOut = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
  var defaultWait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
  if (timeOut === 0) return;
  cy.ifNotExist(_navigation.chatWidgetSelectors.widgetIframe, function () {
    // eslint-disable-next-line cypress/no-unnecessary-waiting
    cy.wait(defaultWait);
    navigationUtils.clickOnHelpSubTab(_navigation.helpIconSelectors.chatButton, _navigation2.helpIconTexts.liveChat);
    cy.ifNotExist(_navigation.chatWidgetSelectors.widgetIframe, function () {
      _waitForChatWidget(timeOut - 1);
    });
  });
};
var verifyChatWithUsTab = function verifyChatWithUsTab(_ref3) {
  var alias = _ref3.alias,
    _ref3$requestCount = _ref3.requestCount,
    requestCount = _ref3$requestCount === void 0 ? 3 : _ref3$requestCount;
  requestCount && cy.interceptNonVersionedApi({
    url: _routes.requestApis.allChatPath,
    alias: alias,
    times: requestCount
  });
  clickOnHelpSubTab(_navigation.helpIconSelectors.chatButton, _navigation2.helpIconTexts.liveChat);
  requestCount && cy.waitForMultipleRequest("@".concat(alias), requestCount);
  _waitForChatWidget();
  cy.withinIframe(_navigation.chatWidgetSelectors.widgetIframe, function () {
    requestCount && cy.interceptNonVersionedApi({
      url: _routes.requestApis.allChatPath,
      alias: alias,
      times: requestCount
    });
    cy.get(_navigation.chatWidgetSelectors.chatWidgetHomeCard, {
      timeout: 10000
    }).click({
      force: true
    });
    requestCount && cy.wait("@".concat(alias), requestCount);
    requestCount && cy.interceptNonVersionedApi({
      url: _routes.requestApis.allChatPath,
      alias: alias,
      times: requestCount
    });
    cy.get(_navigation.chatWidgetSelectors.widgetSubmitButton).click();
    requestCount && cy.waitForMultipleRequest("@".concat(alias), requestCount);
    cy.get(_navigation.chatWidgetSelectors.chatBubbleMessage).should("be.visible");
  });
  cy.get(_navigation.chatWidgetSelectors.chatCloseButton).click();
  cy.get(_navigation.chatWidgetSelectors.widgetIframe).should("not.exist");
};
var verifyMyProfileTab = function verifyMyProfileTab(_ref4) {
  var alias = _ref4.alias,
    _ref4$requestCount = _ref4.requestCount,
    requestCount = _ref4$requestCount === void 0 ? 2 : _ref4$requestCount;
  _openProfileOrHelpCenter({
    tabSelector: _common.profileSelectors.tab,
    subTabLink: _common.profileSelectors.logoutLink,
    count: 5
  });
  cy.get(_common.profileSelectors.myProfileButton).should("have.text", _navigation2.profileTexts.myProfile);
  cy.globalState("subdomainName").then(function (subdomainName) {
    cy.window().then(function (win) {
      cy.stub(win, "open").as(alias).callsFake(function (newUrl) {
        return win.location.href = newUrl;
      });
    });
    cy.get(_common.profileSelectors.myProfileButton).invoke("click");
    cy.get("@".concat(alias)).should("be.called");
    cy.url().should("include", _routes.requestApis.myProfilePath(subdomainName));
  });
  cy.get(_common.commonSelectors.heading).should("have.text", _navigation2.profileTexts.profileSettings);
  cy.globalState("subdomainName").then(function (subdomainName) {
    return cy.url().should("include", _routes.requestApis.myProfilePath(subdomainName));
  });
  cy.interceptApi(alias, requestCount);
  cy.go("back");
  cy.waitForMultipleRequest("@".concat(alias), requestCount);
};
var verifyOrganizationTab = function verifyOrganizationTab() {
  _openProfileOrHelpCenter({
    tabSelector: _common.profileSelectors.tab,
    subTabLink: _common.profileSelectors.logoutLink,
    count: 5
  });
  cy.get(_common.profileSelectors.organizationSettingsButton).should("have.text", _navigation2.profileTexts.myOrganization);
  cy.globalState("subdomainName").then(function (subdomainName) {
    cy.window().then(function (win) {
      cy.stub(win, "open").as("navigateToSettings").callsFake(function (newUrl) {
        return win.location.href = newUrl;
      });
    });
    cy.get(_common.profileSelectors.organizationSettingsButton).invoke("click");
    cy.get("@navigateToSettings").should("be.called");
    cy.url().should("include", _routes.requestApis.settingsPath(subdomainName));
  });
  cy.get(_common.commonSelectors.heading).should("have.text", _common2.commonTexts.settings);
  cy.globalState("subdomainName").then(function (subdomainName) {
    return cy.url().should("include", _routes.requestApis.settingsPath(subdomainName));
  });
};
var _openProfileOrHelpCenter = function openProfileOrHelpCenter(_ref5) {
  var tabSelector = _ref5.tabSelector,
    subTabLink = _ref5.subTabLink,
    _ref5$count = _ref5.count,
    count = _ref5$count === void 0 ? 1 : _ref5$count,
    _ref5$timeout = _ref5.timeout,
    timeout = _ref5$timeout === void 0 ? 2000 : _ref5$timeout;
  if (count === 0) return;
  cy.get(tabSelector).click();
  cy.ifNotExist(subTabLink, function () {
    cy.wait(timeout); // eslint-disable-line cypress/no-unnecessary-waiting
    _openProfileOrHelpCenter({
      tabSelector: tabSelector,
      subTabLink: subTabLink,
      count: count - 1,
      timeout: timeout
    });
  });
};
var _openWhatsNewPane = function openWhatsNewPane() {
  var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 7;
  var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
  if (count === 0) return;
  cy.get(_navigation.helpIconSelectors.whatsNewButton).invoke("click");
  cy.ifNotExist(_navigation.helpIconSelectors.whatsNewWidgetInfo, function () {
    cy.wait(timeout); // eslint-disable-line cypress/no-unnecessary-waiting
    _openWhatsNewPane(count - 1);
  });
};
var navigationUtils = exports.navigationUtils = {
  verifyTabMenu: verifyTabMenu,
  clickOnHelpSubTab: clickOnHelpSubTab,
  verifyHelpDocumentationLink: verifyHelpDocumentationLink,
  verifyKeyboardShortcutsPane: verifyKeyboardShortcutsPane,
  verifyWhatsNewTab: verifyWhatsNewTab,
  verifyChatWithUsTab: verifyChatWithUsTab,
  verifyMyProfileTab: verifyMyProfileTab,
  verifyOrganizationTab: verifyOrganizationTab,
  openProfileOrHelpCenter: _openProfileOrHelpCenter,
  openWhatsNewPane: _openWhatsNewPane
};
//# sourceMappingURL=navigation.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy