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