@commercetools-frontend/cypress 24.4.0 → 24.5.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.
@@ -47,6 +47,10 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _
47
47
 
48
48
  // Alias for backwards compatibility
49
49
 
50
+ const defaultTimeouts = {
51
+ waitForEmailInput: 4000,
52
+ waitForPasswordInput: 8000
53
+ };
50
54
  function isFeatureSupported(expectedVersion) {
51
55
  return semver__default["default"].gte(Cypress.version, expectedVersion);
52
56
  }
@@ -177,18 +181,26 @@ function loginByForm(commandOptions) {
177
181
  cy.origin(identityUrl, {
178
182
  args: {
179
183
  userCredentials,
180
- identityUrl
184
+ identityUrl,
185
+ timeouts: commandOptions.timeouts,
186
+ defaultTimeouts
181
187
  }
182
188
  }, _ref => {
183
189
  let userCredentials = _ref.userCredentials,
184
- identityUrl = _ref.identityUrl;
190
+ identityUrl = _ref.identityUrl,
191
+ timeouts = _ref.timeouts,
192
+ defaultTimeouts = _ref.defaultTimeouts;
185
193
  cy.url().should('include', `${identityUrl}/login`);
186
194
  // Fill in the email and click Next
187
- cy.get('input[name="identifier"]').type(userCredentials.email);
195
+ cy.get('input[name="identifier"]', {
196
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
197
+ }).type(userCredentials.email);
188
198
  cy.get('button').contains('Next').click();
189
199
 
190
200
  // Wait for the password form to appear
191
- cy.get('input[name="password"]').should('be.visible');
201
+ cy.get('input[name="password"]', {
202
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
203
+ }).should('be.visible');
192
204
  // Fill in the password and submit
193
205
  cy.get('input[name="password"]').type(userCredentials.password, {
194
206
  log: false
@@ -207,16 +219,22 @@ function loginByForm(commandOptions) {
207
219
  cy.origin(mcUrl, {
208
220
  args: {
209
221
  userCredentials,
210
- mcUrl
222
+ mcUrl,
223
+ timeouts: commandOptions.timeouts,
224
+ defaultTimeouts
211
225
  }
212
226
  }, _ref2 => {
213
227
  let userCredentials = _ref2.userCredentials,
214
- mcUrl = _ref2.mcUrl;
228
+ mcUrl = _ref2.mcUrl,
229
+ timeouts = _ref2.timeouts,
230
+ defaultTimeouts = _ref2.defaultTimeouts;
215
231
  cy.url().should('include', `${mcUrl}/login`);
216
232
 
217
233
  // Same as `fillLegacyLoginFormWithRetry`.
218
234
  // eslint-disable-next-line cypress/unsafe-to-chain-command
219
- cy.get('input[name=email]')
235
+ cy.get('input[name=email]', {
236
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
237
+ })
220
238
  // We use `force` as the MC login UI (production) in tests renders the
221
239
  // cookie banner overlapping the input fields.
222
240
  // To allow Cypress to interact with the input fields, we use `force`.
@@ -226,7 +244,9 @@ function loginByForm(commandOptions) {
226
244
  force: true
227
245
  });
228
246
  // eslint-disable-next-line cypress/unsafe-to-chain-command
229
- cy.get('input[name=password]')
247
+ cy.get('input[name=password]', {
248
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
249
+ })
230
250
  // We use `force` as the MC login UI (production) in tests renders the
231
251
  // cookie banner overlapping the input fields.
232
252
  // To allow Cypress to interact with the input fields, we use `force`.
@@ -251,11 +271,15 @@ function loginByForm(commandOptions) {
251
271
  if (isGlobalIdentityEnabled) {
252
272
  cy.url().should('include', `${identityUrl}/login`);
253
273
  // Fill in the email and click Next
254
- cy.get('input[name="identifier"]').type(userCredentials.email);
274
+ cy.get('input[name="identifier"]', {
275
+ timeout: commandOptions.timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
276
+ }).type(userCredentials.email);
255
277
  cy.get('button').contains('Next').click();
256
278
 
257
279
  // Wait for the password form to appear
258
- cy.get('input[name="password"]').should('be.visible');
280
+ cy.get('input[name="password"]', {
281
+ timeout: commandOptions.timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
282
+ }).should('be.visible');
259
283
  // Fill in the password and submit
260
284
  cy.get('input[name="password"]').type(userCredentials.password, {
261
285
  log: false
@@ -274,7 +298,7 @@ function loginByForm(commandOptions) {
274
298
  });
275
299
  } else {
276
300
  // Legacy login flow.
277
- fillLegacyLoginFormWithRetry(userCredentials);
301
+ fillLegacyLoginFormWithRetry(userCredentials, commandOptions.timeouts);
278
302
 
279
303
  // Wait for the flow to redirect back to the application.
280
304
  cy.get('[role="main"]').should('exist');
@@ -304,7 +328,7 @@ function loginByForm(commandOptions) {
304
328
  /* Utilities */
305
329
 
306
330
  const legacyMaxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
307
- function fillLegacyLoginFormWithRetry(userCredentials) {
331
+ function fillLegacyLoginFormWithRetry(userCredentials, timeouts) {
308
332
  // Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
309
333
  cy.intercept('POST', '**/tokens').as('loginRequest');
310
334
  function getRandomDelayInSeconds() {
@@ -319,13 +343,17 @@ function fillLegacyLoginFormWithRetry(userCredentials) {
319
343
  cy.log(`Attempts left: ${attemptsLeft}`);
320
344
 
321
345
  // eslint-disable-next-line cypress/unsafe-to-chain-command
322
- cy.get('input[name=email]').clear({
346
+ cy.get('input[name=email]', {
347
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
348
+ }).clear({
323
349
  force: true
324
350
  }).type(userCredentials.email, {
325
351
  force: true
326
352
  });
327
353
  // eslint-disable-next-line cypress/unsafe-to-chain-command
328
- cy.get('input[name=password]').clear({
354
+ cy.get('input[name=password]', {
355
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
356
+ }).clear({
329
357
  force: true
330
358
  }).type(userCredentials.password, {
331
359
  log: false,
@@ -47,6 +47,10 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _
47
47
 
48
48
  // Alias for backwards compatibility
49
49
 
50
+ const defaultTimeouts = {
51
+ waitForEmailInput: 4000,
52
+ waitForPasswordInput: 8000
53
+ };
50
54
  function isFeatureSupported(expectedVersion) {
51
55
  return semver__default["default"].gte(Cypress.version, expectedVersion);
52
56
  }
@@ -177,18 +181,26 @@ function loginByForm(commandOptions) {
177
181
  cy.origin(identityUrl, {
178
182
  args: {
179
183
  userCredentials,
180
- identityUrl
184
+ identityUrl,
185
+ timeouts: commandOptions.timeouts,
186
+ defaultTimeouts
181
187
  }
182
188
  }, _ref => {
183
189
  let userCredentials = _ref.userCredentials,
184
- identityUrl = _ref.identityUrl;
190
+ identityUrl = _ref.identityUrl,
191
+ timeouts = _ref.timeouts,
192
+ defaultTimeouts = _ref.defaultTimeouts;
185
193
  cy.url().should('include', `${identityUrl}/login`);
186
194
  // Fill in the email and click Next
187
- cy.get('input[name="identifier"]').type(userCredentials.email);
195
+ cy.get('input[name="identifier"]', {
196
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
197
+ }).type(userCredentials.email);
188
198
  cy.get('button').contains('Next').click();
189
199
 
190
200
  // Wait for the password form to appear
191
- cy.get('input[name="password"]').should('be.visible');
201
+ cy.get('input[name="password"]', {
202
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
203
+ }).should('be.visible');
192
204
  // Fill in the password and submit
193
205
  cy.get('input[name="password"]').type(userCredentials.password, {
194
206
  log: false
@@ -207,16 +219,22 @@ function loginByForm(commandOptions) {
207
219
  cy.origin(mcUrl, {
208
220
  args: {
209
221
  userCredentials,
210
- mcUrl
222
+ mcUrl,
223
+ timeouts: commandOptions.timeouts,
224
+ defaultTimeouts
211
225
  }
212
226
  }, _ref2 => {
213
227
  let userCredentials = _ref2.userCredentials,
214
- mcUrl = _ref2.mcUrl;
228
+ mcUrl = _ref2.mcUrl,
229
+ timeouts = _ref2.timeouts,
230
+ defaultTimeouts = _ref2.defaultTimeouts;
215
231
  cy.url().should('include', `${mcUrl}/login`);
216
232
 
217
233
  // Same as `fillLegacyLoginFormWithRetry`.
218
234
  // eslint-disable-next-line cypress/unsafe-to-chain-command
219
- cy.get('input[name=email]')
235
+ cy.get('input[name=email]', {
236
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
237
+ })
220
238
  // We use `force` as the MC login UI (production) in tests renders the
221
239
  // cookie banner overlapping the input fields.
222
240
  // To allow Cypress to interact with the input fields, we use `force`.
@@ -226,7 +244,9 @@ function loginByForm(commandOptions) {
226
244
  force: true
227
245
  });
228
246
  // eslint-disable-next-line cypress/unsafe-to-chain-command
229
- cy.get('input[name=password]')
247
+ cy.get('input[name=password]', {
248
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
249
+ })
230
250
  // We use `force` as the MC login UI (production) in tests renders the
231
251
  // cookie banner overlapping the input fields.
232
252
  // To allow Cypress to interact with the input fields, we use `force`.
@@ -251,11 +271,15 @@ function loginByForm(commandOptions) {
251
271
  if (isGlobalIdentityEnabled) {
252
272
  cy.url().should('include', `${identityUrl}/login`);
253
273
  // Fill in the email and click Next
254
- cy.get('input[name="identifier"]').type(userCredentials.email);
274
+ cy.get('input[name="identifier"]', {
275
+ timeout: commandOptions.timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
276
+ }).type(userCredentials.email);
255
277
  cy.get('button').contains('Next').click();
256
278
 
257
279
  // Wait for the password form to appear
258
- cy.get('input[name="password"]').should('be.visible');
280
+ cy.get('input[name="password"]', {
281
+ timeout: commandOptions.timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
282
+ }).should('be.visible');
259
283
  // Fill in the password and submit
260
284
  cy.get('input[name="password"]').type(userCredentials.password, {
261
285
  log: false
@@ -274,7 +298,7 @@ function loginByForm(commandOptions) {
274
298
  });
275
299
  } else {
276
300
  // Legacy login flow.
277
- fillLegacyLoginFormWithRetry(userCredentials);
301
+ fillLegacyLoginFormWithRetry(userCredentials, commandOptions.timeouts);
278
302
 
279
303
  // Wait for the flow to redirect back to the application.
280
304
  cy.get('[role="main"]').should('exist');
@@ -304,7 +328,7 @@ function loginByForm(commandOptions) {
304
328
  /* Utilities */
305
329
 
306
330
  const legacyMaxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
307
- function fillLegacyLoginFormWithRetry(userCredentials) {
331
+ function fillLegacyLoginFormWithRetry(userCredentials, timeouts) {
308
332
  // Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
309
333
  cy.intercept('POST', '**/tokens').as('loginRequest');
310
334
  function getRandomDelayInSeconds() {
@@ -319,13 +343,17 @@ function fillLegacyLoginFormWithRetry(userCredentials) {
319
343
  cy.log(`Attempts left: ${attemptsLeft}`);
320
344
 
321
345
  // eslint-disable-next-line cypress/unsafe-to-chain-command
322
- cy.get('input[name=email]').clear({
346
+ cy.get('input[name=email]', {
347
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
348
+ }).clear({
323
349
  force: true
324
350
  }).type(userCredentials.email, {
325
351
  force: true
326
352
  });
327
353
  // eslint-disable-next-line cypress/unsafe-to-chain-command
328
- cy.get('input[name=password]').clear({
354
+ cy.get('input[name=password]', {
355
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
356
+ }).clear({
329
357
  force: true
330
358
  }).type(userCredentials.password, {
331
359
  log: false,
@@ -27,6 +27,10 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _
27
27
 
28
28
  // Alias for backwards compatibility
29
29
 
30
+ const defaultTimeouts = {
31
+ waitForEmailInput: 4000,
32
+ waitForPasswordInput: 8000
33
+ };
30
34
  function isFeatureSupported(expectedVersion) {
31
35
  return semver.gte(Cypress.version, expectedVersion);
32
36
  }
@@ -157,18 +161,26 @@ function loginByForm(commandOptions) {
157
161
  cy.origin(identityUrl, {
158
162
  args: {
159
163
  userCredentials,
160
- identityUrl
164
+ identityUrl,
165
+ timeouts: commandOptions.timeouts,
166
+ defaultTimeouts
161
167
  }
162
168
  }, _ref => {
163
169
  let userCredentials = _ref.userCredentials,
164
- identityUrl = _ref.identityUrl;
170
+ identityUrl = _ref.identityUrl,
171
+ timeouts = _ref.timeouts,
172
+ defaultTimeouts = _ref.defaultTimeouts;
165
173
  cy.url().should('include', `${identityUrl}/login`);
166
174
  // Fill in the email and click Next
167
- cy.get('input[name="identifier"]').type(userCredentials.email);
175
+ cy.get('input[name="identifier"]', {
176
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
177
+ }).type(userCredentials.email);
168
178
  cy.get('button').contains('Next').click();
169
179
 
170
180
  // Wait for the password form to appear
171
- cy.get('input[name="password"]').should('be.visible');
181
+ cy.get('input[name="password"]', {
182
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
183
+ }).should('be.visible');
172
184
  // Fill in the password and submit
173
185
  cy.get('input[name="password"]').type(userCredentials.password, {
174
186
  log: false
@@ -187,16 +199,22 @@ function loginByForm(commandOptions) {
187
199
  cy.origin(mcUrl, {
188
200
  args: {
189
201
  userCredentials,
190
- mcUrl
202
+ mcUrl,
203
+ timeouts: commandOptions.timeouts,
204
+ defaultTimeouts
191
205
  }
192
206
  }, _ref2 => {
193
207
  let userCredentials = _ref2.userCredentials,
194
- mcUrl = _ref2.mcUrl;
208
+ mcUrl = _ref2.mcUrl,
209
+ timeouts = _ref2.timeouts,
210
+ defaultTimeouts = _ref2.defaultTimeouts;
195
211
  cy.url().should('include', `${mcUrl}/login`);
196
212
 
197
213
  // Same as `fillLegacyLoginFormWithRetry`.
198
214
  // eslint-disable-next-line cypress/unsafe-to-chain-command
199
- cy.get('input[name=email]')
215
+ cy.get('input[name=email]', {
216
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
217
+ })
200
218
  // We use `force` as the MC login UI (production) in tests renders the
201
219
  // cookie banner overlapping the input fields.
202
220
  // To allow Cypress to interact with the input fields, we use `force`.
@@ -206,7 +224,9 @@ function loginByForm(commandOptions) {
206
224
  force: true
207
225
  });
208
226
  // eslint-disable-next-line cypress/unsafe-to-chain-command
209
- cy.get('input[name=password]')
227
+ cy.get('input[name=password]', {
228
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
229
+ })
210
230
  // We use `force` as the MC login UI (production) in tests renders the
211
231
  // cookie banner overlapping the input fields.
212
232
  // To allow Cypress to interact with the input fields, we use `force`.
@@ -231,11 +251,15 @@ function loginByForm(commandOptions) {
231
251
  if (isGlobalIdentityEnabled) {
232
252
  cy.url().should('include', `${identityUrl}/login`);
233
253
  // Fill in the email and click Next
234
- cy.get('input[name="identifier"]').type(userCredentials.email);
254
+ cy.get('input[name="identifier"]', {
255
+ timeout: commandOptions.timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
256
+ }).type(userCredentials.email);
235
257
  cy.get('button').contains('Next').click();
236
258
 
237
259
  // Wait for the password form to appear
238
- cy.get('input[name="password"]').should('be.visible');
260
+ cy.get('input[name="password"]', {
261
+ timeout: commandOptions.timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
262
+ }).should('be.visible');
239
263
  // Fill in the password and submit
240
264
  cy.get('input[name="password"]').type(userCredentials.password, {
241
265
  log: false
@@ -254,7 +278,7 @@ function loginByForm(commandOptions) {
254
278
  });
255
279
  } else {
256
280
  // Legacy login flow.
257
- fillLegacyLoginFormWithRetry(userCredentials);
281
+ fillLegacyLoginFormWithRetry(userCredentials, commandOptions.timeouts);
258
282
 
259
283
  // Wait for the flow to redirect back to the application.
260
284
  cy.get('[role="main"]').should('exist');
@@ -284,7 +308,7 @@ function loginByForm(commandOptions) {
284
308
  /* Utilities */
285
309
 
286
310
  const legacyMaxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
287
- function fillLegacyLoginFormWithRetry(userCredentials) {
311
+ function fillLegacyLoginFormWithRetry(userCredentials, timeouts) {
288
312
  // Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
289
313
  cy.intercept('POST', '**/tokens').as('loginRequest');
290
314
  function getRandomDelayInSeconds() {
@@ -299,13 +323,17 @@ function fillLegacyLoginFormWithRetry(userCredentials) {
299
323
  cy.log(`Attempts left: ${attemptsLeft}`);
300
324
 
301
325
  // eslint-disable-next-line cypress/unsafe-to-chain-command
302
- cy.get('input[name=email]').clear({
326
+ cy.get('input[name=email]', {
327
+ timeout: timeouts?.waitForEmailInput ?? defaultTimeouts.waitForEmailInput
328
+ }).clear({
303
329
  force: true
304
330
  }).type(userCredentials.email, {
305
331
  force: true
306
332
  });
307
333
  // eslint-disable-next-line cypress/unsafe-to-chain-command
308
- cy.get('input[name=password]').clear({
334
+ cy.get('input[name=password]', {
335
+ timeout: timeouts?.waitForPasswordInput ?? defaultTimeouts.waitForPasswordInput
336
+ }).clear({
309
337
  force: true
310
338
  }).type(userCredentials.password, {
311
339
  log: false,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var constants = require('./constants-009cb682.cjs.dev.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "24.4.0";
8
+ var version = "24.5.0";
9
9
 
10
10
  exports.HTTP_STATUS_CODES = constants.HTTP_STATUS_CODES;
11
11
  exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var constants = require('./constants-2f1475a6.cjs.prod.js');
6
6
 
7
7
  // NOTE: This string will be replaced on build time with the package version.
8
- var version = "24.4.0";
8
+ var version = "24.5.0";
9
9
 
10
10
  exports.HTTP_STATUS_CODES = constants.HTTP_STATUS_CODES;
11
11
  exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
@@ -1,6 +1,6 @@
1
1
  export { H as HTTP_STATUS_CODES, O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from './constants-13c76918.esm.js';
2
2
 
3
3
  // NOTE: This string will be replaced on build time with the package version.
4
- var version = "24.4.0";
4
+ var version = "24.5.0";
5
5
 
6
6
  export { version };
@@ -10,6 +10,18 @@ export type LoginCredentials = {
10
10
  */
11
11
  password: string;
12
12
  };
13
+ export type LoginCommandTimeouts = {
14
+ /**
15
+ * The number of milliseconds to wait for the email input to appear.
16
+ * Defaults to `4000` (4 seconds).
17
+ */
18
+ waitForEmailInput?: number;
19
+ /**
20
+ * The number of milliseconds to wait for the password input to appear.
21
+ * Defaults to `8000` (8 seconds).
22
+ */
23
+ waitForPasswordInput?: number;
24
+ };
13
25
  export type CommandLoginOptions = {
14
26
  /**
15
27
  * The application entry point URI path. This value is used to identify
@@ -46,6 +58,10 @@ export type CommandLoginOptions = {
46
58
  * This is only relevant for Cypress version >= `10.9.0`.
47
59
  */
48
60
  disableCacheAcrossSpecs?: boolean;
61
+ /**
62
+ * Configure timeouts for some of the command interactions.
63
+ */
64
+ timeouts?: LoginCommandTimeouts;
49
65
  };
50
66
  export type LoginToMerchantCenterForCustomViewCommandLoginOptions = Omit<CommandLoginOptions, 'entryPointUriPath' | 'initialRoute'> & {
51
67
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/cypress",
3
- "version": "24.4.0",
3
+ "version": "24.5.0",
4
4
  "description": "Cypress commands and utilities for Custom Applications",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -41,9 +41,9 @@
41
41
  "dependencies": {
42
42
  "@babel/runtime": "^7.22.15",
43
43
  "@babel/runtime-corejs3": "^7.22.15",
44
- "@commercetools-frontend/application-config": "24.4.0",
45
- "@commercetools-frontend/application-shell": "24.4.0",
46
- "@commercetools-frontend/constants": "24.4.0",
44
+ "@commercetools-frontend/application-config": "24.5.0",
45
+ "@commercetools-frontend/application-shell": "24.5.0",
46
+ "@commercetools-frontend/constants": "24.5.0",
47
47
  "@manypkg/get-packages": "1.1.3",
48
48
  "@types/semver": "^7.5.1",
49
49
  "semver": "7.6.2",