@commercetools-frontend/cypress 22.2.1 → 22.3.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 +39 -46
- package/add-commands/dist/commercetools-frontend-cypress-add-commands.cjs.prod.js +39 -46
- package/add-commands/dist/commercetools-frontend-cypress-add-commands.esm.js +39 -46
- 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 +11 -6
- package/task/dist/commercetools-frontend-cypress-task.cjs.dev.js +3 -17
- package/task/dist/commercetools-frontend-cypress-task.cjs.prod.js +3 -17
- package/task/dist/commercetools-frontend-cypress-task.esm.js +3 -17
|
@@ -33,37 +33,38 @@ var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
|
33
33
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
34
34
|
|
|
35
35
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
36
|
-
|
|
37
36
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
38
37
|
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
|
|
42
|
+
// Alias for backwards compatibility
|
|
43
|
+
|
|
39
44
|
function isFeatureSupported(expectedVersion) {
|
|
40
45
|
return semver__default["default"].gte(Cypress.version, expectedVersion);
|
|
41
46
|
}
|
|
42
|
-
|
|
43
47
|
function loginByForm(commandOptions) {
|
|
44
48
|
var _commandOptions$proje;
|
|
45
|
-
|
|
46
49
|
if (isLocalhost()) {
|
|
47
50
|
throw new Error("At the moment, the \"loginByForm\" command only works when testing a Merchant Center production URL. Using form login in an application running on localhost is not supported due to issues with \"cy.origin\".");
|
|
48
51
|
}
|
|
49
|
-
|
|
50
52
|
const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
|
|
51
53
|
cy.task('customApplicationConfig', {
|
|
52
54
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
53
55
|
dotfiles: commandOptions.dotfiles
|
|
54
|
-
},
|
|
56
|
+
},
|
|
57
|
+
// Do not show log, as it may contain sensible information.
|
|
55
58
|
{
|
|
56
59
|
log: false
|
|
57
60
|
}).then(appConfig => {
|
|
58
61
|
var _context, _commandOptions$login;
|
|
59
|
-
|
|
60
62
|
let url = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
|
|
61
|
-
|
|
62
63
|
if (commandOptions.entryPointUriPath === 'account') {
|
|
63
64
|
url = "/".concat(commandOptions.entryPointUriPath);
|
|
64
|
-
}
|
|
65
|
-
|
|
65
|
+
}
|
|
66
66
|
|
|
67
|
+
// Log loaded application config for debugging purposes.
|
|
67
68
|
Cypress.log({
|
|
68
69
|
displayName: 'task',
|
|
69
70
|
name: 'customApplicationConfig',
|
|
@@ -73,68 +74,65 @@ function loginByForm(commandOptions) {
|
|
|
73
74
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
74
75
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
75
76
|
};
|
|
76
|
-
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath];
|
|
77
|
+
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath];
|
|
78
|
+
// const mcUrl = new URL(appConfig.mcApiUrl);
|
|
77
79
|
// const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
|
|
78
80
|
|
|
79
81
|
function authCallback() {
|
|
80
|
-
cy.visit(url);
|
|
82
|
+
cy.visit(url);
|
|
83
|
+
|
|
84
|
+
// NOTE: using `cy.origin` is currently disabled as it does not seem to properly work.
|
|
81
85
|
// Interestingly, starting an application locally using Vite works, however not when using Webpack.
|
|
82
86
|
// For now we keep it disabled until we find a solution.
|
|
87
|
+
|
|
83
88
|
// // https://cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/
|
|
84
89
|
// cy.origin(
|
|
85
90
|
// mcFrontendHostname,
|
|
86
91
|
// { args: userCredentials },
|
|
87
92
|
// fillLoginForm
|
|
88
93
|
// );
|
|
94
|
+
fillLoginForm(userCredentials);
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
// Wait for the route to be loaded so that the session can be saved.
|
|
92
97
|
cy.url().should('include', url);
|
|
93
|
-
}
|
|
94
|
-
|
|
98
|
+
}
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
// For backwards compatibility.
|
|
101
|
+
if (isFeatureSupported('12.0.0') || Cypress.config('experimentalSessionAndOrigin')) {
|
|
97
102
|
// https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
|
|
98
103
|
cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
|
|
99
104
|
cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
|
|
100
105
|
} : undefined);
|
|
101
106
|
} else {
|
|
102
|
-
cy.log("We recommend
|
|
107
|
+
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.");
|
|
103
108
|
authCallback();
|
|
104
109
|
}
|
|
105
|
-
|
|
106
110
|
if (commandOptions.initialRoute) {
|
|
107
111
|
var _context2;
|
|
108
|
-
|
|
109
112
|
cy.visit(_concatInstanceProperty__default["default"](_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
|
|
110
113
|
cy.url().should('include', commandOptions.initialRoute);
|
|
111
114
|
}
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
|
-
|
|
115
117
|
function loginByOidc(commandOptions) {
|
|
116
118
|
if (!isLocalhost()) {
|
|
117
119
|
throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
|
|
118
120
|
}
|
|
119
|
-
|
|
120
121
|
const sessionNonce = uuid.v4();
|
|
121
122
|
let projectKey = undefined;
|
|
122
|
-
|
|
123
123
|
if (commandOptions.entryPointUriPath !== 'account') {
|
|
124
124
|
var _commandOptions$proje2;
|
|
125
|
-
|
|
126
125
|
projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
|
|
127
126
|
}
|
|
128
|
-
|
|
129
127
|
cy.task('customApplicationConfig', {
|
|
130
128
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
131
129
|
dotfiles: commandOptions.dotfiles
|
|
132
|
-
},
|
|
130
|
+
},
|
|
131
|
+
// Do not show log, as it may contain sensible information.
|
|
133
132
|
{
|
|
134
133
|
log: false
|
|
135
134
|
}).then(appConfig => {
|
|
136
135
|
var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _appConfig$__DEVELOPM5, _appConfig$__DEVELOPM6, _commandOptions$login2;
|
|
137
|
-
|
|
138
136
|
// Log loaded application config for debugging purposes.
|
|
139
137
|
Cypress.log({
|
|
140
138
|
displayName: 'task',
|
|
@@ -151,9 +149,9 @@ function loginByOidc(commandOptions) {
|
|
|
151
149
|
const userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
|
|
152
150
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
153
151
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
154
|
-
};
|
|
152
|
+
};
|
|
153
|
+
// Perform the login using the API, then store some required values into the browser storage
|
|
155
154
|
// and redirect to the auth callback route.
|
|
156
|
-
|
|
157
155
|
const requestOptions = {
|
|
158
156
|
method: 'POST',
|
|
159
157
|
url: "".concat(appConfig.mcApiUrl, "/tokens"),
|
|
@@ -168,56 +166,49 @@ function loginByOidc(commandOptions) {
|
|
|
168
166
|
};
|
|
169
167
|
cy.request(requestOptions).then(res => {
|
|
170
168
|
const sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
|
|
171
|
-
|
|
172
169
|
function authCallback() {
|
|
173
170
|
cy.visit(res.body.redirectTo, {
|
|
174
171
|
onBeforeLoad(win) {
|
|
175
172
|
var _context3;
|
|
176
|
-
|
|
177
173
|
if (projectKey) {
|
|
178
174
|
win.localStorage.setItem(constants.STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
|
|
179
175
|
}
|
|
180
|
-
|
|
181
176
|
win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context3 = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify__default["default"]({
|
|
182
177
|
applicationId,
|
|
183
178
|
query: {}
|
|
184
179
|
}));
|
|
185
|
-
win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
186
|
-
|
|
180
|
+
win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
181
|
+
// Disable redesign announcement
|
|
187
182
|
win.localStorage.setItem('isNewDesignReleaseNotificationClosed', 'true');
|
|
188
|
-
|
|
189
183
|
if (commandOptions.onBeforeLoad) {
|
|
190
184
|
commandOptions.onBeforeLoad(win);
|
|
191
185
|
}
|
|
192
186
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
187
|
+
});
|
|
188
|
+
// Wait for the application to be loaded so that the session can be saved.
|
|
196
189
|
cy.get('#app-loader').should('not.exist');
|
|
197
|
-
}
|
|
198
|
-
|
|
190
|
+
}
|
|
199
191
|
|
|
200
|
-
|
|
192
|
+
// For backwards compatibility.
|
|
193
|
+
if (isFeatureSupported('12.0.0') || Cypress.config('experimentalSessionAndOrigin')) {
|
|
201
194
|
// https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
|
|
202
195
|
cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
|
|
203
196
|
cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
|
|
204
197
|
} : undefined);
|
|
205
198
|
} else {
|
|
206
|
-
cy.log("We recommend
|
|
199
|
+
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.");
|
|
207
200
|
authCallback();
|
|
208
201
|
}
|
|
209
|
-
|
|
210
202
|
if (commandOptions.initialRoute) {
|
|
211
203
|
var _context4;
|
|
212
|
-
|
|
213
204
|
cy.visit(_concatInstanceProperty__default["default"](_context4 = "".concat(Cypress.config('baseUrl'))).call(_context4, commandOptions.initialRoute));
|
|
214
205
|
cy.url().should('include', commandOptions.initialRoute);
|
|
215
206
|
}
|
|
216
207
|
});
|
|
217
208
|
});
|
|
218
209
|
}
|
|
219
|
-
/* Utilities */
|
|
220
210
|
|
|
211
|
+
/* Utilities */
|
|
221
212
|
|
|
222
213
|
function fillLoginForm(userCredentials) {
|
|
223
214
|
cy.get('input[name=email]').type(userCredentials.email);
|
|
@@ -226,17 +217,19 @@ function fillLoginForm(userCredentials) {
|
|
|
226
217
|
});
|
|
227
218
|
cy.get('button').contains('Sign in').click();
|
|
228
219
|
}
|
|
229
|
-
|
|
230
220
|
function isLocalhost() {
|
|
231
221
|
const baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
|
|
232
222
|
return baseUrl.hostname === 'localhost';
|
|
233
223
|
}
|
|
234
224
|
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
226
|
+
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
+
|
|
235
229
|
Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
|
|
236
230
|
Cypress.log({
|
|
237
231
|
name: 'loginToMerchantCenter'
|
|
238
232
|
});
|
|
239
|
-
|
|
240
233
|
if (isLocalhost()) {
|
|
241
234
|
loginByOidc(commandOptions);
|
|
242
235
|
} else {
|
|
@@ -33,37 +33,38 @@ var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
|
33
33
|
var semver__default = /*#__PURE__*/_interopDefault(semver);
|
|
34
34
|
|
|
35
35
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
36
|
-
|
|
37
36
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
38
37
|
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
|
|
42
|
+
// Alias for backwards compatibility
|
|
43
|
+
|
|
39
44
|
function isFeatureSupported(expectedVersion) {
|
|
40
45
|
return semver__default["default"].gte(Cypress.version, expectedVersion);
|
|
41
46
|
}
|
|
42
|
-
|
|
43
47
|
function loginByForm(commandOptions) {
|
|
44
48
|
var _commandOptions$proje;
|
|
45
|
-
|
|
46
49
|
if (isLocalhost()) {
|
|
47
50
|
throw new Error("At the moment, the \"loginByForm\" command only works when testing a Merchant Center production URL. Using form login in an application running on localhost is not supported due to issues with \"cy.origin\".");
|
|
48
51
|
}
|
|
49
|
-
|
|
50
52
|
const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
|
|
51
53
|
cy.task('customApplicationConfig', {
|
|
52
54
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
53
55
|
dotfiles: commandOptions.dotfiles
|
|
54
|
-
},
|
|
56
|
+
},
|
|
57
|
+
// Do not show log, as it may contain sensible information.
|
|
55
58
|
{
|
|
56
59
|
log: false
|
|
57
60
|
}).then(appConfig => {
|
|
58
61
|
var _context, _commandOptions$login;
|
|
59
|
-
|
|
60
62
|
let url = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
|
|
61
|
-
|
|
62
63
|
if (commandOptions.entryPointUriPath === 'account') {
|
|
63
64
|
url = "/".concat(commandOptions.entryPointUriPath);
|
|
64
|
-
}
|
|
65
|
-
|
|
65
|
+
}
|
|
66
66
|
|
|
67
|
+
// Log loaded application config for debugging purposes.
|
|
67
68
|
Cypress.log({
|
|
68
69
|
displayName: 'task',
|
|
69
70
|
name: 'customApplicationConfig',
|
|
@@ -73,68 +74,65 @@ function loginByForm(commandOptions) {
|
|
|
73
74
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
74
75
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
75
76
|
};
|
|
76
|
-
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath];
|
|
77
|
+
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath];
|
|
78
|
+
// const mcUrl = new URL(appConfig.mcApiUrl);
|
|
77
79
|
// const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
|
|
78
80
|
|
|
79
81
|
function authCallback() {
|
|
80
|
-
cy.visit(url);
|
|
82
|
+
cy.visit(url);
|
|
83
|
+
|
|
84
|
+
// NOTE: using `cy.origin` is currently disabled as it does not seem to properly work.
|
|
81
85
|
// Interestingly, starting an application locally using Vite works, however not when using Webpack.
|
|
82
86
|
// For now we keep it disabled until we find a solution.
|
|
87
|
+
|
|
83
88
|
// // https://cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/
|
|
84
89
|
// cy.origin(
|
|
85
90
|
// mcFrontendHostname,
|
|
86
91
|
// { args: userCredentials },
|
|
87
92
|
// fillLoginForm
|
|
88
93
|
// );
|
|
94
|
+
fillLoginForm(userCredentials);
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
// Wait for the route to be loaded so that the session can be saved.
|
|
92
97
|
cy.url().should('include', url);
|
|
93
|
-
}
|
|
94
|
-
|
|
98
|
+
}
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
// For backwards compatibility.
|
|
101
|
+
if (isFeatureSupported('12.0.0') || Cypress.config('experimentalSessionAndOrigin')) {
|
|
97
102
|
// https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
|
|
98
103
|
cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
|
|
99
104
|
cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
|
|
100
105
|
} : undefined);
|
|
101
106
|
} else {
|
|
102
|
-
cy.log("We recommend
|
|
107
|
+
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.");
|
|
103
108
|
authCallback();
|
|
104
109
|
}
|
|
105
|
-
|
|
106
110
|
if (commandOptions.initialRoute) {
|
|
107
111
|
var _context2;
|
|
108
|
-
|
|
109
112
|
cy.visit(_concatInstanceProperty__default["default"](_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
|
|
110
113
|
cy.url().should('include', commandOptions.initialRoute);
|
|
111
114
|
}
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
|
-
|
|
115
117
|
function loginByOidc(commandOptions) {
|
|
116
118
|
if (!isLocalhost()) {
|
|
117
119
|
throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
|
|
118
120
|
}
|
|
119
|
-
|
|
120
121
|
const sessionNonce = uuid.v4();
|
|
121
122
|
let projectKey = undefined;
|
|
122
|
-
|
|
123
123
|
if (commandOptions.entryPointUriPath !== 'account') {
|
|
124
124
|
var _commandOptions$proje2;
|
|
125
|
-
|
|
126
125
|
projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
|
|
127
126
|
}
|
|
128
|
-
|
|
129
127
|
cy.task('customApplicationConfig', {
|
|
130
128
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
131
129
|
dotfiles: commandOptions.dotfiles
|
|
132
|
-
},
|
|
130
|
+
},
|
|
131
|
+
// Do not show log, as it may contain sensible information.
|
|
133
132
|
{
|
|
134
133
|
log: false
|
|
135
134
|
}).then(appConfig => {
|
|
136
135
|
var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _appConfig$__DEVELOPM5, _appConfig$__DEVELOPM6, _commandOptions$login2;
|
|
137
|
-
|
|
138
136
|
// Log loaded application config for debugging purposes.
|
|
139
137
|
Cypress.log({
|
|
140
138
|
displayName: 'task',
|
|
@@ -151,9 +149,9 @@ function loginByOidc(commandOptions) {
|
|
|
151
149
|
const userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
|
|
152
150
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
153
151
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
154
|
-
};
|
|
152
|
+
};
|
|
153
|
+
// Perform the login using the API, then store some required values into the browser storage
|
|
155
154
|
// and redirect to the auth callback route.
|
|
156
|
-
|
|
157
155
|
const requestOptions = {
|
|
158
156
|
method: 'POST',
|
|
159
157
|
url: "".concat(appConfig.mcApiUrl, "/tokens"),
|
|
@@ -168,56 +166,49 @@ function loginByOidc(commandOptions) {
|
|
|
168
166
|
};
|
|
169
167
|
cy.request(requestOptions).then(res => {
|
|
170
168
|
const sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
|
|
171
|
-
|
|
172
169
|
function authCallback() {
|
|
173
170
|
cy.visit(res.body.redirectTo, {
|
|
174
171
|
onBeforeLoad(win) {
|
|
175
172
|
var _context3;
|
|
176
|
-
|
|
177
173
|
if (projectKey) {
|
|
178
174
|
win.localStorage.setItem(constants.STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
|
|
179
175
|
}
|
|
180
|
-
|
|
181
176
|
win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context3 = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify__default["default"]({
|
|
182
177
|
applicationId,
|
|
183
178
|
query: {}
|
|
184
179
|
}));
|
|
185
|
-
win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
186
|
-
|
|
180
|
+
win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
181
|
+
// Disable redesign announcement
|
|
187
182
|
win.localStorage.setItem('isNewDesignReleaseNotificationClosed', 'true');
|
|
188
|
-
|
|
189
183
|
if (commandOptions.onBeforeLoad) {
|
|
190
184
|
commandOptions.onBeforeLoad(win);
|
|
191
185
|
}
|
|
192
186
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
187
|
+
});
|
|
188
|
+
// Wait for the application to be loaded so that the session can be saved.
|
|
196
189
|
cy.get('#app-loader').should('not.exist');
|
|
197
|
-
}
|
|
198
|
-
|
|
190
|
+
}
|
|
199
191
|
|
|
200
|
-
|
|
192
|
+
// For backwards compatibility.
|
|
193
|
+
if (isFeatureSupported('12.0.0') || Cypress.config('experimentalSessionAndOrigin')) {
|
|
201
194
|
// https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
|
|
202
195
|
cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
|
|
203
196
|
cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
|
|
204
197
|
} : undefined);
|
|
205
198
|
} else {
|
|
206
|
-
cy.log("We recommend
|
|
199
|
+
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.");
|
|
207
200
|
authCallback();
|
|
208
201
|
}
|
|
209
|
-
|
|
210
202
|
if (commandOptions.initialRoute) {
|
|
211
203
|
var _context4;
|
|
212
|
-
|
|
213
204
|
cy.visit(_concatInstanceProperty__default["default"](_context4 = "".concat(Cypress.config('baseUrl'))).call(_context4, commandOptions.initialRoute));
|
|
214
205
|
cy.url().should('include', commandOptions.initialRoute);
|
|
215
206
|
}
|
|
216
207
|
});
|
|
217
208
|
});
|
|
218
209
|
}
|
|
219
|
-
/* Utilities */
|
|
220
210
|
|
|
211
|
+
/* Utilities */
|
|
221
212
|
|
|
222
213
|
function fillLoginForm(userCredentials) {
|
|
223
214
|
cy.get('input[name=email]').type(userCredentials.email);
|
|
@@ -226,17 +217,19 @@ function fillLoginForm(userCredentials) {
|
|
|
226
217
|
});
|
|
227
218
|
cy.get('button').contains('Sign in').click();
|
|
228
219
|
}
|
|
229
|
-
|
|
230
220
|
function isLocalhost() {
|
|
231
221
|
const baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
|
|
232
222
|
return baseUrl.hostname === 'localhost';
|
|
233
223
|
}
|
|
234
224
|
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
226
|
+
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
+
|
|
235
229
|
Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
|
|
236
230
|
Cypress.log({
|
|
237
231
|
name: 'loginToMerchantCenter'
|
|
238
232
|
});
|
|
239
|
-
|
|
240
233
|
if (isLocalhost()) {
|
|
241
234
|
loginByOidc(commandOptions);
|
|
242
235
|
} else {
|
|
@@ -16,37 +16,38 @@ import { buildOidcScope } from '@commercetools-frontend/application-shell/ssr';
|
|
|
16
16
|
import { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from '../../dist/constants-18b165fc.esm.js';
|
|
17
17
|
|
|
18
18
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
19
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
20
|
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
|
|
25
|
+
// Alias for backwards compatibility
|
|
26
|
+
|
|
22
27
|
function isFeatureSupported(expectedVersion) {
|
|
23
28
|
return semver.gte(Cypress.version, expectedVersion);
|
|
24
29
|
}
|
|
25
|
-
|
|
26
30
|
function loginByForm(commandOptions) {
|
|
27
31
|
var _commandOptions$proje;
|
|
28
|
-
|
|
29
32
|
if (isLocalhost()) {
|
|
30
33
|
throw new Error("At the moment, the \"loginByForm\" command only works when testing a Merchant Center production URL. Using form login in an application running on localhost is not supported due to issues with \"cy.origin\".");
|
|
31
34
|
}
|
|
32
|
-
|
|
33
35
|
const projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
|
|
34
36
|
cy.task('customApplicationConfig', {
|
|
35
37
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
36
38
|
dotfiles: commandOptions.dotfiles
|
|
37
|
-
},
|
|
39
|
+
},
|
|
40
|
+
// Do not show log, as it may contain sensible information.
|
|
38
41
|
{
|
|
39
42
|
log: false
|
|
40
43
|
}).then(appConfig => {
|
|
41
44
|
var _context, _commandOptions$login;
|
|
42
|
-
|
|
43
45
|
let url = _concatInstanceProperty(_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
|
|
44
|
-
|
|
45
46
|
if (commandOptions.entryPointUriPath === 'account') {
|
|
46
47
|
url = "/".concat(commandOptions.entryPointUriPath);
|
|
47
|
-
}
|
|
48
|
-
|
|
48
|
+
}
|
|
49
49
|
|
|
50
|
+
// Log loaded application config for debugging purposes.
|
|
50
51
|
Cypress.log({
|
|
51
52
|
displayName: 'task',
|
|
52
53
|
name: 'customApplicationConfig',
|
|
@@ -56,68 +57,65 @@ function loginByForm(commandOptions) {
|
|
|
56
57
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
57
58
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
58
59
|
};
|
|
59
|
-
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath];
|
|
60
|
+
const sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath];
|
|
61
|
+
// const mcUrl = new URL(appConfig.mcApiUrl);
|
|
60
62
|
// const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
|
|
61
63
|
|
|
62
64
|
function authCallback() {
|
|
63
|
-
cy.visit(url);
|
|
65
|
+
cy.visit(url);
|
|
66
|
+
|
|
67
|
+
// NOTE: using `cy.origin` is currently disabled as it does not seem to properly work.
|
|
64
68
|
// Interestingly, starting an application locally using Vite works, however not when using Webpack.
|
|
65
69
|
// For now we keep it disabled until we find a solution.
|
|
70
|
+
|
|
66
71
|
// // https://cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/
|
|
67
72
|
// cy.origin(
|
|
68
73
|
// mcFrontendHostname,
|
|
69
74
|
// { args: userCredentials },
|
|
70
75
|
// fillLoginForm
|
|
71
76
|
// );
|
|
77
|
+
fillLoginForm(userCredentials);
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
// Wait for the route to be loaded so that the session can be saved.
|
|
75
80
|
cy.url().should('include', url);
|
|
76
|
-
}
|
|
77
|
-
|
|
81
|
+
}
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
// For backwards compatibility.
|
|
84
|
+
if (isFeatureSupported('12.0.0') || Cypress.config('experimentalSessionAndOrigin')) {
|
|
80
85
|
// https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
|
|
81
86
|
cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
|
|
82
87
|
cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
|
|
83
88
|
} : undefined);
|
|
84
89
|
} else {
|
|
85
|
-
cy.log("We recommend
|
|
90
|
+
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.");
|
|
86
91
|
authCallback();
|
|
87
92
|
}
|
|
88
|
-
|
|
89
93
|
if (commandOptions.initialRoute) {
|
|
90
94
|
var _context2;
|
|
91
|
-
|
|
92
95
|
cy.visit(_concatInstanceProperty(_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
|
|
93
96
|
cy.url().should('include', commandOptions.initialRoute);
|
|
94
97
|
}
|
|
95
98
|
});
|
|
96
99
|
}
|
|
97
|
-
|
|
98
100
|
function loginByOidc(commandOptions) {
|
|
99
101
|
if (!isLocalhost()) {
|
|
100
102
|
throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
|
|
101
103
|
}
|
|
102
|
-
|
|
103
104
|
const sessionNonce = v4();
|
|
104
105
|
let projectKey = undefined;
|
|
105
|
-
|
|
106
106
|
if (commandOptions.entryPointUriPath !== 'account') {
|
|
107
107
|
var _commandOptions$proje2;
|
|
108
|
-
|
|
109
108
|
projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
|
|
110
109
|
}
|
|
111
|
-
|
|
112
110
|
cy.task('customApplicationConfig', {
|
|
113
111
|
entryPointUriPath: commandOptions.entryPointUriPath,
|
|
114
112
|
dotfiles: commandOptions.dotfiles
|
|
115
|
-
},
|
|
113
|
+
},
|
|
114
|
+
// Do not show log, as it may contain sensible information.
|
|
116
115
|
{
|
|
117
116
|
log: false
|
|
118
117
|
}).then(appConfig => {
|
|
119
118
|
var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _appConfig$__DEVELOPM5, _appConfig$__DEVELOPM6, _commandOptions$login2;
|
|
120
|
-
|
|
121
119
|
// Log loaded application config for debugging purposes.
|
|
122
120
|
Cypress.log({
|
|
123
121
|
displayName: 'task',
|
|
@@ -134,9 +132,9 @@ function loginByOidc(commandOptions) {
|
|
|
134
132
|
const userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
|
|
135
133
|
email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
|
|
136
134
|
password: Cypress.env('LOGIN_PASSWORD')
|
|
137
|
-
};
|
|
135
|
+
};
|
|
136
|
+
// Perform the login using the API, then store some required values into the browser storage
|
|
138
137
|
// and redirect to the auth callback route.
|
|
139
|
-
|
|
140
138
|
const requestOptions = {
|
|
141
139
|
method: 'POST',
|
|
142
140
|
url: "".concat(appConfig.mcApiUrl, "/tokens"),
|
|
@@ -151,56 +149,49 @@ function loginByOidc(commandOptions) {
|
|
|
151
149
|
};
|
|
152
150
|
cy.request(requestOptions).then(res => {
|
|
153
151
|
const sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
|
|
154
|
-
|
|
155
152
|
function authCallback() {
|
|
156
153
|
cy.visit(res.body.redirectTo, {
|
|
157
154
|
onBeforeLoad(win) {
|
|
158
155
|
var _context3;
|
|
159
|
-
|
|
160
156
|
if (projectKey) {
|
|
161
157
|
win.localStorage.setItem(STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
|
|
162
158
|
}
|
|
163
|
-
|
|
164
159
|
win.sessionStorage.setItem(_concatInstanceProperty(_context3 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify({
|
|
165
160
|
applicationId,
|
|
166
161
|
query: {}
|
|
167
162
|
}));
|
|
168
|
-
win.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
169
|
-
|
|
163
|
+
win.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, sessionScope);
|
|
164
|
+
// Disable redesign announcement
|
|
170
165
|
win.localStorage.setItem('isNewDesignReleaseNotificationClosed', 'true');
|
|
171
|
-
|
|
172
166
|
if (commandOptions.onBeforeLoad) {
|
|
173
167
|
commandOptions.onBeforeLoad(win);
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
});
|
|
171
|
+
// Wait for the application to be loaded so that the session can be saved.
|
|
179
172
|
cy.get('#app-loader').should('not.exist');
|
|
180
|
-
}
|
|
181
|
-
|
|
173
|
+
}
|
|
182
174
|
|
|
183
|
-
|
|
175
|
+
// For backwards compatibility.
|
|
176
|
+
if (isFeatureSupported('12.0.0') || Cypress.config('experimentalSessionAndOrigin')) {
|
|
184
177
|
// https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
|
|
185
178
|
cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
|
|
186
179
|
cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
|
|
187
180
|
} : undefined);
|
|
188
181
|
} else {
|
|
189
|
-
cy.log("We recommend
|
|
182
|
+
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.");
|
|
190
183
|
authCallback();
|
|
191
184
|
}
|
|
192
|
-
|
|
193
185
|
if (commandOptions.initialRoute) {
|
|
194
186
|
var _context4;
|
|
195
|
-
|
|
196
187
|
cy.visit(_concatInstanceProperty(_context4 = "".concat(Cypress.config('baseUrl'))).call(_context4, commandOptions.initialRoute));
|
|
197
188
|
cy.url().should('include', commandOptions.initialRoute);
|
|
198
189
|
}
|
|
199
190
|
});
|
|
200
191
|
});
|
|
201
192
|
}
|
|
202
|
-
/* Utilities */
|
|
203
193
|
|
|
194
|
+
/* Utilities */
|
|
204
195
|
|
|
205
196
|
function fillLoginForm(userCredentials) {
|
|
206
197
|
cy.get('input[name=email]').type(userCredentials.email);
|
|
@@ -209,17 +200,19 @@ function fillLoginForm(userCredentials) {
|
|
|
209
200
|
});
|
|
210
201
|
cy.get('button').contains('Sign in').click();
|
|
211
202
|
}
|
|
212
|
-
|
|
213
203
|
function isLocalhost() {
|
|
214
204
|
const baseUrl = new _URL(Cypress.config('baseUrl'));
|
|
215
205
|
return baseUrl.hostname === 'localhost';
|
|
216
206
|
}
|
|
217
207
|
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
209
|
+
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
|
+
|
|
218
212
|
Cypress.Commands.add('loginToMerchantCenter', commandOptions => {
|
|
219
213
|
Cypress.log({
|
|
220
214
|
name: 'loginToMerchantCenter'
|
|
221
215
|
});
|
|
222
|
-
|
|
223
216
|
if (isLocalhost()) {
|
|
224
217
|
loginByOidc(commandOptions);
|
|
225
218
|
} else {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var constants = require('./constants-c657705e.cjs.dev.js');
|
|
6
6
|
|
|
7
7
|
// NOTE: This string will be replaced on build time with the package version.
|
|
8
|
-
var version = "22.
|
|
8
|
+
var version = "22.3.1";
|
|
9
9
|
|
|
10
10
|
exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
|
|
11
11
|
exports.STORAGE_KEYS = constants.STORAGE_KEYS;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var constants = require('./constants-8ad2a50e.cjs.prod.js');
|
|
6
6
|
|
|
7
7
|
// NOTE: This string will be replaced on build time with the package version.
|
|
8
|
-
var version = "22.
|
|
8
|
+
var version = "22.3.1";
|
|
9
9
|
|
|
10
10
|
exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
|
|
11
11
|
exports.STORAGE_KEYS = constants.STORAGE_KEYS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/cypress",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.3.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": {
|
|
@@ -24,7 +24,11 @@
|
|
|
24
24
|
"main": "dist/commercetools-frontend-cypress.cjs.js",
|
|
25
25
|
"module": "dist/commercetools-frontend-cypress.esm.js",
|
|
26
26
|
"preconstruct": {
|
|
27
|
-
"entrypoints": [
|
|
27
|
+
"entrypoints": [
|
|
28
|
+
"./index.ts",
|
|
29
|
+
"./add-commands/index.ts",
|
|
30
|
+
"./task/index.ts"
|
|
31
|
+
]
|
|
28
32
|
},
|
|
29
33
|
"files": [
|
|
30
34
|
"dist",
|
|
@@ -37,17 +41,18 @@
|
|
|
37
41
|
"dependencies": {
|
|
38
42
|
"@babel/runtime": "^7.20.13",
|
|
39
43
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
40
|
-
"@commercetools-frontend/application-config": "22.
|
|
41
|
-
"@commercetools-frontend/application-shell": "22.
|
|
44
|
+
"@commercetools-frontend/application-config": "22.3.1",
|
|
45
|
+
"@commercetools-frontend/application-shell": "22.3.1",
|
|
42
46
|
"@manypkg/get-packages": "1.1.3",
|
|
47
|
+
"@types/semver": "^7.5.0",
|
|
43
48
|
"semver": "7.5.0",
|
|
44
49
|
"uuid": "9.0.0"
|
|
45
50
|
},
|
|
46
51
|
"devDependencies": {
|
|
47
52
|
"@tsconfig/node16": "^1.0.3",
|
|
48
|
-
"cypress": "
|
|
53
|
+
"cypress": "12.12.0"
|
|
49
54
|
},
|
|
50
55
|
"peerDependencies": {
|
|
51
56
|
"cypress": ">=8"
|
|
52
57
|
}
|
|
53
|
-
}
|
|
58
|
+
}
|
|
@@ -32,47 +32,37 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
|
32
32
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
33
33
|
|
|
34
34
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
|
-
|
|
36
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
37
36
|
let cachedAllCustomApplicationConfigs;
|
|
38
37
|
const defaultDotfiles = ['.env', '.env.local'];
|
|
39
|
-
|
|
40
38
|
const loadEnvironmentVariables = (packageDirPath, options) => {
|
|
41
39
|
var _options$dotfiles;
|
|
42
|
-
|
|
43
40
|
const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
|
|
44
41
|
return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
|
|
45
42
|
const envPath = path__default["default"].join(packageDirPath, dotfile);
|
|
46
|
-
|
|
47
43
|
if (!fs__default["default"].existsSync(envPath)) {
|
|
48
44
|
return mergedEnvs;
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
const env = require('dotenv').config({
|
|
52
47
|
path: envPath
|
|
53
48
|
});
|
|
54
|
-
|
|
55
49
|
if (env.error) {
|
|
56
50
|
console.error("Failed to load environment variables from ".concat(envPath));
|
|
57
51
|
return mergedEnvs;
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
console.log("Loading environment variables from ".concat(envPath));
|
|
61
|
-
return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
|
|
54
|
+
return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
|
|
55
|
+
// Merge it with the environment variables defined in the current process.
|
|
62
56
|
}, process.env);
|
|
63
57
|
};
|
|
64
|
-
|
|
65
58
|
const loadAllCustomApplicationConfigs = async options => {
|
|
66
59
|
if (cachedAllCustomApplicationConfigs) {
|
|
67
60
|
return cachedAllCustomApplicationConfigs;
|
|
68
61
|
}
|
|
69
|
-
|
|
70
62
|
const _await$getPackages = await getPackages.getPackages(process.cwd()),
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
packages = _await$getPackages.packages;
|
|
73
64
|
cachedAllCustomApplicationConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
|
|
74
65
|
const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
|
|
75
|
-
|
|
76
66
|
try {
|
|
77
67
|
const processedConfig = applicationConfig.processConfig({
|
|
78
68
|
disableCache: true,
|
|
@@ -90,21 +80,17 @@ const loadAllCustomApplicationConfigs = async options => {
|
|
|
90
80
|
if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
|
|
91
81
|
return allConfigs;
|
|
92
82
|
}
|
|
93
|
-
|
|
94
83
|
throw error;
|
|
95
84
|
}
|
|
96
85
|
}, {});
|
|
97
86
|
return cachedAllCustomApplicationConfigs;
|
|
98
87
|
};
|
|
99
|
-
|
|
100
88
|
const customApplicationConfig = async options => {
|
|
101
89
|
const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
|
|
102
90
|
const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
103
|
-
|
|
104
91
|
if (!customApplicationConfig) {
|
|
105
92
|
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
106
93
|
}
|
|
107
|
-
|
|
108
94
|
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
109
95
|
return customApplicationConfig;
|
|
110
96
|
};
|
|
@@ -32,47 +32,37 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
|
32
32
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
33
33
|
|
|
34
34
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
|
-
|
|
36
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
37
36
|
let cachedAllCustomApplicationConfigs;
|
|
38
37
|
const defaultDotfiles = ['.env', '.env.local'];
|
|
39
|
-
|
|
40
38
|
const loadEnvironmentVariables = (packageDirPath, options) => {
|
|
41
39
|
var _options$dotfiles;
|
|
42
|
-
|
|
43
40
|
const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
|
|
44
41
|
return _reduceInstanceProperty__default["default"](dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
|
|
45
42
|
const envPath = path__default["default"].join(packageDirPath, dotfile);
|
|
46
|
-
|
|
47
43
|
if (!fs__default["default"].existsSync(envPath)) {
|
|
48
44
|
return mergedEnvs;
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
const env = require('dotenv').config({
|
|
52
47
|
path: envPath
|
|
53
48
|
});
|
|
54
|
-
|
|
55
49
|
if (env.error) {
|
|
56
50
|
console.error("Failed to load environment variables from ".concat(envPath));
|
|
57
51
|
return mergedEnvs;
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
console.log("Loading environment variables from ".concat(envPath));
|
|
61
|
-
return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
|
|
54
|
+
return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
|
|
55
|
+
// Merge it with the environment variables defined in the current process.
|
|
62
56
|
}, process.env);
|
|
63
57
|
};
|
|
64
|
-
|
|
65
58
|
const loadAllCustomApplicationConfigs = async options => {
|
|
66
59
|
if (cachedAllCustomApplicationConfigs) {
|
|
67
60
|
return cachedAllCustomApplicationConfigs;
|
|
68
61
|
}
|
|
69
|
-
|
|
70
62
|
const _await$getPackages = await getPackages.getPackages(process.cwd()),
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
packages = _await$getPackages.packages;
|
|
73
64
|
cachedAllCustomApplicationConfigs = _reduceInstanceProperty__default["default"](packages).call(packages, (allConfigs, packageInfo) => {
|
|
74
65
|
const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
|
|
75
|
-
|
|
76
66
|
try {
|
|
77
67
|
const processedConfig = applicationConfig.processConfig({
|
|
78
68
|
disableCache: true,
|
|
@@ -90,21 +80,17 @@ const loadAllCustomApplicationConfigs = async options => {
|
|
|
90
80
|
if (error instanceof applicationConfig.MissingOrInvalidConfigError) {
|
|
91
81
|
return allConfigs;
|
|
92
82
|
}
|
|
93
|
-
|
|
94
83
|
throw error;
|
|
95
84
|
}
|
|
96
85
|
}, {});
|
|
97
86
|
return cachedAllCustomApplicationConfigs;
|
|
98
87
|
};
|
|
99
|
-
|
|
100
88
|
const customApplicationConfig = async options => {
|
|
101
89
|
const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
|
|
102
90
|
const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
103
|
-
|
|
104
91
|
if (!customApplicationConfig) {
|
|
105
92
|
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
106
93
|
}
|
|
107
|
-
|
|
108
94
|
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
109
95
|
return customApplicationConfig;
|
|
110
96
|
};
|
|
@@ -14,47 +14,37 @@ import { getPackages } from '@manypkg/get-packages';
|
|
|
14
14
|
import { processConfig, MissingOrInvalidConfigError } from '@commercetools-frontend/application-config';
|
|
15
15
|
|
|
16
16
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
18
|
let cachedAllCustomApplicationConfigs;
|
|
20
19
|
const defaultDotfiles = ['.env', '.env.local'];
|
|
21
|
-
|
|
22
20
|
const loadEnvironmentVariables = (packageDirPath, options) => {
|
|
23
21
|
var _options$dotfiles;
|
|
24
|
-
|
|
25
22
|
const dotfiles = (_options$dotfiles = options.dotfiles) !== null && _options$dotfiles !== void 0 ? _options$dotfiles : defaultDotfiles;
|
|
26
23
|
return _reduceInstanceProperty(dotfiles).call(dotfiles, (mergedEnvs, dotfile) => {
|
|
27
24
|
const envPath = path.join(packageDirPath, dotfile);
|
|
28
|
-
|
|
29
25
|
if (!fs.existsSync(envPath)) {
|
|
30
26
|
return mergedEnvs;
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
const env = require('dotenv').config({
|
|
34
29
|
path: envPath
|
|
35
30
|
});
|
|
36
|
-
|
|
37
31
|
if (env.error) {
|
|
38
32
|
console.error("Failed to load environment variables from ".concat(envPath));
|
|
39
33
|
return mergedEnvs;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
console.log("Loading environment variables from ".concat(envPath));
|
|
43
|
-
return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
|
|
36
|
+
return _objectSpread(_objectSpread({}, mergedEnvs), env.parsed);
|
|
37
|
+
// Merge it with the environment variables defined in the current process.
|
|
44
38
|
}, process.env);
|
|
45
39
|
};
|
|
46
|
-
|
|
47
40
|
const loadAllCustomApplicationConfigs = async options => {
|
|
48
41
|
if (cachedAllCustomApplicationConfigs) {
|
|
49
42
|
return cachedAllCustomApplicationConfigs;
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
const _await$getPackages = await getPackages(process.cwd()),
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
packages = _await$getPackages.packages;
|
|
55
46
|
cachedAllCustomApplicationConfigs = _reduceInstanceProperty(packages).call(packages, (allConfigs, packageInfo) => {
|
|
56
47
|
const processEnv = loadEnvironmentVariables(packageInfo.dir, options);
|
|
57
|
-
|
|
58
48
|
try {
|
|
59
49
|
const processedConfig = processConfig({
|
|
60
50
|
disableCache: true,
|
|
@@ -72,21 +62,17 @@ const loadAllCustomApplicationConfigs = async options => {
|
|
|
72
62
|
if (error instanceof MissingOrInvalidConfigError) {
|
|
73
63
|
return allConfigs;
|
|
74
64
|
}
|
|
75
|
-
|
|
76
65
|
throw error;
|
|
77
66
|
}
|
|
78
67
|
}, {});
|
|
79
68
|
return cachedAllCustomApplicationConfigs;
|
|
80
69
|
};
|
|
81
|
-
|
|
82
70
|
const customApplicationConfig = async options => {
|
|
83
71
|
const allCustomApplicationConfigs = await loadAllCustomApplicationConfigs(options);
|
|
84
72
|
const customApplicationConfig = allCustomApplicationConfigs[options.entryPointUriPath];
|
|
85
|
-
|
|
86
73
|
if (!customApplicationConfig) {
|
|
87
74
|
throw new Error("Could not find Custom Application config for entry point \"".concat(options.entryPointUriPath, "\""));
|
|
88
75
|
}
|
|
89
|
-
|
|
90
76
|
console.log("Using Custom Application config for \"".concat(options.entryPointUriPath, "\""));
|
|
91
77
|
return customApplicationConfig;
|
|
92
78
|
};
|