@commercetools-frontend/cypress 21.15.0 → 21.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,9 +11,11 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
11
11
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
12
12
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
13
13
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
14
+ var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
14
15
  var uuid = require('uuid');
15
- var constants = require('../../dist/constants-42a0ebf5.cjs.dev.js');
16
+ var semver = require('semver');
16
17
  var ssr = require('@commercetools-frontend/application-shell/ssr');
18
+ var constants = require('../../dist/constants-42a0ebf5.cjs.dev.js');
17
19
 
18
20
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
21
 
@@ -27,19 +29,103 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
27
29
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
28
30
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
29
31
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
32
+ var _URL__default = /*#__PURE__*/_interopDefault(_URL);
33
+ var semver__default = /*#__PURE__*/_interopDefault(semver);
30
34
 
31
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; }
32
36
 
33
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
37
+ 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; }
34
38
 
35
- Cypress.Commands.add('loginByOidc', function (commandOptions) {
39
+ function isFeatureSupported(expectedVersion) {
40
+ return semver__default["default"].gte(Cypress.version, expectedVersion);
41
+ }
42
+
43
+ function loginByForm(commandOptions) {
36
44
  var _commandOptions$proje;
37
45
 
38
- Cypress.log({
39
- name: 'loginByOidc'
40
- });
46
+ if (isLocalhost()) {
47
+ 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
+ }
49
+
41
50
  var projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
51
+ cy.task('customApplicationConfig', {
52
+ entryPointUriPath: commandOptions.entryPointUriPath,
53
+ dotfiles: commandOptions.dotfiles
54
+ }, // Do not show log, as it may contain sensible information.
55
+ {
56
+ log: false
57
+ }).then(function (appConfig) {
58
+ var _context, _commandOptions$login;
59
+
60
+ var url = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
61
+
62
+ if (commandOptions.entryPointUriPath === 'account') {
63
+ url = "/".concat(commandOptions.entryPointUriPath);
64
+ } // Log loaded application config for debugging purposes.
65
+
66
+
67
+ Cypress.log({
68
+ displayName: 'task',
69
+ name: 'customApplicationConfig',
70
+ message: appConfig
71
+ });
72
+ var userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
73
+ email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
74
+ password: Cypress.env('LOGIN_PASSWORD')
75
+ };
76
+ var sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath]; // const mcUrl = new URL(appConfig.mcApiUrl);
77
+ // const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
78
+
79
+ function authCallback() {
80
+ cy.visit(url); // NOTE: using `cy.origin` is currently disabled as it does not seem to properly work.
81
+ // Interestingly, starting an application locally using Vite works, however not when using Webpack.
82
+ // For now we keep it disabled until we find a solution.
83
+ // // https://cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/
84
+ // cy.origin(
85
+ // mcFrontendHostname,
86
+ // { args: userCredentials },
87
+ // fillLoginForm
88
+ // );
89
+
90
+ fillLoginForm(userCredentials); // Wait for the route to be loaded so that the session can be saved.
91
+
92
+ cy.url().should('include', url);
93
+ } // For backwards compatibility.
94
+
95
+
96
+ if (Cypress.config('experimentalSessionAndOrigin')) {
97
+ // https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
98
+ cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
99
+ cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
100
+ } : undefined);
101
+ } else {
102
+ cy.log("We recommend turning on the flag \"experimentalSessionAndOrigin\" to be able to use \"cy.session\" and thus reduce the time to log in between tests.");
103
+ authCallback();
104
+ }
105
+
106
+ if (commandOptions.initialRoute) {
107
+ var _context2;
108
+
109
+ cy.visit(_concatInstanceProperty__default["default"](_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
110
+ cy.url().should('include', commandOptions.initialRoute);
111
+ }
112
+ });
113
+ }
114
+
115
+ function loginByOidc(commandOptions) {
116
+ if (!isLocalhost()) {
117
+ throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
118
+ }
119
+
42
120
  var sessionNonce = uuid.v4();
121
+ var projectKey = undefined;
122
+
123
+ if (commandOptions.entryPointUriPath !== 'account') {
124
+ var _commandOptions$proje2;
125
+
126
+ projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
127
+ }
128
+
43
129
  cy.task('customApplicationConfig', {
44
130
  entryPointUriPath: commandOptions.entryPointUriPath,
45
131
  dotfiles: commandOptions.dotfiles
@@ -47,7 +133,7 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
47
133
  {
48
134
  log: false
49
135
  }).then(function (appConfig) {
50
- var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _commandOptions$login, _Cypress$env;
136
+ var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _commandOptions$login2;
51
137
 
52
138
  // Log loaded application config for debugging purposes.
53
139
  Cypress.log({
@@ -61,8 +147,8 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
61
147
  oAuthScopes: (_appConfig$__DEVELOPM = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM === void 0 ? void 0 : (_appConfig$__DEVELOPM2 = _appConfig$__DEVELOPM.oidc) === null || _appConfig$__DEVELOPM2 === void 0 ? void 0 : _appConfig$__DEVELOPM2.oAuthScopes,
62
148
  teamId: (_appConfig$__DEVELOPM3 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM3 === void 0 ? void 0 : (_appConfig$__DEVELOPM4 = _appConfig$__DEVELOPM3.oidc) === null || _appConfig$__DEVELOPM4 === void 0 ? void 0 : _appConfig$__DEVELOPM4.teamId
63
149
  });
64
- var userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
65
- email: (_Cypress$env = Cypress.env('LOGIN_EMAIL')) !== null && _Cypress$env !== void 0 ? _Cypress$env : Cypress.env('LOGIN_USER'),
150
+ var userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
151
+ email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
66
152
  password: Cypress.env('LOGIN_PASSWORD')
67
153
  }; // Perform the login using the API, then store some required values into the browser storage
68
154
  // and redirect to the auth callback route.
@@ -80,29 +166,83 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
80
166
  followRedirect: false
81
167
  };
82
168
  cy.request(requestOptions).then(function (res) {
83
- cy.visit(res.body.redirectTo, {
84
- onBeforeLoad: function onBeforeLoad(win) {
85
- var _context;
86
-
87
- win.localStorage.setItem(constants.STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
88
- win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context, sessionNonce), _JSON$stringify__default["default"]({
89
- applicationId: applicationId,
90
- query: {}
91
- }));
92
- win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
93
-
94
- if (commandOptions.onBeforeLoad) {
95
- commandOptions.onBeforeLoad(win);
169
+ var sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
170
+
171
+ function authCallback() {
172
+ cy.visit(res.body.redirectTo, {
173
+ onBeforeLoad: function onBeforeLoad(win) {
174
+ var _context3;
175
+
176
+ if (projectKey) {
177
+ win.localStorage.setItem(constants.STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
178
+ }
179
+
180
+ win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context3 = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify__default["default"]({
181
+ applicationId: applicationId,
182
+ query: {}
183
+ }));
184
+ win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
185
+
186
+ if (commandOptions.onBeforeLoad) {
187
+ commandOptions.onBeforeLoad(win);
188
+ }
96
189
  }
97
- }
98
- });
190
+ }); // Wait for the application to be loaded so that the session can be saved.
191
+
192
+ cy.get('#app-loader').should('not.exist');
193
+ } // For backwards compatibility.
194
+
195
+
196
+ if (Cypress.config('experimentalSessionAndOrigin')) {
197
+ // https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
198
+ cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
199
+ cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
200
+ } : undefined);
201
+ } else {
202
+ cy.log("We recommend turning on the flag \"experimentalSessionAndOrigin\" to be able to use \"cy.session\" and thus reduce the time to log in between tests.");
203
+ authCallback();
204
+ }
99
205
 
100
206
  if (commandOptions.initialRoute) {
101
- var _context2;
207
+ var _context4;
102
208
 
103
- cy.visit(_concatInstanceProperty__default["default"](_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
209
+ cy.visit(_concatInstanceProperty__default["default"](_context4 = "".concat(Cypress.config('baseUrl'))).call(_context4, commandOptions.initialRoute));
104
210
  cy.url().should('include', commandOptions.initialRoute);
105
211
  }
106
212
  });
107
213
  });
214
+ }
215
+ /* Utilities */
216
+
217
+
218
+ function fillLoginForm(userCredentials) {
219
+ cy.get('input[name=email]').type(userCredentials.email);
220
+ cy.get('input[name=password]').type(userCredentials.password, {
221
+ log: false
222
+ });
223
+ cy.get('button').contains('Sign in').click();
224
+ }
225
+
226
+ function isLocalhost() {
227
+ var baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
228
+ return baseUrl.hostname === 'localhost';
229
+ }
230
+
231
+ Cypress.Commands.add('loginToMerchantCenter', function (commandOptions) {
232
+ Cypress.log({
233
+ name: 'loginToMerchantCenter'
234
+ });
235
+
236
+ if (isLocalhost()) {
237
+ loginByOidc(commandOptions);
238
+ } else {
239
+ loginByForm(commandOptions);
240
+ }
241
+ });
242
+ Cypress.Commands.add('loginByOidc', function (commandOptions) {
243
+ Cypress.log({
244
+ name: 'loginByOidc'
245
+ });
246
+ cy.log('We recommend not to use the command "cy.loginByOidc" directly. Instead, use the more generic "cy.loginToMerchantCenter" command as it automatically detects which login mechanism to use.');
247
+ loginByOidc(commandOptions);
108
248
  });
@@ -11,9 +11,11 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
11
11
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
12
12
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
13
13
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
14
+ var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
14
15
  var uuid = require('uuid');
15
- var constants = require('../../dist/constants-4d9d4b7b.cjs.prod.js');
16
+ var semver = require('semver');
16
17
  var ssr = require('@commercetools-frontend/application-shell/ssr');
18
+ var constants = require('../../dist/constants-4d9d4b7b.cjs.prod.js');
17
19
 
18
20
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
21
 
@@ -27,19 +29,103 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
27
29
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
28
30
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
29
31
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
32
+ var _URL__default = /*#__PURE__*/_interopDefault(_URL);
33
+ var semver__default = /*#__PURE__*/_interopDefault(semver);
30
34
 
31
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; }
32
36
 
