@commercetools-frontend/cypress 25.0.0 → 25.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,6 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
9
9
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
10
10
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
11
11
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
12
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
13
12
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
14
13
  var constants = require('@commercetools-frontend/constants');
15
14
  var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
@@ -29,16 +28,14 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
29
28
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
30
29
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
31
30
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
32
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
33
31
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
34
32
  var _URL__default = /*#__PURE__*/_interopDefault(_URL);
35
33
  var semver__default = /*#__PURE__*/_interopDefault(semver);
36
34
  var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
37
35
  var _reduceRightInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceRightInstanceProperty);
38
36
 
39
- var _Cypress$config;
40
37
  function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys$1(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$1(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
38
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
42
39
 
43
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
41
 
@@ -58,16 +55,15 @@ function isRunningOnLocalhost() {
58
55
  }
59
56
  const isCustomView = commandOptions => commandOptions.entryPointUriPath === constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
60
57
  function loginByForm(commandOptions) {
61
- var _commandOptions$proje, _packageName;
62
58
  const isLocalhost = isRunningOnLocalhost();
63
59
  Cypress.log({
64
60
  name: 'isLocalhost',
65
61
  message: isLocalhost
66
62
  });
67
- const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
63
+ const projectKey = commandOptions.projectKey ?? Cypress.env('PROJECT_KEY');
68
64
  const isCustomViewConfigCommand = isCustomView(commandOptions);
69
65
  const customEntityConfigCommand = isCustomViewConfigCommand ? 'customViewConfig' : 'customApplicationConfig';
70
- const packageName = (_packageName = commandOptions.packageName) !== null && _packageName !== void 0 ? _packageName : Cypress.env('PACKAGE_NAME');
66
+ const packageName = commandOptions.packageName ?? Cypress.env('PACKAGE_NAME');
71
67
  cy.task(customEntityConfigCommand, _objectSpread$1({
72
68
  entryPointUriPath: commandOptions.entryPointUriPath,
73
69
  dotfiles: commandOptions.dotfiles
@@ -78,10 +74,9 @@ function loginByForm(commandOptions) {
78
74
  {
79
75
  log: false
80
76
  }).then(appConfig => {
81
- var _context, _commandOptions$login;
82
- let initialUriPath = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
77
+ let initialUriPath = `/${projectKey}/${commandOptions.entryPointUriPath}`;
83
78
  if (commandOptions.entryPointUriPath === 'account') {
84
- initialUriPath = "/".concat(commandOptions.entryPointUriPath);
79
+ initialUriPath = `/${commandOptions.entryPointUriPath}`;
85
80
  }
86
81
 
87
82
  // Log loaded application config for debugging purposes.
@@ -90,7 +85,7 @@ function loginByForm(commandOptions) {
90
85
  name: customEntityConfigCommand,
91
86
  message: appConfig
92
87
  });
93
- const userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
88
+ const userCredentials = commandOptions.login ?? {
94
89
  email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
95
90
  password: Cypress.env('LOGIN_PASSWORD')
96
91
  };
@@ -105,10 +100,10 @@ function loginByForm(commandOptions) {
105
100
  // check whether Identity is enabled
106
101
  cy.request({
107
102
  method: 'POST',
108
- url: "".concat(appConfig.mcApiUrl, "/graphql"),
103
+ url: `${appConfig.mcApiUrl}/graphql`,
109
104
  body: {
110
105
  operationName: 'AllFeatures',
111
- query: "query AllFeatures { allFeatures { name value } }"
106
+ query: `query AllFeatures { allFeatures { name value } }`
112
107
  },
113
108
  headers: {
114
109
  'content-type': 'application/json',
@@ -117,9 +112,9 @@ function loginByForm(commandOptions) {
117
112
  'x-project-key': projectKey
118
113
  }
119
114
  }).then(res => {
120
- var _context2;
121
- const enableIdentity = _findInstanceProperty__default["default"](_context2 = res.body.data.allFeatures).call(_context2, feature => feature.name === 'enableGlobalIdentity');
122
- const isGlobalIdentityEnabled = Boolean(enableIdentity === null || enableIdentity === void 0 ? void 0 : enableIdentity.value);
115
+ var _context;
116
+ const enableIdentity = _findInstanceProperty__default["default"](_context = res.body.data.allFeatures).call(_context, feature => feature.name === 'enableGlobalIdentity');
117
+ const isGlobalIdentityEnabled = Boolean(enableIdentity?.value);
123
118
  Cypress.log({
124
119
  name: 'isGlobalIdentityEnabled',
125
120
  message: isGlobalIdentityEnabled
@@ -163,7 +158,6 @@ function loginByForm(commandOptions) {
163
158
  */
164
159
 
165
160
  if (isLocalhost) {
166
- var _commandOptions$timeo, _commandOptions$timeo2;
167
161
  // Visit the special endpoint /api/health to ensure that the primary origin is set to localhost.
168
162
  cy.visit('/api/health');
169
163
  // Visit the application URL, which triggers then the login flow.
@@ -176,7 +170,7 @@ function loginByForm(commandOptions) {
176
170
  // but the test is still in the initial origin URL.
177
171
  // This is a bit unexpected and to be considered a workaround.
178
172
  // eslint-disable-next-line cypress/no-unnecessary-waiting
179
- cy.wait((_commandOptions$timeo = (_commandOptions$timeo2 = commandOptions.timeouts) === null || _commandOptions$timeo2 === void 0 ? void 0 : _commandOptions$timeo2.waitForRedirectToLogin) !== null && _commandOptions$timeo !== void 0 ? _commandOptions$timeo : defaultTimeouts.waitForRedirectToLogin);
173
+ cy.wait(commandOptions.timeouts?.waitForRedirectToLogin ?? defaultTimeouts.waitForRedirectToLogin);
180
174
  if (isGlobalIdentityEnabled) {
181
175
  // Use cy.origin to handle the identity domain
182
176
  cy.origin(identityUrl, {
@@ -187,7 +181,7 @@ function loginByForm(commandOptions) {
187
181
  }, _ref => {
188
182
  let userCredentials = _ref.userCredentials,
189
183
  identityUrl = _ref.identityUrl;
190
- cy.url().should('include', "".concat(identityUrl, "/login"));
184
+ cy.url().should('include', `${identityUrl}/login`);
191
185
  // Fill in the email and click Next
192
186
  cy.get('input[name="identifier"]').type(userCredentials.email);
193
187
  cy.get('button').contains('Next').click({
@@ -215,7 +209,7 @@ function loginByForm(commandOptions) {
215
209
  }, _ref2 => {
216
210
  let userCredentials = _ref2.userCredentials,
217
211
  mcUrl = _ref2.mcUrl;
218
- cy.url().should('include', "".concat(mcUrl, "/login"));
212
+ cy.url().should('include', `${mcUrl}/login`);
219
213
 
220
214
  // Same as `fillLegacyLoginFormWithRetry`.
221
215
  // eslint-disable-next-line cypress/unsafe-to-chain-command
@@ -262,7 +256,7 @@ function loginByForm(commandOptions) {
262
256
  args: identityArgs
263
257
  }, args => {
264
258
  cy.visit({
265
- url: "/login",
259
+ url: `/login`,
266
260
  qs: {
267
261
  returnTo: args.returnTo
268
262
  }
@@ -314,12 +308,11 @@ function loginByForm(commandOptions) {
314
308
  // },
315
309
  } : undefined);
316
310
  } else {
317
- cy.log("We recommend to use \"cy.session\" to reduce the time to log in between tests. Make sure to have at least Cypress v12 or enable it via \"experimentalSessionAndOrigin\" for older Cypress versions.");
311
+ cy.log(`We recommend to use "cy.session" to reduce the time to log in between tests. Make sure to have at least Cypress v12 or enable it via "experimentalSessionAndOrigin" for older Cypress versions.`);
318
312
  sessionAuthCallback();
319
313
  }
320
314
  if (commandOptions.initialRoute) {
321
- var _context3;
322
- cy.visit(_concatInstanceProperty__default["default"](_context3 = "".concat(Cypress.config('baseUrl'))).call(_context3, commandOptions.initialRoute));
315
+ cy.visit(`${Cypress.config('baseUrl')}${commandOptions.initialRoute}`);
323
316
  cy.url().should('include', commandOptions.initialRoute);
324
317
  }
325
318
  });
@@ -327,7 +320,7 @@ function loginByForm(commandOptions) {
327
320
 
328
321
  /* Utilities */
329
322
 
330
- const legacyMaxLoginAttempts = (_Cypress$config = Cypress.config('maxLoginAttempts')) !== null && _Cypress$config !== void 0 ? _Cypress$config : 3;
323
+ const legacyMaxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
331
324
  function fillLegacyLoginFormWithRetry(userCredentials) {
332
325
  // Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
333
326
  cy.intercept('POST', '**/tokens').as('loginRequest');
@@ -338,9 +331,9 @@ function fillLegacyLoginFormWithRetry(userCredentials) {
338
331
  }
339
332
  function attemptLogin(attemptsLeft) {
340
333
  if (attemptsLeft <= 0) {
341
- throw new Error("All login attempts exhausted. Please check your credentials.");
334
+ throw new Error(`All login attempts exhausted. Please check your credentials.`);
342
335
  }
343
- cy.log("Attempts left: ".concat(attemptsLeft));
336
+ cy.log(`Attempts left: ${attemptsLeft}`);
344
337
 
345
338
  // eslint-disable-next-line cypress/unsafe-to-chain-command
346
339
  cy.get('input[name=email]').clear({
@@ -395,7 +388,7 @@ async function fireCdpCommand(command, params) {
395
388
  command,
396
389
  params
397
390
  }).catch(error => {
398
- throw new Error("Failed request to chrome devtools protocol. This can happen if cypress lost connection to the browser or the command itself is not valid. Original cypress error: ".concat(error));
391
+ throw new Error(`Failed request to chrome devtools protocol. This can happen if cypress lost connection to the browser or the command itself is not valid. Original cypress error: ${error}`);
399
392
  });
400
393
  }
401
394
  function getPositionedCoordinates(x0, y0, width, height, position, frameScale) {
@@ -522,13 +515,12 @@ function getCypressElementCoordinates(
522
515
  // @ts-ignore
523
516
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
524
517
  jqueryEl, position, scrollBehavior) {
525
- var _ref2;
526
518
  const htmlElement = jqueryEl.get(0);
527
519
  const cypressAppFrame = window.parent.document.querySelector('iframe');
528
520
  if (!cypressAppFrame) {
529
521
  throw new Error('Can not find cypress application iframe, it looks like critical issue. Please rise an issue on GitHub.');
530
522
  }
531
- const effectiveScrollBehavior = (_ref2 = scrollBehavior !== null && scrollBehavior !== void 0 ? scrollBehavior : Cypress.config('scrollBehavior')) !== null && _ref2 !== void 0 ? _ref2 : 'center';
523
+ const effectiveScrollBehavior = scrollBehavior ?? Cypress.config('scrollBehavior') ?? 'center';
532
524
  if (effectiveScrollBehavior && typeof effectiveScrollBehavior !== 'object') {
533
525
  scrollIntoView(htmlElement, effectiveScrollBehavior);
534
526
  }
@@ -538,7 +530,7 @@ jqueryEl, position, scrollBehavior) {
538
530
  width = _getElementPositionXY.width,
539
531
  height = _getElementPositionXY.height,
540
532
  frameScale = _getElementPositionXY.frameScale;
541
- const _getPositionedCoordin = getPositionedCoordinates(x, y, width, height, position !== null && position !== void 0 ? position : 'center', frameScale),
533
+ const _getPositionedCoordin = getPositionedCoordinates(x, y, width, height, position ?? 'center', frameScale),
542
534
  _getPositionedCoordin2 = _slicedToArray(_getPositionedCoordin, 2),
543
535
  posX = _getPositionedCoordin2[0],
544
536
  posY = _getPositionedCoordin2[1];
@@ -558,7 +550,6 @@ async function realHover(
558
550
  // @ts-ignore
559
551
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
560
552
  subject) {
561
- var _options$pointer;
562
553
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
563
554
  const _getCypressElementCoo = getCypressElementCoordinates(subject, options.position, options.scrollBehavior),
564
555
  x = _getCypressElementCoo.x,
@@ -579,7 +570,7 @@ subject) {
579
570
  y,
580
571
  type: 'mouseMoved',
581
572
  button: 'none',
582
- pointerType: (_options$pointer = options.pointer) !== null && _options$pointer !== void 0 ? _options$pointer : 'mouse',
573
+ pointerType: options.pointer ?? 'mouse',
583
574
  modifiers: options.shiftKey ? keyToModifierBitMap.Shift : 0
584
575
  });
585
576
  log.snapshot().end();
@@ -587,7 +578,7 @@ subject) {
587
578
  }
588
579
 
589
580
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
590
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
581
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
591
582
 
592
583
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
593
584
 
@@ -600,14 +591,13 @@ Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
600
591
  loginByForm(commandOptions);
601
592
  });
602
593
  Cypress.Commands.add('loginToMerchantCenterForCustomView', commandOptions => {
603
- var _context;
604
594
  Cypress.log({
605
595
  name: 'loginToMerchantCenterForCustomView'
606
596
  });
607
597
  const projectKey = Cypress.env('PROJECT_KEY');
608
598
  loginByForm(_objectSpread(_objectSpread({}, commandOptions), {}, {
609
599
  entryPointUriPath: constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH,
610
- initialRoute: _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH)
600
+ initialRoute: `/${projectKey}/${constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH}`
611
601
  }));
612
602
  });
613
603
  Cypress.Commands.add('loginByOidc', commandOptions => {
@@ -634,7 +624,7 @@ Cypress.Commands.add('getIframeBody', {
634
624
  $iframe => {
635
625
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
636
626
  return new Cypress.Promise(resolve => {
637
- var _context2;
638
- resolve(_findInstanceProperty__default["default"](_context2 = $iframe.contents()).call(_context2, 'body'));
627
+ var _context;
628
+ resolve(_findInstanceProperty__default["default"](_context = $iframe.contents()).call(_context, 'body'));
639
629
  });
640
630
  });
@@ -9,7 +9,6 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
9
9
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
10
10
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
11
11
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
12
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
13
12
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
14
13
  var constants = require('@commercetools-frontend/constants');
15
14
  var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
@@ -29,16 +28,14 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
29
28
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
30
29
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
31
30
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
32
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
33
31
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
34
32
  var _URL__default = /*#__PURE__*/_interopDefault(_URL);
35
33
  var semver__default = /*#__PURE__*/_interopDefault(semver);
36
34
  var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
37
35
  var _reduceRightInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceRightInstanceProperty);
38
36
 
39
- var _Cypress$config;
40
37
  function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys$1(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$1(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
38
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
42
39
 
43
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
41
 
@@ -58,16 +55,15 @@ function isRunningOnLocalhost() {
58
55
  }
59
56
  const isCustomView = commandOptions => commandOptions.entryPointUriPath === constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
60
57
  function loginByForm(commandOptions) {
61
- var _commandOptions$proje, _packageName;
62
58
  const isLocalhost = isRunningOnLocalhost();
63
59
  Cypress.log({
64
60
  name: 'isLocalhost',
65
61
  message: isLocalhost
66
62
  });
67
- const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
63
+ const projectKey = commandOptions.projectKey ?? Cypress.env('PROJECT_KEY');
68
64
  const isCustomViewConfigCommand = isCustomView(commandOptions);
69
65
  const customEntityConfigCommand = isCustomViewConfigCommand ? 'customViewConfig' : 'customApplicationConfig';
70
- const packageName = (_packageName = commandOptions.packageName) !== null && _packageName !== void 0 ? _packageName : Cypress.env('PACKAGE_NAME');
66
+ const packageName = commandOptions.packageName ?? Cypress.env('PACKAGE_NAME');
71
67
  cy.task(customEntityConfigCommand, _objectSpread$1({
72
68
  entryPointUriPath: commandOptions.entryPointUriPath,
73
69
  dotfiles: commandOptions.dotfiles
@@ -78,10 +74,9 @@ function loginByForm(commandOptions) {
78
74
  {
79
75
  log: false
80
76
  }).then(appConfig => {
81
- var _context, _commandOptions$login;
82
- let initialUriPath = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
77
+ let initialUriPath = `/${projectKey}/${commandOptions.entryPointUriPath}`;
83
78
  if (commandOptions.entryPointUriPath === 'account') {
84
- initialUriPath = "/".concat(commandOptions.entryPointUriPath);
79
+ initialUriPath = `/${commandOptions.entryPointUriPath}`;
85
80
  }
86
81
 
87
82
  // Log loaded application config for debugging purposes.
@@ -90,7 +85,7 @@ function loginByForm(commandOptions) {
90
85
  name: customEntityConfigCommand,
91
86
  message: appConfig
92
87
  });
93
- const userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
88
+ const userCredentials = commandOptions.login ?? {
94
89
  email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
95
90
  password: Cypress.env('LOGIN_PASSWORD')
96
91
  };
@@ -105,10 +100,10 @@ function loginByForm(commandOptions) {
105
100
  // check whether Identity is enabled
106
101
  cy.request({
107
102
  method: 'POST',
108
- url: "".concat(appConfig.mcApiUrl, "/graphql"),
103
+ url: `${appConfig.mcApiUrl}/graphql`,
109
104
  body: {
110
105
  operationName: 'AllFeatures',
111
- query: "query AllFeatures { allFeatures { name value } }"
106
+ query: `query AllFeatures { allFeatures { name value } }`
112
107
  },
113
108
  headers: {
114
109
  'content-type': 'application/json',
@@ -117,9 +112,9 @@ function loginByForm(commandOptions) {
117
112
  'x-project-key': projectKey
118
113
  }
119
114
  }).then(res => {
120
- var _context2;
121
- const enableIdentity = _findInstanceProperty__default["default"](_context2 = res.body.data.allFeatures).call(_context2, feature => feature.name === 'enableGlobalIdentity');
122
- const isGlobalIdentityEnabled = Boolean(enableIdentity === null || enableIdentity === void 0 ? void 0 : enableIdentity.value);
115
+ var _context;
116
+ const enableIdentity = _findInstanceProperty__default["default"](_context = res.body.data.allFeatures).call(_context, feature => feature.name === 'enableGlobalIdentity');
117
+ const isGlobalIdentityEnabled = Boolean(enableIdentity?.value);
123
118
  Cypress.log({
124
119
  name: 'isGlobalIdentityEnabled',
125
120
  message: isGlobalIdentityEnabled
@@ -163,7 +158,6 @@ function loginByForm(commandOptions) {
163
158
  */
164
159
 
165
160
  if (isLocalhost) {
166
- var _commandOptions$timeo, _commandOptions$timeo2;
167
161
  // Visit the special endpoint /api/health to ensure that the primary origin is set to localhost.
168
162
  cy.visit('/api/health');
169
163
  // Visit the application URL, which triggers then the login flow.
@@ -176,7 +170,7 @@ function loginByForm(commandOptions) {
176
170
  // but the test is still in the initial origin URL.
177
171
  // This is a bit unexpected and to be considered a workaround.
178
172
  // eslint-disable-next-line cypress/no-unnecessary-waiting
179
- cy.wait((_commandOptions$timeo = (_commandOptions$timeo2 = commandOptions.timeouts) === null || _commandOptions$timeo2 === void 0 ? void 0 : _commandOptions$timeo2.waitForRedirectToLogin) !== null && _commandOptions$timeo !== void 0 ? _commandOptions$timeo : defaultTimeouts.waitForRedirectToLogin);
173
+ cy.wait(commandOptions.timeouts?.waitForRedirectToLogin ?? defaultTimeouts.waitForRedirectToLogin);
180
174
  if (isGlobalIdentityEnabled) {
181
175
  // Use cy.origin to handle the identity domain
182
176
  cy.origin(identityUrl, {
@@ -187,7 +181,7 @@ function loginByForm(commandOptions) {
187
181
  }, _ref => {
188
182
  let userCredentials = _ref.userCredentials,
189
183
  identityUrl = _ref.identityUrl;
190
- cy.url().should('include', "".concat(identityUrl, "/login"));
184
+ cy.url().should('include', `${identityUrl}/login`);
191
185
  // Fill in the email and click Next
192
186
  cy.get('input[name="identifier"]').type(userCredentials.email);
193
187
  cy.get('button').contains('Next').click({
@@ -215,7 +209,7 @@ function loginByForm(commandOptions) {
215
209
  }, _ref2 => {
216
210
  let userCredentials = _ref2.userCredentials,
217
211
  mcUrl = _ref2.mcUrl;
218
- cy.url().should('include', "".concat(mcUrl, "/login"));
212
+ cy.url().should('include', `${mcUrl}/login`);
219
213
 
220
214
  // Same as `fillLegacyLoginFormWithRetry`.
221
215
  // eslint-disable-next-line cypress/unsafe-to-chain-command
@@ -262,7 +256,7 @@ function loginByForm(commandOptions) {
262
256
  args: identityArgs
263
257
  }, args => {
264
258
  cy.visit({
265
- url: "/login",
259
+ url: `/login`,
266
260
  qs: {
267
261
  returnTo: args.returnTo
268
262
  }
@@ -314,12 +308,11 @@ function loginByForm(commandOptions) {
314
308
  // },
315
309
  } : undefined);
316
310
  } else {
317
- cy.log("We recommend to use \"cy.session\" to reduce the time to log in between tests. Make sure to have at least Cypress v12 or enable it via \"experimentalSessionAndOrigin\" for older Cypress versions.");
311
+ cy.log(`We recommend to use "cy.session" to reduce the time to log in between tests. Make sure to have at least Cypress v12 or enable it via "experimentalSessionAndOrigin" for older Cypress versions.`);
318
312
  sessionAuthCallback();
319
313
  }
320
314
  if (commandOptions.initialRoute) {
321
- var _context3;
322
- cy.visit(_concatInstanceProperty__default["default"](_context3 = "".concat(Cypress.config('baseUrl'))).call(_context3, commandOptions.initialRoute));
315
+ cy.visit(`${Cypress.config('baseUrl')}${commandOptions.initialRoute}`);
323
316
  cy.url().should('include', commandOptions.initialRoute);
324
317
  }
325
318
  });
@@ -327,7 +320,7 @@ function loginByForm(commandOptions) {
327
320
 
328
321
  /* Utilities */
329
322
 
330
- const legacyMaxLoginAttempts = (_Cypress$config = Cypress.config('maxLoginAttempts')) !== null && _Cypress$config !== void 0 ? _Cypress$config : 3;
323
+ const legacyMaxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
331
324
  function fillLegacyLoginFormWithRetry(userCredentials) {
332
325
  // Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
333
326
  cy.intercept('POST', '**/tokens').as('loginRequest');
@@ -338,9 +331,9 @@ function fillLegacyLoginFormWithRetry(userCredentials) {
338
331
  }
339
332
  function attemptLogin(attemptsLeft) {
340
333
  if (attemptsLeft <= 0) {
341
- throw new Error("All login attempts exhausted. Please check your credentials.");
334
+ throw new Error(`All login attempts exhausted. Please check your credentials.`);
342
335
  }
343
- cy.log("Attempts left: ".concat(attemptsLeft));
336
+ cy.log(`Attempts left: ${attemptsLeft}`);
344
337
 
345
338
  // eslint-disable-next-line cypress/unsafe-to-chain-command
346
339
  cy.get('input[name=email]').clear({
@@ -395,7 +388,7 @@ async function fireCdpCommand(command, params) {
395
388
  command,
396
389
  params
397
390
  }).catch(error => {
398
- throw new Error("Failed request to chrome devtools protocol. This can happen if cypress lost connection to the browser or the command itself is not valid. Original cypress error: ".concat(error));
391
+ throw new Error(`Failed request to chrome devtools protocol. This can happen if cypress lost connection to the browser or the command itself is not valid. Original cypress error: ${error}`);
399
392
  });
400
393
  }
401
394
  function getPositionedCoordinates(x0, y0, width, height, position, frameScale) {
@@ -522,13 +515,12 @@ function getCypressElementCoordinates(
522
515
  // @ts-ignore
523
516
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
524
517
  jqueryEl, position, scrollBehavior) {
525
- var _ref2;
526
518
  const htmlElement = jqueryEl.get(0);
527
519
  const cypressAppFrame = window.parent.document.querySelector('iframe');
528
520
  if (!cypressAppFrame) {
529
521
  throw new Error('Can not find cypress application iframe, it looks like critical issue. Please rise an issue on GitHub.');
530
522
  }
531
- const effectiveScrollBehavior = (_ref2 = scrollBehavior !== null && scrollBehavior !== void 0 ? scrollBehavior : Cypress.config('scrollBehavior')) !== null && _ref2 !== void 0 ? _ref2 : 'center';
523
+ const effectiveScrollBehavior = scrollBehavior ?? Cypress.config('scrollBehavior') ?? 'center';
532
524
  if (effectiveScrollBehavior && typeof effectiveScrollBehavior !== 'object') {
533
525
  scrollIntoView(htmlElement, effectiveScrollBehavior);
534
526
  }
@@ -538,7 +530,7 @@ jqueryEl, position, scrollBehavior) {
538
530
  width = _getElementPositionXY.width,
539
531
  height = _getElementPositionXY.height,
540
532
  frameScale = _getElementPositionXY.frameScale;
541
- const _getPositionedCoordin = getPositionedCoordinates(x, y, width, height, position !== null && position !== void 0 ? position : 'center', frameScale),
533
+ const _getPositionedCoordin = getPositionedCoordinates(x, y, width, height, position ?? 'center', frameScale),
542
534
  _getPositionedCoordin2 = _slicedToArray(_getPositionedCoordin, 2),
543
535
  posX = _getPositionedCoordin2[0],
544
536
  posY = _getPositionedCoordin2[1];
@@ -558,7 +550,6 @@ async function realHover(
558
550
  // @ts-ignore
559
551
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
560
552
  subject) {
561
- var _options$pointer;
562
553
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
563
554
  const _getCypressElementCoo = getCypressElementCoordinates(subject, options.position, options.scrollBehavior),
564
555
  x = _getCypressElementCoo.x,
@@ -579,7 +570,7 @@ subject) {
579
570
  y,
580
571
  type: 'mouseMoved',
581
572
  button: 'none',
582
- pointerType: (_options$pointer = options.pointer) !== null && _options$pointer !== void 0 ? _options$pointer : 'mouse',
573
+ pointerType: options.pointer ?? 'mouse',
583
574
  modifiers: options.shiftKey ? keyToModifierBitMap.Shift : 0
584
575
  });
585
576
  log.snapshot().end();
@@ -587,7 +578,7 @@ subject) {
587
578
  }
588
579
 
589
580
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
590
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
581
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
591
582
 
592
583
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
593
584
 
@@ -600,14 +591,13 @@ Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
600
591
  loginByForm(commandOptions);
601
592
  });
602
593
  Cypress.Commands.add('loginToMerchantCenterForCustomView', commandOptions => {
603
- var _context;
604
594
  Cypress.log({
605
595
  name: 'loginToMerchantCenterForCustomView'
606
596
  });
607
597
  const projectKey = Cypress.env('PROJECT_KEY');
608
598
  loginByForm(_objectSpread(_objectSpread({}, commandOptions), {}, {
609
599
  entryPointUriPath: constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH,
610
- initialRoute: _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH)
600
+ initialRoute: `/${projectKey}/${constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH}`
611
601
  }));
612
602
  });
613
603
  Cypress.Commands.add('loginByOidc', commandOptions => {
@@ -634,7 +624,7 @@ Cypress.Commands.add('getIframeBody', {
634
624
  $iframe => {
635
625
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
636
626
  return new Cypress.Promise(resolve => {
637
- var _context2;
638
- resolve(_findInstanceProperty__default["default"](_context2 = $iframe.contents()).call(_context2, 'body'));
627
+ var _context;
628
+ resolve(_findInstanceProperty__default["default"](_context = $iframe.contents()).call(_context, 'body'));
639
629
  });
640
630
  });
@@ -7,7 +7,6 @@ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-st
7
7
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
8
8
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
- import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
11
10
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
12
11
  import { CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, GRAPHQL_TARGETS } from '@commercetools-frontend/constants';
13
12
  import _URL from '@babel/runtime-corejs3/core-js-stable/url';
@@ -17,9 +16,8 @@ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
17
16
  import _Array$from from '@babel/runtime-corejs3/core-js-stable/array/from';
18
17
  import _reduceRightInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce-right';
19
18
 
20
- var _Cypress$config;
21
19
  function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys$1(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys$1(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$1(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$1(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
23
21
 
24
22
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
23
 
@@ -39,16 +37,15 @@ function isRunningOnLocalhost() {
39
37
  }
40
38
  const isCustomView = commandOptions => commandOptions.entryPointUriPath === CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
41
39
  function loginByForm(commandOptions) {
42
- var _commandOptions$proje, _packageName;
43
40
  const isLocalhost = isRunningOnLocalhost();
44
41
  Cypress.log({
45
42
  name: 'isLocalhost',
46
43
  message: isLocalhost
47
44
  });
48
- const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
45
+ const projectKey = commandOptions.projectKey ?? Cypress.env('PROJECT_KEY');
49
46
  const isCustomViewConfigCommand = isCustomView(commandOptions);
50
47
  const customEntityConfigCommand = isCustomViewConfigCommand ? 'customViewConfig' : 'customApplicationConfig';
51
- const packageName = (_packageName = commandOptions.packageName) !== null && _packageName !== void 0 ? _packageName : Cypress.env('PACKAGE_NAME');
48
+ const packageName = commandOptions.packageName ?? Cypress.env('PACKAGE_NAME');
52
49
  cy.task(customEntityConfigCommand, _objectSpread$1({
53
50
  entryPointUriPath: commandOptions.entryPointUriPath,
54
51
  dotfiles: commandOptions.dotfiles
@@ -59,10 +56,9 @@ function loginByForm(commandOptions) {
59
56
  {
60
57
  log: false
61
58
  }).then(appConfig => {
62
- var _context, _commandOptions$login;
63
- let initialUriPath = _concatInstanceProperty(_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
59
+ let initialUriPath = `/${projectKey}/${commandOptions.entryPointUriPath}`;
64
60
  if (commandOptions.entryPointUriPath === 'account') {
65
- initialUriPath = "/".concat(commandOptions.entryPointUriPath);
61
+ initialUriPath = `/${commandOptions.entryPointUriPath}`;
66
62
  }
67
63
 
68
64
  // Log loaded application config for debugging purposes.
@@ -71,7 +67,7 @@ function loginByForm(commandOptions) {
71
67
  name: customEntityConfigCommand,
72
68
  message: appConfig
73
69
  });
74
- const userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
70
+ const userCredentials = commandOptions.login ?? {
75
71
  email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
76
72
  password: Cypress.env('LOGIN_PASSWORD')
77
73
  };
@@ -86,10 +82,10 @@ function loginByForm(commandOptions) {
86
82
  // check whether Identity is enabled
87
83
  cy.request({
88
84
  method: 'POST',
89
- url: "".concat(appConfig.mcApiUrl, "/graphql"),
85
+ url: `${appConfig.mcApiUrl}/graphql`,
90
86
  body: {
91
87
  operationName: 'AllFeatures',
92
- query: "query AllFeatures { allFeatures { name value } }"
88
+ query: `query AllFeatures { allFeatures { name value } }`
93
89
  },
94
90
  headers: {
95
91
  'content-type': 'application/json',
@@ -98,9 +94,9 @@ function loginByForm(commandOptions) {
98
94
  'x-project-key': projectKey
99
95
  }
100
96
  }).then(res => {
101
- var _context2;
102
- const enableIdentity = _findInstanceProperty(_context2 = res.body.data.allFeatures).call(_context2, feature => feature.name === 'enableGlobalIdentity');
103
- const isGlobalIdentityEnabled = Boolean(enableIdentity === null || enableIdentity === void 0 ? void 0 : enableIdentity.value);
97
+ var _context;
98
+ const enableIdentity = _findInstanceProperty(_context = res.body.data.allFeatures).call(_context, feature => feature.name === 'enableGlobalIdentity');
99
+ const isGlobalIdentityEnabled = Boolean(enableIdentity?.value);
104
100
  Cypress.log({
105
101
  name: 'isGlobalIdentityEnabled',
106
102
  message: isGlobalIdentityEnabled
@@ -144,7 +140,6 @@ function loginByForm(commandOptions) {
144
140
  */
145
141
 
146
142
  if (isLocalhost) {
147
- var _commandOptions$timeo, _commandOptions$timeo2;
148
143
  // Visit the special endpoint /api/health to ensure that the primary origin is set to localhost.
149
144
  cy.visit('/api/health');
150
145
  // Visit the application URL, which triggers then the login flow.
@@ -157,7 +152,7 @@ function loginByForm(commandOptions) {
157
152
  // but the test is still in the initial origin URL.
158
153
  // This is a bit unexpected and to be considered a workaround.
159
154
  // eslint-disable-next-line cypress/no-unnecessary-waiting
160
- cy.wait((_commandOptions$timeo = (_commandOptions$timeo2 = commandOptions.timeouts) === null || _commandOptions$timeo2 === void 0 ? void 0 : _commandOptions$timeo2.waitForRedirectToLogin) !== null && _commandOptions$timeo !== void 0 ? _commandOptions$timeo : defaultTimeouts.waitForRedirectToLogin);
155
+ cy.wait(commandOptions.timeouts?.waitForRedirectToLogin ?? defaultTimeouts.waitForRedirectToLogin);
161
156
  if (isGlobalIdentityEnabled) {
162
157
  // Use cy.origin to handle the identity domain
163
158
  cy.origin(identityUrl, {
@@ -168,7 +163,7 @@ function loginByForm(commandOptions) {
168
163
  }, _ref => {
169
164
  let userCredentials = _ref.userCredentials,
170
165
  identityUrl = _ref.identityUrl;
171
- cy.url().should('include', "".concat(identityUrl, "/login"));
166
+ cy.url().should('include', `${identityUrl}/login`);
172
167
  // Fill in the email and click Next
173
168
  cy.get('input[name="identifier"]').type(userCredentials.email);
174
169
  cy.get('button').contains('Next').click({
@@ -196,7 +191,7 @@ function loginByForm(commandOptions) {
196
191
  }, _ref2 => {
197
192
  let userCredentials = _ref2.userCredentials,
198
193
  mcUrl = _ref2.mcUrl;
199
- cy.url().should('include', "".concat(mcUrl, "/login"));
194
+ cy.url().should('include', `${mcUrl}/login`);
200
195
 
201
196
  // Same as `fillLegacyLoginFormWithRetry`.
202
197
  // eslint-disable-next-line cypress/unsafe-to-chain-command
@@ -243,7 +238,7 @@ function loginByForm(commandOptions) {
243
238
  args: identityArgs
244
239
  }, args => {
245
240
  cy.visit({
246
- url: "/login",
241
+ url: `/login`,
247
242
  qs: {
248
243
  returnTo: args.returnTo
249
244
  }
@@ -295,12 +290,11 @@ function loginByForm(commandOptions) {
295
290
  // },
296
291
  } : undefined);
297
292
  } else {
298
- cy.log("We recommend to use \"cy.session\" to reduce the time to log in between tests. Make sure to have at least Cypress v12 or enable it via \"experimentalSessionAndOrigin\" for older Cypress versions.");
293
+ cy.log(`We recommend to use "cy.session" to reduce the time to log in between tests. Make sure to have at least Cypress v12 or enable it via "experimentalSessionAndOrigin" for older Cypress versions.`);
299
294
  sessionAuthCallback();
300
295
  }
301
296
  if (commandOptions.initialRoute) {
302
- var _context3;
303
- cy.visit(_concatInstanceProperty(_context3 = "".concat(Cypress.config('baseUrl'))).call(_context3, commandOptions.initialRoute));
297
+ cy.visit(`${Cypress.config('baseUrl')}${commandOptions.initialRoute}`);
304
298
  cy.url().should('include', commandOptions.initialRoute);
305
299
  }
306
300
  });
@@ -308,7 +302,7 @@ function loginByForm(commandOptions) {
308
302
 
309
303
  /* Utilities */
310
304
 
311
- const legacyMaxLoginAttempts = (_Cypress$config = Cypress.config('maxLoginAttempts')) !== null && _Cypress$config !== void 0 ? _Cypress$config : 3;
305
+ const legacyMaxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
312
306
  function fillLegacyLoginFormWithRetry(userCredentials) {
313
307
  // Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
314
308
  cy.intercept('POST', '**/tokens').as('loginRequest');
@@ -319,9 +313,9 @@ function fillLegacyLoginFormWithRetry(userCredentials) {
319
313
  }
320
314
  function attemptLogin(attemptsLeft) {
321
315
  if (attemptsLeft <= 0) {
322
- throw new Error("All login attempts exhausted. Please check your credentials.");
316
+ throw new Error(`All login attempts exhausted. Please check your credentials.`);
323
317
  }
324
- cy.log("Attempts left: ".concat(attemptsLeft));
318
+ cy.log(`Attempts left: ${attemptsLeft}`);
325
319
 
326
320
  // eslint-disable-next-line cypress/unsafe-to-chain-command
327
321
  cy.get('input[name=email]').clear({
@@ -376,7 +370,7 @@ async function fireCdpCommand(command, params) {
376
370
  command,
377
371
  params
378
372
  }).catch(error => {
379
- throw new Error("Failed request to chrome devtools protocol. This can happen if cypress lost connection to the browser or the command itself is not valid. Original cypress error: ".concat(error));
373
+ throw new Error(`Failed request to chrome devtools protocol. This can happen if cypress lost connection to the browser or the command itself is not valid. Original cypress error: ${error}`);
380
374
  });
381
375
  }
382
376
  function getPositionedCoordinates(x0, y0, width, height, position, frameScale) {
@@ -503,13 +497,12 @@ function getCypressElementCoordinates(
503
497
  // @ts-ignore
504
498
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
505
499
  jqueryEl, position, scrollBehavior) {
506
- var _ref2;
507
500
  const htmlElement = jqueryEl.get(0);
508
501
  const cypressAppFrame = window.parent.document.querySelector('iframe');
509
502
  if (!cypressAppFrame) {
510
503
  throw new Error('Can not find cypress application iframe, it looks like critical issue. Please rise an issue on GitHub.');
511
504
  }
512
- const effectiveScrollBehavior = (_ref2 = scrollBehavior !== null && scrollBehavior !== void 0 ? scrollBehavior : Cypress.config('scrollBehavior')) !== null && _ref2 !== void 0 ? _ref2 : 'center';
505
+ const effectiveScrollBehavior = scrollBehavior ?? Cypress.config('scrollBehavior') ?? 'center';
513
506
  if (effectiveScrollBehavior && typeof effectiveScrollBehavior !== 'object') {
514
507
  scrollIntoView(htmlElement, effectiveScrollBehavior);
515
508
  }
@@ -519,7 +512,7 @@ jqueryEl, position, scrollBehavior) {
519
512
  width = _getElementPositionXY.width,
520
513
  height = _getElementPositionXY.height,
521
514
  frameScale = _getElementPositionXY.frameScale;
522
- const _getPositionedCoordin = getPositionedCoordinates(x, y, width, height, position !== null && position !== void 0 ? position : 'center', frameScale),
515
+ const _getPositionedCoordin = getPositionedCoordinates(x, y, width, height, position ?? 'center', frameScale),
523
516
  _getPositionedCoordin2 = _slicedToArray(_getPositionedCoordin, 2),
524
517
  posX = _getPositionedCoordin2[0],
525
518
  posY = _getPositionedCoordin2[1];
@@ -539,7 +532,6 @@ async function realHover(
539
532
  // @ts-ignore
540
533
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
541
534
  subject) {
542
- var _options$pointer;
543
535
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
544
536
  const _getCypressElementCoo = getCypressElementCoordinates(subject, options.position, options.scrollBehavior),
545
537
  x = _getCypressElementCoo.x,
@@ -560,7 +552,7 @@ subject) {
560
552
  y,
561
553
  type: 'mouseMoved',
562
554
  button: 'none',
563
- pointerType: (_options$pointer = options.pointer) !== null && _options$pointer !== void 0 ? _options$pointer : 'mouse',
555
+ pointerType: options.pointer ?? 'mouse',
564
556
  modifiers: options.shiftKey ? keyToModifierBitMap.Shift : 0
565
557
  });
566
558
  log.snapshot().end();
@@ -568,7 +560,7 @@ subject) {
568
560
  }
569
561
 
570
562
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
571
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
563
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
572
564
 
573
565
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
574
566
 
@@ -581,14 +573,13 @@ Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
581
573
  loginByForm(commandOptions);
582
574
  });
583
575
  Cypress.Commands.add('loginToMerchantCenterForCustomView', commandOptions => {
584
- var _context;
585
576
  Cypress.log({
586
577
  name: 'loginToMerchantCenterForCustomView'
587
578
  });
588
579
  const projectKey = Cypress.env('PROJECT_KEY');
589
580
  loginByForm(_objectSpread(_objectSpread({}, commandOptions), {}, {
590
581
  entryPointUriPath: CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH,
591
- initialRoute: _concatInstanceProperty(_context = "/".concat(projectKey, "/")).call(_context, CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH)
582
+ initialRoute: `/${projectKey}/${CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH}`
592
583
  }));
593
584
  });
594
585
  Cypress.Commands.add('loginByOidc', commandOptions => {
@@ -615,7 +606,7 @@ Cypress.Commands.add('getIframeBody', {
615
606
  $iframe => {
616
607
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
617
608
  return new Cypress.Promise(resolve => {
618
- var _context2;
619
- resolve(_findInstanceProperty(_context2 = $iframe.contents()).call(_context2, 'body'));
609
+ var _context;
610
+ resolve(_findInstanceProperty(_context = $iframe.contents()).call(_context, 'body'));
620
611
  });
621
612
  });
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var constants = require('./constants-009cb682.cjs.dev.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "25.0.0";
8
+ var version = "25.2.0";
9
9
 
10
10
  exports.HTTP_STATUS_CODES = constants.HTTP_STATUS_CODES;
11
11
  exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var constants = require('./constants-2f1475a6.cjs.prod.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "25.0.0";
8
+ var version = "25.2.0";
9
9
 
10
10
  exports.HTTP_STATUS_CODES = constants.HTTP_STATUS_CODES;
11
11
  exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
@@ -1,6 +1,6 @@
1
1
  export { H as HTTP_STATUS_CODES, O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from './constants-13c76918.esm.js';
2
2
 
3
3
  // NOTE: This string will be replaced on build time with the package version.
4
- var version = "25.0.0";
4
+ var version = "25.2.0";
5
5
 
6
6
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress",
3
- "version": "25.0.0",
3
+ "version": "25.2.0",
4
4
  "description": "Cypress commands and utilities for Custom Applications",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -41,9 +41,9 @@
41
41
  "dependencies": {
42
42
  "@babel/runtime": "^7.22.15",
43
43
  "@babel/runtime-corejs3": "^7.22.15",
44
- "@commercetools-frontend/application-config": "25.0.0",
45
- "@commercetools-frontend/application-shell": "25.0.0",
46
- "@commercetools-frontend/constants": "25.0.0",
44
+ "@commercetools-frontend/application-config": "25.2.0",
45
+ "@commercetools-frontend/application-shell": "25.2.0",
46
+ "@commercetools-frontend/constants": "25.2.0",
47
47
  "@manypkg/get-packages": "1.1.3",
48
48
  "@types/semver": "^7.5.1",
49
49
  "semver": "7.7.2",
@@ -12,7 +12,6 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
14
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
16
15
  var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
17
16
  var fs = require('fs');
18
17
  var path = require('path');
@@ -31,13 +30,12 @@ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_O
31
30
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
32
31
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
33
32
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
34
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
35
33
  var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
36
34
  var fs__default = /*#__PURE__*/_interopDefault(fs);
37
35
  var path__default = /*#__PURE__*/_interopDefault(path);
38
36
 
39
37
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
40
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
38
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
41
39
  function doesFileExist(path) {
42
40
  try {
43
41
  fs__default["default"].accessSync(path);
@@ -49,8 +47,7 @@ function doesFileExist(path) {
49
47
  let cachedAllCustomEntityConfigs;
50
48
  const defaultDotfiles = ['.env', '.env.local'];
51
49
  const loadEnvironmentVariables = (packageDirPath, options) => {
52
- var _options$dotfiles;
53
- const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
50
+ const dotfiles = options.dotfiles ?? defaultDotfiles;
54
51
  return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
55
52
  const envPath = path__default["default"].join(packageDirPath, dotfile);
56
53
  if (!doesFileExist(envPath)) {
@@ -60,10 +57,10 @@ const loadEnvironmentVariables = (packageDirPath, options) => {
60
57
  path: envPath
61
58
  });
62
59
  if (env.error) {
63
- console.error("Failed to load environment variables from ".concat(envPath));
60
+ console.error(`Failed to load environment variables from ${envPath}`);
64
61
  return mergedEnvs;
65
62
  }
66
- console.log("Loading environment variables from ".concat(envPath));
63
+ console.log(`Loading environment variables from ${envPath}`);
67
64
  return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
68
65
  // Merge it with the environment variables defined in the current process.
69
66
  }, process.env);
@@ -78,15 +75,14 @@ const loadAllCustomEntityConfigs = async options => {
78
75
  const allConfigs = await allConfigsPromise;
79
76
  const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
80
77
  try {
81
- var _context, _context2;
82
78
  const processedConfig = await applicationConfig.processConfig({
83
79
  disableCache: true,
84
80
  processEnv,
85
81
  applicationPath: packageInfo.dir
86
82
  });
87
83
  const isCustomViewConfig = Boolean(processedConfig.env.customViewId);
88
- console.log(_concatInstanceProperty__default["default"](_context = "Found Custom ".concat(isCustomViewConfig ? 'View' : 'Application', " config for ")).call(_context, packageInfo.packageJson.name));
89
- const customEntityConfigCacheKey = isCustomViewConfig ? _concatInstanceProperty__default["default"](_context2 = "".concat(processedConfig.env.entryPointUriPath, "-")).call(_context2, packageInfo.packageJson.name) : processedConfig.env.entryPointUriPath;
84
+ console.log(`Found Custom ${isCustomViewConfig ? 'View' : 'Application'} config for ${packageInfo.packageJson.name}`);
85
+ const customEntityConfigCacheKey = isCustomViewConfig ? `${processedConfig.env.entryPointUriPath}-${packageInfo.packageJson.name}` : processedConfig.env.entryPointUriPath;
90
86
  return _objectSpread(_objectSpread({}, allConfigs), {}, {
91
87
  [customEntityConfigCacheKey]: processedConfig.env
92
88
  });
@@ -106,21 +102,20 @@ const customApplicationConfig = async options => {
106
102
  const allCustomEntityConfigs = await loadAllCustomEntityConfigs(options);
107
103
  const customApplicationConfig = allCustomEntityConfigs[options.entryPointUriPath];
108
104
  if (!customApplicationConfig) {
109
- throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
105
+ throw new Error(`Could not find Custom Application config for entry point "${options.entryPointUriPath}"`);
110
106
  }
111
- console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
107
+ console.log(`Using Custom Application config for "${options.entryPointUriPath}"`);
112
108
  return customApplicationConfig;
113
109
  };
114
110
  const customViewConfig = async options => {
115
- var _context3;
116
111
  const allCustomEntityConfigs = await loadAllCustomEntityConfigs(_objectSpread(_objectSpread({}, options), {}, {
117
112
  entryPointUriPath: constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH
118
113
  }));
119
- const customViewConfig = allCustomEntityConfigs[_concatInstanceProperty__default["default"](_context3 = "".concat(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, "-")).call(_context3, options.packageName)];
114
+ const customViewConfig = allCustomEntityConfigs[`${constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH}-${options.packageName}`];
120
115
  if (!customViewConfig) {
121
- throw new Error("Could not find Custom View config");
116
+ throw new Error(`Could not find Custom View config`);
122
117
  }
123
- console.log("Using Custom View config for \"".concat(options.packageName, "\""));
118
+ console.log(`Using Custom View config for "${options.packageName}"`);
124
119
  return customViewConfig;
125
120
  };
126
121
 
@@ -12,7 +12,6 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
14
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
16
15
  var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
17
16
  var fs = require('fs');
18
17
  var path = require('path');
@@ -31,13 +30,12 @@ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_O
31
30
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
32
31
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
33
32
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
34
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
35
33
  var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
36
34
  var fs__default = /*#__PURE__*/_interopDefault(fs);
37
35
  var path__default = /*#__PURE__*/_interopDefault(path);
38
36
 
39
37
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
40
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
38
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
41
39
  function doesFileExist(path) {
42
40
  try {
43
41
  fs__default["default"].accessSync(path);
@@ -49,8 +47,7 @@ function doesFileExist(path) {
49
47
  let cachedAllCustomEntityConfigs;
50
48
  const defaultDotfiles = ['.env', '.env.local'];
51
49
  const loadEnvironmentVariables = (packageDirPath, options) => {
52
- var _options$dotfiles;
53
- const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
50
+ const dotfiles = options.dotfiles ?? defaultDotfiles;
54
51
  return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
55
52
  const envPath = path__default["default"].join(packageDirPath, dotfile);
56
53
  if (!doesFileExist(envPath)) {
@@ -60,10 +57,10 @@ const loadEnvironmentVariables = (packageDirPath, options) => {
60
57
  path: envPath
61
58
  });
62
59
  if (env.error) {
63
- console.error("Failed to load environment variables from ".concat(envPath));
60
+ console.error(`Failed to load environment variables from ${envPath}`);
64
61
  return mergedEnvs;
65
62
  }
66
- console.log("Loading environment variables from ".concat(envPath));
63
+ console.log(`Loading environment variables from ${envPath}`);
67
64
  return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
68
65
  // Merge it with the environment variables defined in the current process.
69
66
  }, process.env);
@@ -78,15 +75,14 @@ const loadAllCustomEntityConfigs = async options => {
78
75
  const allConfigs = await allConfigsPromise;
79
76
  const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
80
77
  try {
81
- var _context, _context2;
82
78
  const processedConfig = await applicationConfig.processConfig({
83
79
  disableCache: true,
84
80
  processEnv,
85
81
  applicationPath: packageInfo.dir
86
82
  });
87
83
  const isCustomViewConfig = Boolean(processedConfig.env.customViewId);
88
- console.log(_concatInstanceProperty__default["default"](_context = "Found Custom ".concat(isCustomViewConfig ? 'View' : 'Application', " config for ")).call(_context, packageInfo.packageJson.name));
89
- const customEntityConfigCacheKey = isCustomViewConfig ? _concatInstanceProperty__default["default"](_context2 = "".concat(processedConfig.env.entryPointUriPath, "-")).call(_context2, packageInfo.packageJson.name) : processedConfig.env.entryPointUriPath;
84
+ console.log(`Found Custom ${isCustomViewConfig ? 'View' : 'Application'} config for ${packageInfo.packageJson.name}`);
85
+ const customEntityConfigCacheKey = isCustomViewConfig ? `${processedConfig.env.entryPointUriPath}-${packageInfo.packageJson.name}` : processedConfig.env.entryPointUriPath;
90
86
  return _objectSpread(_objectSpread({}, allConfigs), {}, {
91
87
  [customEntityConfigCacheKey]: processedConfig.env
92
88
  });
@@ -106,21 +102,20 @@ const customApplicationConfig = async options => {
106
102
  const allCustomEntityConfigs = await loadAllCustomEntityConfigs(options);
107
103
  const customApplicationConfig = allCustomEntityConfigs[options.entryPointUriPath];
108
104
  if (!customApplicationConfig) {
109
- throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
105
+ throw new Error(`Could not find Custom Application config for entry point "${options.entryPointUriPath}"`);
110
106
  }
111
- console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
107
+ console.log(`Using Custom Application config for "${options.entryPointUriPath}"`);
112
108
  return customApplicationConfig;
113
109
  };
114
110
  const customViewConfig = async options => {
115
- var _context3;
116
111
  const allCustomEntityConfigs = await loadAllCustomEntityConfigs(_objectSpread(_objectSpread({}, options), {}, {
117
112
  entryPointUriPath: constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH
118
113
  }));
119
- const customViewConfig = allCustomEntityConfigs[_concatInstanceProperty__default["default"](_context3 = "".concat(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, "-")).call(_context3, options.packageName)];
114
+ const customViewConfig = allCustomEntityConfigs[`${constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH}-${options.packageName}`];
120
115
  if (!customViewConfig) {
121
- throw new Error("Could not find Custom View config");
116
+ throw new Error(`Could not find Custom View config`);
122
117
  }
123
- console.log("Using Custom View config for \"".concat(options.packageName, "\""));
118
+ console.log(`Using Custom View config for "${options.packageName}"`);
124
119
  return customViewConfig;
125
120
  };
126
121
 
@@ -8,7 +8,6 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
8
8
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
10
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
11
- import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
12
11
  import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
13
12
  import fs from 'fs';
14
13
  import path from 'path';
@@ -17,7 +16,7 @@ import { processConfig, MissingOrInvalidConfigError } from '@commercetools-front
17
16
  import { CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH } from '@commercetools-frontend/constants';
18
17
 
19
18
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
21
20
  function doesFileExist(path) {
22
21
  try {
23
22
  fs.accessSync(path);
@@ -29,8 +28,7 @@ function doesFileExist(path) {
29
28
  let cachedAllCustomEntityConfigs;
30
29
  const defaultDotfiles = ['.env', '.env.local'];
31
30
  const loadEnvironmentVariables = (packageDirPath, options) => {
32
- var _options$dotfiles;
33
- const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
31
+ const dotfiles = options.dotfiles ?? defaultDotfiles;
34
32
  return _reduceInstanceProperty(dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
35
33
  const envPath = path.join(packageDirPath, dotfile);
36
34
  if (!doesFileExist(envPath)) {
@@ -40,10 +38,10 @@ const loadEnvironmentVariables = (packageDirPath, options) => {
40
38
  path: envPath
41
39
  });
42
40
  if (env.error) {
43
- console.error("Failed to load environment variables from ".concat(envPath));
41
+ console.error(`Failed to load environment variables from ${envPath}`);
44
42
  return mergedEnvs;
45
43
  }
46
- console.log("Loading environment variables from ".concat(envPath));
44
+ console.log(`Loading environment variables from ${envPath}`);
47
45
  return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
48
46
  // Merge it with the environment variables defined in the current process.
49
47
  }, process.env);
@@ -58,15 +56,14 @@ const loadAllCustomEntityConfigs = async options => {
58
56
  const allConfigs = await allConfigsPromise;
59
57
  const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
60
58
  try {
61
- var _context, _context2;
62
59
  const processedConfig = await processConfig({
63
60
  disableCache: true,
64
61
  processEnv,
65
62
  applicationPath: packageInfo.dir
66
63
  });
67
64
  const isCustomViewConfig = Boolean(processedConfig.env.customViewId);
68
- console.log(_concatInstanceProperty(_context = "Found Custom ".concat(isCustomViewConfig ? 'View' : 'Application', " config for ")).call(_context, packageInfo.packageJson.name));
69
- const customEntityConfigCacheKey = isCustomViewConfig ? _concatInstanceProperty(_context2 = "".concat(processedConfig.env.entryPointUriPath, "-")).call(_context2, packageInfo.packageJson.name) : processedConfig.env.entryPointUriPath;
65
+ console.log(`Found Custom ${isCustomViewConfig ? 'View' : 'Application'} config for ${packageInfo.packageJson.name}`);
66
+ const customEntityConfigCacheKey = isCustomViewConfig ? `${processedConfig.env.entryPointUriPath}-${packageInfo.packageJson.name}` : processedConfig.env.entryPointUriPath;
70
67
  return _objectSpread(_objectSpread({}, allConfigs), {}, {
71
68
  [customEntityConfigCacheKey]: processedConfig.env
72
69
  });
@@ -86,21 +83,20 @@ const customApplicationConfig = async options => {
86
83
  const allCustomEntityConfigs = await loadAllCustomEntityConfigs(options);
87
84
  const customApplicationConfig = allCustomEntityConfigs[options.entryPointUriPath];
88
85
  if (!customApplicationConfig) {
89
- throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
86
+ throw new Error(`Could not find Custom Application config for entry point "${options.entryPointUriPath}"`);
90
87
  }
91
- console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
88
+ console.log(`Using Custom Application config for "${options.entryPointUriPath}"`);
92
89
  return customApplicationConfig;
93
90
  };
94
91
  const customViewConfig = async options => {
95
- var _context3;
96
92
  const allCustomEntityConfigs = await loadAllCustomEntityConfigs(_objectSpread(_objectSpread({}, options), {}, {
97
93
  entryPointUriPath: CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH
98
94
  }));
99
- const customViewConfig = allCustomEntityConfigs[_concatInstanceProperty(_context3 = "".concat(CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, "-")).call(_context3, options.packageName)];
95
+ const customViewConfig = allCustomEntityConfigs[`${CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH}-${options.packageName}`];
100
96
  if (!customViewConfig) {
101
- throw new Error("Could not find Custom View config");
97
+ throw new Error(`Could not find Custom View config`);
102
98
  }
103
- console.log("Using Custom View config for \"".concat(options.packageName, "\""));
99
+ console.log(`Using Custom View config for "${options.packageName}"`);
104
100
  return customViewConfig;
105
101
  };
106
102