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(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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