33
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
37
+ 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; }
34
38
 
35
- Cypress.Commands.add('loginByOidc', function (commandOptions) {
39
+ function isFeatureSupported(expectedVersion) {
40
+ return semver__default["default"].gte(Cypress.version, expectedVersion);
41
+ }
42
+
43
+ function loginByForm(commandOptions) {
36
44
  var _commandOptions$proje;
37
45
 
38
- Cypress.log({
39
- name: 'loginByOidc'
40
- });
46
+ if (isLocalhost()) {
47
+ 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
+ }
49
+
41
50
  var projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
51
+ cy.task('customApplicationConfig', {
52
+ entryPointUriPath: commandOptions.entryPointUriPath,
53
+ dotfiles: commandOptions.dotfiles
54
+ }, // Do not show log, as it may contain sensible information.
55
+ {
56
+ log: false
57
+ }).then(function (appConfig) {
58
+ var _context, _commandOptions$login;
59
+
60
+ var url = _concatInstanceProperty__default["default"](_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
61
+
62
+ if (commandOptions.entryPointUriPath === 'account') {
63
+ url = "/".concat(commandOptions.entryPointUriPath);
64
+ } // Log loaded application config for debugging purposes.
65
+
66
+
67
+ Cypress.log({
68
+ displayName: 'task',
69
+ name: 'customApplicationConfig',
70
+ message: appConfig
71
+ });
72
+ var userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
73
+ email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
74
+ password: Cypress.env('LOGIN_PASSWORD')
75
+ };
76
+ var sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath]; // const mcUrl = new URL(appConfig.mcApiUrl);
77
+ // const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
78
+
79
+ function authCallback() {
80
+ cy.visit(url); // NOTE: using `cy.origin` is currently disabled as it does not seem to properly work.
81
+ // Interestingly, starting an application locally using Vite works, however not when using Webpack.
82
+ // For now we keep it disabled until we find a solution.
83
+ // // https://cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/
84
+ // cy.origin(
85
+ // mcFrontendHostname,
86
+ // { args: userCredentials },
87
+ // fillLoginForm
88
+ // );
89
+
90
+ fillLoginForm(userCredentials); // Wait for the route to be loaded so that the session can be saved.
91
+
92
+ cy.url().should('include', url);
93
+ } // For backwards compatibility.
94
+
95
+
96
+ if (Cypress.config('experimentalSessionAndOrigin')) {
97
+ // https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
98
+ cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
99
+ cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
100
+ } : undefined);
101
+ } else {
102
+ cy.log("We recommend turning on the flag \"experimentalSessionAndOrigin\" to be able to use \"cy.session\" and thus reduce the time to log in between tests.");
103
+ authCallback();
104
+ }
105
+
106
+ if (commandOptions.initialRoute) {
107
+ var _context2;
108
+
109
+ cy.visit(_concatInstanceProperty__default["default"](_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
110
+ cy.url().should('include', commandOptions.initialRoute);
111
+ }
112
+ });
113
+ }
114
+
115
+ function loginByOidc(commandOptions) {
116
+ if (!isLocalhost()) {
117
+ throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
118
+ }
119
+
42
120
  var sessionNonce = uuid.v4();
121
+ var projectKey = undefined;
122
+
123
+ if (commandOptions.entryPointUriPath !== 'account') {
124
+ var _commandOptions$proje2;
125
+
126
+ projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
127
+ }
128
+
43
129
  cy.task('customApplicationConfig', {
44
130
  entryPointUriPath: commandOptions.entryPointUriPath,
45
131
  dotfiles: commandOptions.dotfiles
@@ -47,7 +133,7 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
47
133
  {
48
134
  log: false
49
135
  }).then(function (appConfig) {
50
- var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _commandOptions$login, _Cypress$env;
136
+ var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _commandOptions$login2;
51
137
 
52
138
  // Log loaded application config for debugging purposes.
53
139
  Cypress.log({
@@ -61,8 +147,8 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
61
147
  oAuthScopes: (_appConfig$__DEVELOPM = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM === void 0 ? void 0 : (_appConfig$__DEVELOPM2 = _appConfig$__DEVELOPM.oidc) === null || _appConfig$__DEVELOPM2 === void 0 ? void 0 : _appConfig$__DEVELOPM2.oAuthScopes,
62
148
  teamId: (_appConfig$__DEVELOPM3 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM3 === void 0 ? void 0 : (_appConfig$__DEVELOPM4 = _appConfig$__DEVELOPM3.oidc) === null || _appConfig$__DEVELOPM4 === void 0 ? void 0 : _appConfig$__DEVELOPM4.teamId
63
149
  });
64
- var userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
65
- email: (_Cypress$env = Cypress.env('LOGIN_EMAIL')) !== null && _Cypress$env !== void 0 ? _Cypress$env : Cypress.env('LOGIN_USER'),
150
+ var userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
151
+ email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
66
152
  password: Cypress.env('LOGIN_PASSWORD')
67
153
  }; // Perform the login using the API, then store some required values into the browser storage
68
154
  // and redirect to the auth callback route.
@@ -80,29 +166,83 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
80
166
  followRedirect: false
81
167
  };
82
168
  cy.request(requestOptions).then(function (res) {
83
- cy.visit(res.body.redirectTo, {
84
- onBeforeLoad: function onBeforeLoad(win) {
85
- var _context;
86
-
87
- win.localStorage.setItem(constants.STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
88
- win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context, sessionNonce), _JSON$stringify__default["default"]({
89
- applicationId: applicationId,
90
- query: {}
91
- }));
92
- win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
93
-
94
- if (commandOptions.onBeforeLoad) {
95
- commandOptions.onBeforeLoad(win);
169
+ var sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
170
+
171
+ function authCallback() {
172
+ cy.visit(res.body.redirectTo, {
173
+ onBeforeLoad: function onBeforeLoad(win) {
174
+ var _context3;
175
+
176
+ if (projectKey) {
177
+ win.localStorage.setItem(constants.STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
178
+ }
179
+
180
+ win.sessionStorage.setItem(_concatInstanceProperty__default["default"](_context3 = "".concat(constants.STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify__default["default"]({
181
+ applicationId: applicationId,
182
+ query: {}
183
+ }));
184
+ win.sessionStorage.setItem(constants.STORAGE_KEYS.SESSION_SCOPE, sessionScope);
185
+
186
+ if (commandOptions.onBeforeLoad) {
187
+ commandOptions.onBeforeLoad(win);
188
+ }
96
189
  }
97
- }
98
- });
190
+ }); // Wait for the application to be loaded so that the session can be saved.
191
+
192
+ cy.get('#app-loader').should('not.exist');
193
+ } // For backwards compatibility.
194
+
195
+
196
+ if (Cypress.config('experimentalSessionAndOrigin')) {
197
+ // https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
198
+ cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
199
+ cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
200
+ } : undefined);
201
+ } else {
202
+ cy.log("We recommend turning on the flag \"experimentalSessionAndOrigin\" to be able to use \"cy.session\" and thus reduce the time to log in between tests.");
203
+ authCallback();
204
+ }
99
205
 
100
206
  if (commandOptions.initialRoute) {
101
- var _context2;
207
+ var _context4;
102
208
 
103
- cy.visit(_concatInstanceProperty__default["default"](_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
209
+ cy.visit(_concatInstanceProperty__default["default"](_context4 = "".concat(Cypress.config('baseUrl'))).call(_context4, commandOptions.initialRoute));
104
210
  cy.url().should('include', commandOptions.initialRoute);
105
211
  }
106
212
  });
107
213
  });
214
+ }
215
+ /* Utilities */
216
+
217
+
218
+ function fillLoginForm(userCredentials) {
219
+ cy.get('input[name=email]').type(userCredentials.email);
220
+ cy.get('input[name=password]').type(userCredentials.password, {
221
+ log: false
222
+ });
223
+ cy.get('button').contains('Sign in').click();
224
+ }
225
+
226
+ function isLocalhost() {
227
+ var baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
228
+ return baseUrl.hostname === 'localhost';
229
+ }
230
+
231
+ Cypress.Commands.add('loginToMerchantCenter', function (commandOptions) {
232
+ Cypress.log({
233
+ name: 'loginToMerchantCenter'
234
+ });
235
+
236
+ if (isLocalhost()) {
237
+ loginByOidc(commandOptions);
238
+ } else {
239
+ loginByForm(commandOptions);
240
+ }
241
+ });
242
+ Cypress.Commands.add('loginByOidc', function (commandOptions) {
243
+ Cypress.log({
244
+ name: 'loginByOidc'
245
+ });
246
+ cy.log('We recommend not to use the command "cy.loginByOidc" directly. Instead, use the more generic "cy.loginToMerchantCenter" command as it automatically detects which login mechanism to use.');
247
+ loginByOidc(commandOptions);
108
248
  });
@@ -9,22 +9,106 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
10
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
11
11
  import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
12
+ import _URL from '@babel/runtime-corejs3/core-js-stable/url';
12
13
  import { v4 } from 'uuid';
13
- import { S as STORAGE_KEYS, O as OIDC_RESPONSE_TYPES } from '../../dist/constants-0e882d21.esm.js';
14
+ import semver from 'semver';
14
15
  import { buildOidcScope } from '@commercetools-frontend/application-shell/ssr';
16
+ import { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from '../../dist/constants-0e882d21.esm.js';
15
17
 
16
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; }
17
19
 
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
20
+ 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; }
19
21
 
20
- Cypress.Commands.add('loginByOidc', function (commandOptions) {
22
+ function isFeatureSupported(expectedVersion) {
23
+ return semver.gte(Cypress.version, expectedVersion);
24
+ }
25
+
26
+ function loginByForm(commandOptions) {
21
27
  var _commandOptions$proje;
22
28
 
23
- Cypress.log({
24
- name: 'loginByOidc'
25
- });
29
+ if (isLocalhost()) {
30
+ 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
+ }
32
+
26
33
  var projectKey = (_commandOptions$proje = commandOptions.projectKey) !== null && _commandOptions$proje !== void 0 ? _commandOptions$proje : Cypress.env('PROJECT_KEY');
34
+ cy.task('customApplicationConfig', {
35
+ entryPointUriPath: commandOptions.entryPointUriPath,
36
+ dotfiles: commandOptions.dotfiles
37
+ }, // Do not show log, as it may contain sensible information.
38
+ {
39
+ log: false
40
+ }).then(function (appConfig) {
41
+ var _context, _commandOptions$login;
42
+
43
+ var url = _concatInstanceProperty(_context = "/".concat(projectKey, "/")).call(_context, commandOptions.entryPointUriPath);
44
+
45
+ if (commandOptions.entryPointUriPath === 'account') {
46
+ url = "/".concat(commandOptions.entryPointUriPath);
47
+ } // Log loaded application config for debugging purposes.
48
+
49
+
50
+ Cypress.log({
51
+ displayName: 'task',
52
+ name: 'customApplicationConfig',
53
+ message: appConfig
54
+ });
55
+ var userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
56
+ email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
57
+ password: Cypress.env('LOGIN_PASSWORD')
58
+ };
59
+ var sessionKey = ['loginByForm', userCredentials.email, commandOptions.entryPointUriPath]; // const mcUrl = new URL(appConfig.mcApiUrl);
60
+ // const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');
61
+
62
+ function authCallback() {
63
+ cy.visit(url); // NOTE: using `cy.origin` is currently disabled as it does not seem to properly work.
64
+ // Interestingly, starting an application locally using Vite works, however not when using Webpack.
65
+ // For now we keep it disabled until we find a solution.
66
+ // // https://cypress.io/blog/2022/04/25/cypress-9-6-0-easily-test-multi-domain-workflows-with-cy-origin/
67
+ // cy.origin(
68
+ // mcFrontendHostname,
69
+ // { args: userCredentials },
70
+ // fillLoginForm
71
+ // );
72
+
73
+ fillLoginForm(userCredentials); // Wait for the route to be loaded so that the session can be saved.
74
+
75
+ cy.url().should('include', url);
76
+ } // For backwards compatibility.
77
+
78
+
79
+ if (Cypress.config('experimentalSessionAndOrigin')) {
80
+ // https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
81
+ cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
82
+ cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
83
+ } : undefined);
84
+ } else {
85
+ cy.log("We recommend turning on the flag \"experimentalSessionAndOrigin\" to be able to use \"cy.session\" and thus reduce the time to log in between tests.");
86
+ authCallback();
87
+ }
88
+
89
+ if (commandOptions.initialRoute) {
90
+ var _context2;
91
+
92
+ cy.visit(_concatInstanceProperty(_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
93
+ cy.url().should('include', commandOptions.initialRoute);
94
+ }
95
+ });
96
+ }
97
+
98
+ function loginByOidc(commandOptions) {
99
+ if (!isLocalhost()) {
100
+ throw new Error("The \"loginByOidc\" command only works when testing a Custom Application running on localhost.");
101
+ }
102
+
27
103
  var sessionNonce = v4();
104
+ var projectKey = undefined;
105
+
106
+ if (commandOptions.entryPointUriPath !== 'account') {
107
+ var _commandOptions$proje2;
108
+
109
+ projectKey = (_commandOptions$proje2 = commandOptions.projectKey) !== null && _commandOptions$proje2 !== void 0 ? _commandOptions$proje2 : Cypress.env('PROJECT_KEY');
110
+ }
111
+
28
112
  cy.task('customApplicationConfig', {
29
113
  entryPointUriPath: commandOptions.entryPointUriPath,
30
114
  dotfiles: commandOptions.dotfiles
@@ -32,7 +116,7 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
32
116
  {
33
117
  log: false
34
118
  }).then(function (appConfig) {
35
- var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _commandOptions$login, _Cypress$env;
119
+ var _appConfig$__DEVELOPM, _appConfig$__DEVELOPM2, _appConfig$__DEVELOPM3, _appConfig$__DEVELOPM4, _commandOptions$login2;
36
120
 
37
121
  // Log loaded application config for debugging purposes.
38
122
  Cypress.log({
@@ -46,8 +130,8 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
46
130
  oAuthScopes: (_appConfig$__DEVELOPM = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM === void 0 ? void 0 : (_appConfig$__DEVELOPM2 = _appConfig$__DEVELOPM.oidc) === null || _appConfig$__DEVELOPM2 === void 0 ? void 0 : _appConfig$__DEVELOPM2.oAuthScopes,
47
131
  teamId: (_appConfig$__DEVELOPM3 = appConfig.__DEVELOPMENT__) === null || _appConfig$__DEVELOPM3 === void 0 ? void 0 : (_appConfig$__DEVELOPM4 = _appConfig$__DEVELOPM3.oidc) === null || _appConfig$__DEVELOPM4 === void 0 ? void 0 : _appConfig$__DEVELOPM4.teamId
48
132
  });
49
- var userCredentials = (_commandOptions$login = commandOptions.login) !== null && _commandOptions$login !== void 0 ? _commandOptions$login : {
50
- email: (_Cypress$env = Cypress.env('LOGIN_EMAIL')) !== null && _Cypress$env !== void 0 ? _Cypress$env : Cypress.env('LOGIN_USER'),
133
+ var userCredentials = (_commandOptions$login2 = commandOptions.login) !== null && _commandOptions$login2 !== void 0 ? _commandOptions$login2 : {
134
+ email: Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER'),
51
135
  password: Cypress.env('LOGIN_PASSWORD')
52
136
  }; // Perform the login using the API, then store some required values into the browser storage
53
137
  // and redirect to the auth callback route.
@@ -65,29 +149,83 @@ Cypress.Commands.add('loginByOidc', function (commandOptions) {
65
149
  followRedirect: false
66
150
  };
67
151
  cy.request(requestOptions).then(function (res) {
68
- cy.visit(res.body.redirectTo, {
69
- onBeforeLoad: function onBeforeLoad(win) {
70
- var _context;
71
-
72
- win.localStorage.setItem(STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
73
- win.sessionStorage.setItem(_concatInstanceProperty(_context = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context, sessionNonce), _JSON$stringify({
74
- applicationId: applicationId,
75
- query: {}
76
- }));
77
- win.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, sessionScope);
78
-
79
- if (commandOptions.onBeforeLoad) {
80
- commandOptions.onBeforeLoad(win);
152
+ var sessionKey = ['loginByOidc', userCredentials.email, commandOptions.entryPointUriPath];
153
+
154
+ function authCallback() {
155
+ cy.visit(res.body.redirectTo, {
156
+ onBeforeLoad: function onBeforeLoad(win) {
157
+ var _context3;
158
+
159
+ if (projectKey) {
160
+ win.localStorage.setItem(STORAGE_KEYS.ACTIVE_PROJECT_KEY, projectKey);
161
+ }
162
+
163
+ win.sessionStorage.setItem(_concatInstanceProperty(_context3 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context3, sessionNonce), _JSON$stringify({
164
+ applicationId: applicationId,
165
+ query: {}
166
+ }));
167
+ win.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, sessionScope);
168
+
169
+ if (commandOptions.onBeforeLoad) {
170
+ commandOptions.onBeforeLoad(win);
171
+ }
81
172
  }
82
- }
83
- });
173
+ }); // Wait for the application to be loaded so that the session can be saved.
174
+
175
+ cy.get('#app-loader').should('not.exist');
176
+ } // For backwards compatibility.
177
+
178
+
179
+ if (Cypress.config('experimentalSessionAndOrigin')) {
180
+ // https://www.cypress.io/blog/2021/08/04/authenticate-faster-in-tests-cy-session-command/
181
+ cy.session(sessionKey, authCallback, isFeatureSupported('10.9.0') ? {
182
+ cacheAcrossSpecs: typeof commandOptions.disableCacheAcrossSpecs === 'boolean' ? !commandOptions.disableCacheAcrossSpecs : true
183
+ } : undefined);
184
+ } else {
185
+ cy.log("We recommend turning on the flag \"experimentalSessionAndOrigin\" to be able to use \"cy.session\" and thus reduce the time to log in between tests.");
186
+ authCallback();
187
+ }
84
188
 
85
189
  if (commandOptions.initialRoute) {
86
- var _context2;
190
+ var _context4;
87
191
 
88
- cy.visit(_concatInstanceProperty(_context2 = "".concat(Cypress.config('baseUrl'))).call(_context2, commandOptions.initialRoute));
192
+ cy.visit(_concatInstanceProperty(_context4 = "".concat(Cypress.config('baseUrl'))).call(_context4, commandOptions.initialRoute));
89
193
  cy.url().should('include', commandOptions.initialRoute);
90
194
  }
91
195
  });
92
196
  });
197
+ }
198
+ /* Utilities */
199
+
200
+
201
+ function fillLoginForm(userCredentials) {
202
+ cy.get('input[name=email]').type(userCredentials.email);
203
+ cy.get('input[name=password]').type(userCredentials.password, {
204
+ log: false
205
+ });
206
+ cy.get('button').contains('Sign in').click();
207
+ }
208
+
209
+ function isLocalhost() {
210
+ var baseUrl = new _URL(Cypress.config('baseUrl'));
211
+ return baseUrl.hostname === 'localhost';
212
+ }
213
+
214
+ Cypress.Commands.add('loginToMerchantCenter', function (commandOptions) {
215
+ Cypress.log({
216
+ name: 'loginToMerchantCenter'
217
+ });
218
+
219
+ if (isLocalhost()) {
220
+ loginByOidc(commandOptions);
221
+ } else {
222
+ loginByForm(commandOptions);
223
+ }
224
+ });
225
+ Cypress.Commands.add('loginByOidc', function (commandOptions) {
226
+ Cypress.log({
227
+ name: 'loginByOidc'
228
+ });
229
+ cy.log('We recommend not to use the command "cy.loginByOidc" directly. Instead, use the more generic "cy.loginToMerchantCenter" command as it automatically detects which login mechanism to use.');
230
+ loginByOidc(commandOptions);
93
231
  });
@@ -1,13 +1,29 @@
1
1
  declare namespace Cypress {
2
2
  interface Chainable<Subject> {
3
+ /**
4
+ * Log into the Custom Application.
5
+ * The command detects whether the application is running on localhost or on production
6
+ * and chooses the appropriate login mechanism.
7
+ *
8
+ * @example
9
+ * cy.loginToMerchantCenter({ entryPointUriPath: 'template-starter' })
10
+ */
11
+ loginToMerchantCenter(
12
+ // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types
13
+ options?: import('./dist/commercetools-frontend-cypress-add-commands.cjs').CommandLoginOptions
14
+ ): Chainable<Subject>;
3
15
  /**
4
16
  * Log into the Custom Application using the OIDC workflow.
17
+ * The command only works for testing an application running on localhost.
18
+ *
5
19
  * @example
6
20
  * cy.loginByOidc({ entryPointUriPath: 'template-starter' })
21
+ *
22
+ * @deprecated Use the more generic {@link cy.loginToMerchantCenter} command as it automatically detects which login mechanism to use.
7
23
  */
8
24
  loginByOidc(
9
25
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types
10
- options?: import('./dist/commercetools-frontend-cypress-add-commands.cjs').CommandLoginByOidcOptions
26
+ options?: import('./dist/commercetools-frontend-cypress-add-commands.cjs').CommandLoginOptions
11
27
  ): Chainable<Subject>;
12
28
  }
13
29
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var constants = require('./constants-42a0ebf5.cjs.dev.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "21.15.0";
8
+ var version = "21.17.0";
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-4d9d4b7b.cjs.prod.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "21.15.0";
8
+ var version = "21.17.0";
9
9
 
10
10
  exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
11
11
  exports.STORAGE_KEYS = constants.STORAGE_KEYS;
@@ -1,6 +1,6 @@
1
1
  export { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from './constants-0e882d21.esm.js';
2
2
 
3
3
  // NOTE: This string will be replaced on build time with the package version.
4
- var version = "21.15.0";
4
+ var version = "21.17.0";
5
5
 
6
6
  export { version };
@@ -1,43 +1,2 @@
1
- export declare type CommandLoginByOidcOptions = {
2
- /**
3
- * The application entry point URI path. This value is used to identify
4
- * the correct application config.
5
- */
6
- entryPointUriPath: string;
7
- /**
8
- * Pass a list of dotfiles that must be loaded when the custom-application-config.json
9
- * is loaded (in case you are using environment placeholder).
10
- * By default the following dotfiles are loaded: `.env` and `.env.local`.
11
- * You can also define the values using paths relative to the application folder.
12
- */
13
- dotfiles?: string[];
14
- /**
15
- * Called before your page has loaded all of its resources.
16
- * Use this as a chance to interact for example with the browser storage.
17
- */
18
- onBeforeLoad?: (win: Window) => void;
19
- /**
20
- * If defined, visit this route after login.
21
- */
22
- initialRoute?: string;
23
- /**
24
- * The project key to access in the user session. The session token is valid for one project key at a time.
25
- * Defaults to `Cypress.env('PROJECT_KEY')`.
26
- */
27
- projectKey?: string;
28
- /**
29
- * The user login credentials.
30
- */
31
- login?: {
32
- /**
33
- * The user email.
34
- * Defaults to `Cypress.env('LOGIN_EMAIL') ?? Cypress.env('LOGIN_USER')`.
35
- */
36
- email: string;
37
- /**
38
- * The user password.
39
- * Defaults to `Cypress.env('LOGIN_PASSWORD')`.
40
- */
41
- password: string;
42
- };
43
- };
1
+ import { type CommandLoginOptions as TCommandLoginOptions } from './login';
2
+ export declare type CommandLoginOptions = TCommandLoginOptions;
@@ -0,0 +1,54 @@
1
+ export declare type LoginCredentials = {
2
+ /**
3
+ * The user email.
4
+ * Defaults to `Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER')`.
5
+ */
6
+ email: string;
7
+ /**
8
+ * The user password.
9
+ * Defaults to `Cypress.env('LOGIN_PASSWORD')`.
10
+ */
11
+ password: string;
12
+ };
13
+ export declare type CommandLoginOptions = {
14
+ /**
15
+ * The application entry point URI path. This value is used to identify
16
+ * the correct application config.
17
+ */
18
+ entryPointUriPath: string;
19
+ /**
20
+ * Pass a list of dotfiles that must be loaded when the custom-application-config.json
21
+ * is loaded (in case you are using environment placeholder).
22
+ * By default the following dotfiles are loaded: `.env` and `.env.local`.
23
+ * You can also define the values using paths relative to the application folder.
24
+ */
25
+ dotfiles?: string[];
26
+ /**
27
+ * Called before your page has loaded all of its resources.
28
+ * Use this as a chance to interact for example with the browser storage.
29
+ */
30
+ onBeforeLoad?: (win: Window) => void;
31
+ /**
32
+ * If defined, visit this route after login.
33
+ */
34
+ initialRoute?: string;
35
+ /**
36
+ * The project key to access in the user session. The session token is valid for one project key at a time.
37
+ * Defaults to `Cypress.env('PROJECT_KEY')`.
38
+ */
39
+ projectKey?: string;
40
+ /**
41
+ * The user login credentials.
42
+ */
43
+ login?: LoginCredentials;
44
+ /**
45
+ * Turn off caching the session across specs.
46
+ * This is only relevant for Cypress version >= `10.9.0`.
47
+ */
48
+ disableCacheAcrossSpecs?: boolean;
49
+ };
50
+ export declare type CommandLoginByOidcOptions = CommandLoginOptions;
51
+ declare function loginByForm(commandOptions: CommandLoginOptions): void;
52
+ declare function loginByOidc(commandOptions: CommandLoginOptions): void;
53
+ declare function isLocalhost(): boolean;
54
+ export { loginByForm, loginByOidc, isLocalhost };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress",
3
- "version": "21.15.0",
3
+ "version": "21.17.0",
4
4
  "description": "Cypress commands and utilities for Custom Applications",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -37,13 +37,14 @@
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.19.0",
39
39
  "@babel/runtime-corejs3": "^7.19.0",
40
- "@commercetools-frontend/application-config": "21.15.0",
41
- "@commercetools-frontend/application-shell": "21.15.0",
40
+ "@commercetools-frontend/application-config": "21.17.0",
41
+ "@commercetools-frontend/application-shell": "21.17.0",
42
42
  "@manypkg/get-packages": "1.1.3",
43
+ "semver": "7.3.7",
43
44
  "uuid": "8.3.2"
44
45
  },
45
46
  "devDependencies": {
46
- "cypress": "10.8.0"
47
+ "cypress": "10.9.0"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "cypress": "8.x || 9.x || 10.x"