package.cypress-utils.utils.common.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
{"version":3,"file":"common.js","names":["environment","getCountFromText","countText","Number","text","trim","split","env","isDevelopment","Cypress","development","isReview","review","isStaging","staging","isProduction","production","isNightlyRun","tld","isStagingEnv","dataCy","value","suffix","arguments","length","undefined","concat","dataTestId","setListCount","countSelector","alias","cy","get","then","wrap","as","verifyListCount","count","should","getUrl","path","getTestTitle","ctx","mocha","getRunner","suite","currentTest","parent","title","joinHyphenCase","_len","args","Array","_key","join","replace","toLowerCase","hyphenize","input","fallbackString","String","initializeCredentials","stagingData","task","state","newState","_objectSpread","businessName","currentUserName","email","firstName","lastName","subdomainName","skipSetup","baseUrl","domain","config"],"sources":["../../../src/cypress-utils/utils/common.js"],"sourcesContent":["import { environment } from \"../constants\";\n\nconst getCountFromText = countText =>\n Number(countText.text().trim().split(\" \")[0]);\n\nconst env = {\n isDevelopment: Cypress.env(\"configFile\") === environment.development,\n isReview: Cypress.env(\"configFile\") === environment.review,\n isStaging: Cypress.env(\"configFile\") === environment.staging,\n isProduction: Cypress.env(\"configFile\") === environment.production,\n};\nenv.isNightlyRun = env.isProduction || env.isStaging;\nenv.tld = env.isProduction ? \"com\" : \"net\";\n\nconst isStagingEnv = Cypress.env(\"configFile\") === environment.staging;\n\nconst dataCy = (value, suffix = \"\") => `[data-cy='${value}']${suffix}`;\n\nconst dataTestId = (value, suffix = \"\") => `[data-testid='${value}']${suffix}`;\n\nconst setListCount = (countSelector, alias) =>\n cy.get(countSelector).then(countText => {\n cy.wrap(getCountFromText(countText)).as(alias);\n });\n\nconst verifyListCount = (countSelector, count) =>\n cy.get(countSelector).then(countText => {\n cy.wrap(getCountFromText(countText)).should(\"eq\", count);\n });\n\nconst getUrl = path => `/api/v1/${path}`;\n\nconst getTestTitle = () => {\n const { ctx } = Cypress.mocha.getRunner().suite;\n\n return ctx.currentTest.parent.title;\n};\n\nconst joinHyphenCase = (...args) =>\n args.join(\" \").replace(/\\s+/g, \"-\").toLowerCase();\n\nconst hyphenize = input => {\n const fallbackString = \"\";\n if (typeof input === \"number\") return String(input);\n\n if (input && typeof input === \"string\" && input.replace) {\n return input\n .replace(/[\\s_]/g, \"-\")\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/-+/g, \"-\")\n .toLowerCase();\n }\n\n return fallbackString;\n};\n\nconst initializeCredentials = stagingData => {\n cy.task(\"getGlobalState\").then(state => {\n const newState = {\n ...state,\n businessName: state.businessName || stagingData.businessName,\n currentUserName: state.currentUserName || stagingData.currentUserName,\n email: state.email || stagingData.email,\n firstName: state.firstName || stagingData.firstName,\n lastName: state.lastName || stagingData.lastName,\n subdomainName: state.subdomainName || stagingData.subdomainName,\n skipSetup: state.skipSetup,\n };\n if (isStagingEnv) {\n const baseUrl = `https://${newState.subdomainName}.${stagingData.domain}`;\n Cypress.config(\"baseUrl\", baseUrl);\n }\n cy.task(\"bulkUpdateGlobalState\", newState);\n });\n};\n\nexport {\n env,\n isStagingEnv,\n dataCy,\n dataTestId,\n setListCount,\n verifyListCount,\n getUrl,\n getTestTitle,\n joinHyphenCase,\n hyphenize,\n initializeCredentials,\n};\n"],"mappings":";;;AAAA,SAASA,WAAW;AAEpB,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,SAAS;EAAA,OAChCC,MAAM,CAACD,SAAS,CAACE,IAAI,EAAE,CAACC,IAAI,EAAE,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAAA;AAE/C,IAAMC,GAAG,GAAG;EACVC,aAAa,EAAEC,OAAO,CAACF,GAAG,CAAC,YAAY,CAAC,KAAKP,WAAW,CAACU,WAAW;EACpEC,QAAQ,EAAEF,OAAO,CAACF,GAAG,CAAC,YAAY,CAAC,KAAKP,WAAW,CAACY,MAAM;EAC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