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

package.cypress-utils.utils.common.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
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
import { environment } from "../constants";
var getCountFromText = function getCountFromText(countText) {
  return Number(countText.text().trim().split(" ")[0]);
};
var env = {
  isDevelopment: Cypress.env("configFile") === environment.development,
  isReview: Cypress.env("configFile") === environment.review,
  isStaging: Cypress.env("configFile") === environment.staging,
  isProduction: Cypress.env("configFile") === environment.production
};
env.isNightlyRun = env.isProduction || env.isStaging;
env.tld = env.isProduction ? "com" : "net";
var isStagingEnv = Cypress.env("configFile") === environment.staging;
var dataCy = function dataCy(value) {
  var suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  return "[data-cy='".concat(value, "']").concat(suffix);
};
var dataTestId = function dataTestId(value) {
  var suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  return "[data-testid='".concat(value, "']").concat(suffix);
};
var setListCount = function setListCount(countSelector, alias) {
  return cy.get(countSelector).then(function (countText) {
    cy.wrap(getCountFromText(countText)).as(alias);
  });
};
var verifyListCount = function verifyListCount(countSelector, count) {
  return cy.get(countSelector).then(function (countText) {
    cy.wrap(getCountFromText(countText)).should("eq", count);
  });
};
var getUrl = function getUrl(path) {
  return "/api/v1/".concat(path);
};
var getTestTitle = function getTestTitle() {
  var ctx = Cypress.mocha.getRunner().suite.ctx;
  return ctx.currentTest.parent.title;
};
var joinHyphenCase = function joinHyphenCase() {
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
    args[_key] = arguments[_key];
  }
  return args.join(" ").replace(/\s+/g, "-").toLowerCase();
};
var hyphenize = function hyphenize(input) {
  var fallbackString = "";
  if (typeof input === "number") return String(input);
  if (input && typeof input === "string" && input.replace) {
    return input.replace(/[\s_]/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/-+/g, "-").toLowerCase();
  }
  return fallbackString;
};
var initializeCredentials = function initializeCredentials(stagingData) {
  cy.task("getGlobalState").then(function (state) {
    var newState = _objectSpread(_objectSpread({}, state), {}, {
      businessName: state.businessName || stagingData.businessName,
      currentUserName: state.currentUserName || stagingData.currentUserName,
      email: state.email || stagingData.email,
      firstName: state.firstName || stagingData.firstName,
      lastName: state.lastName || stagingData.lastName,
      subdomainName: state.subdomainName || stagingData.subdomainName,
      skipSetup: state.skipSetup
    });
    if (isStagingEnv) {
      var baseUrl = "https://".concat(newState.subdomainName, ".").concat(stagingData.domain);
      Cypress.config("baseUrl", baseUrl);
    }
    cy.task("bulkUpdateGlobalState", newState);
  });
};
export { env, isStagingEnv, dataCy, dataTestId, setListCount, verifyListCount, getUrl, getTestTitle, joinHyphenCase, hyphenize, initializeCredentials };
//# sourceMappingURL=common.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy