@commercetools-frontend/cypress 23.2.3 → 23.4.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.
- package/add-commands/dist/commercetools-frontend-cypress-add-commands.cjs.dev.js +37 -6
- package/add-commands/dist/commercetools-frontend-cypress-add-commands.cjs.prod.js +37 -6
- package/add-commands/dist/commercetools-frontend-cypress-add-commands.esm.js +37 -6
- package/dist/commercetools-frontend-cypress.cjs.dev.js +3 -2
- package/dist/commercetools-frontend-cypress.cjs.prod.js +3 -2
- package/dist/commercetools-frontend-cypress.esm.js +2 -2
- package/dist/{constants-8ad2a50e.cjs.prod.js → constants-009cb682.cjs.dev.js} +4 -0
- package/dist/{constants-18b165fc.esm.js → constants-13c76918.esm.js} +4 -1
- package/dist/{constants-c657705e.cjs.dev.js → constants-2f1475a6.cjs.prod.js} +4 -0
- package/dist/declarations/src/constants.d.ts +3 -0
- package/package.json +4 -4
|
@@ -16,7 +16,7 @@ var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
|
16
16
|
var semver = require('semver');
|
|
17
17
|
var uuid = require('uuid');
|
|
18
18
|
var ssr = require('@commercetools-frontend/application-shell/ssr');
|
|
19
|
-
var constants = require('../../dist/constants-
|
|
19
|
+
var constants = require('../../dist/constants-009cb682.cjs.dev.js');
|
|
20
20
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
21
21
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
22
22
|
var _Array$from = require('@babel/runtime-corejs3/core-js-stable/array/from');
|
|
@@ -223,12 +223,43 @@ function loginByOidc(commandOptions) {
|
|
|
223
223
|
|
|
224
224
|
/* Utilities */
|
|
225
225
|
|
|
226
|
+
const maxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
|
|
226
227
|
function fillLoginForm(userCredentials) {
|
|
227
|
-
|
|
228
|
-
cy.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
// Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
|
|
229
|
+
cy.intercept('POST', '**/tokens').as('loginRequest');
|
|
230
|
+
function getRandomDelayInSeconds() {
|
|
231
|
+
const minSeconds = 0.5;
|
|
232
|
+
const maxSeconds = 1.5;
|
|
233
|
+
return (Math.random() * (maxSeconds - minSeconds) + minSeconds) * 1000;
|
|
234
|
+
}
|
|
235
|
+
function attemptLogin(attemptsLeft) {
|
|
236
|
+
if (attemptsLeft <= 0) {
|
|
237
|
+
throw new Error(`All login attempts exhausted. Please check your credentials.`);
|
|
238
|
+
}
|
|
239
|
+
cy.log(`Attempts left: ${attemptsLeft}`);
|
|
240
|
+
|
|
241
|
+
// eslint-disable-next-line cypress/unsafe-to-chain-command
|
|
242
|
+
cy.get('input[name=email]').clear().type(userCredentials.email);
|
|
243
|
+
// eslint-disable-next-line cypress/unsafe-to-chain-command
|
|
244
|
+
cy.get('input[name=password]').clear().type(userCredentials.password, {
|
|
245
|
+
log: false
|
|
246
|
+
});
|
|
247
|
+
cy.get('button').contains('Sign in').click();
|
|
248
|
+
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
cy.wait('@loginRequest').then(interception => {
|
|
251
|
+
const statusCode = interception.response.statusCode;
|
|
252
|
+
cy.log('Login request status code:', statusCode);
|
|
253
|
+
if (statusCode === constants.HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {
|
|
254
|
+
// We wait for something between 0.5 and 1.5 seconds before retrying
|
|
255
|
+
cy.wait(getRandomDelayInSeconds());
|
|
256
|
+
attemptLogin(attemptsLeft - 1);
|
|
257
|
+
} else {
|
|
258
|
+
cy.log('Login successful');
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
attemptLogin(maxLoginAttempts);
|
|
232
263
|
}
|
|
233
264
|
function isLocalhost() {
|
|
234
265
|
const baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
|
|
@@ -16,7 +16,7 @@ var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
|
16
16
|
var semver = require('semver');
|
|
17
17
|
var uuid = require('uuid');
|
|
18
18
|
var ssr = require('@commercetools-frontend/application-shell/ssr');
|
|
19
|
-
var constants = require('../../dist/constants-
|
|
19
|
+
var constants = require('../../dist/constants-2f1475a6.cjs.prod.js');
|
|
20
20
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
21
21
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
22
22
|
var _Array$from = require('@babel/runtime-corejs3/core-js-stable/array/from');
|
|
@@ -223,12 +223,43 @@ function loginByOidc(commandOptions) {
|
|
|
223
223
|
|
|
224
224
|
/* Utilities */
|
|
225
225
|
|
|
226
|
+
const maxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
|
|
226
227
|
function fillLoginForm(userCredentials) {
|
|
227
|
-
|
|
228
|
-
cy.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
// Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
|
|
229
|
+
cy.intercept('POST', '**/tokens').as('loginRequest');
|
|
230
|
+
function getRandomDelayInSeconds() {
|
|
231
|
+
const minSeconds = 0.5;
|
|
232
|
+
const maxSeconds = 1.5;
|
|
233
|
+
return (Math.random() * (maxSeconds - minSeconds) + minSeconds) * 1000;
|
|
234
|
+
}
|
|
235
|
+
function attemptLogin(attemptsLeft) {
|
|
236
|
+
if (attemptsLeft <= 0) {
|
|
237
|
+
throw new Error(`All login attempts exhausted. Please check your credentials.`);
|
|
238
|
+
}
|
|
239
|
+
cy.log(`Attempts left: ${attemptsLeft}`);
|
|
240
|
+
|
|
241
|
+
// eslint-disable-next-line cypress/unsafe-to-chain-command
|
|
242
|
+
cy.get('input[name=email]').clear().type(userCredentials.email);
|
|
243
|
+
// eslint-disable-next-line cypress/unsafe-to-chain-command
|
|
244
|
+
cy.get('input[name=password]').clear().type(userCredentials.password, {
|
|
245
|
+
log: false
|
|
246
|
+
});
|
|
247
|
+
cy.get('button').contains('Sign in').click();
|
|
248
|
+
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
cy.wait('@loginRequest').then(interception => {
|
|
251
|
+
const statusCode = interception.response.statusCode;
|
|
252
|
+
cy.log('Login request status code:', statusCode);
|
|
253
|
+
if (statusCode === constants.HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {
|
|
254
|
+
// We wait for something between 0.5 and 1.5 seconds before retrying
|
|
255
|
+
cy.wait(getRandomDelayInSeconds());
|
|
256
|
+
attemptLogin(attemptsLeft - 1);
|
|
257
|
+
} else {
|
|
258
|
+
cy.log('Login successful');
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
attemptLogin(maxLoginAttempts);
|
|
232
263
|
}
|
|
233
264
|
function isLocalhost() {
|
|
234
265
|
const baseUrl = new _URL__default["default"](Cypress.config('baseUrl'));
|
|
@@ -14,7 +14,7 @@ import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
|
14
14
|
import semver from 'semver';
|
|
15
15
|
import { v4 } from 'uuid';
|
|
16
16
|
import { buildOidcScope } from '@commercetools-frontend/application-shell/ssr';
|
|
17
|
-
import { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from '../../dist/constants-
|
|
17
|
+
import { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS, H as HTTP_STATUS_CODES } from '../../dist/constants-13c76918.esm.js';
|
|
18
18
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
19
19
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
20
20
|
import _Array$from from '@babel/runtime-corejs3/core-js-stable/array/from';
|
|
@@ -202,12 +202,43 @@ function loginByOidc(commandOptions) {
|
|
|
202
202
|
|
|
203
203
|
/* Utilities */
|
|
204
204
|
|
|
205
|
+
const maxLoginAttempts = Cypress.config('maxLoginAttempts') ?? 3;
|
|
205
206
|
function fillLoginForm(userCredentials) {
|
|
206
|
-
|
|
207
|
-
cy.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
// Intercept the login request so we can retry it if we receive a TOO_MANY_REQUESTS status code
|
|
208
|
+
cy.intercept('POST', '**/tokens').as('loginRequest');
|
|
209
|
+
function getRandomDelayInSeconds() {
|
|
210
|
+
const minSeconds = 0.5;
|
|
211
|
+
const maxSeconds = 1.5;
|
|
212
|
+
return (Math.random() * (maxSeconds - minSeconds) + minSeconds) * 1000;
|
|
213
|
+
}
|
|
214
|
+
function attemptLogin(attemptsLeft) {
|
|
215
|
+
if (attemptsLeft <= 0) {
|
|
216
|
+
throw new Error(`All login attempts exhausted. Please check your credentials.`);
|
|
217
|
+
}
|
|
218
|
+
cy.log(`Attempts left: ${attemptsLeft}`);
|
|
219
|
+
|
|
220
|
+
// eslint-disable-next-line cypress/unsafe-to-chain-command
|
|
221
|
+
cy.get('input[name=email]').clear().type(userCredentials.email);
|
|
222
|
+
// eslint-disable-next-line cypress/unsafe-to-chain-command
|
|
223
|
+
cy.get('input[name=password]').clear().type(userCredentials.password, {
|
|
224
|
+
log: false
|
|
225
|
+
});
|
|
226
|
+
cy.get('button').contains('Sign in').click();
|
|
227
|
+
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
cy.wait('@loginRequest').then(interception => {
|
|
230
|
+
const statusCode = interception.response.statusCode;
|
|
231
|
+
cy.log('Login request status code:', statusCode);
|
|
232
|
+
if (statusCode === HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {
|
|
233
|
+
// We wait for something between 0.5 and 1.5 seconds before retrying
|
|
234
|
+
cy.wait(getRandomDelayInSeconds());
|
|
235
|
+
attemptLogin(attemptsLeft - 1);
|
|
236
|
+
} else {
|
|
237
|
+
cy.log('Login successful');
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
attemptLogin(maxLoginAttempts);
|
|
211
242
|
}
|
|
212
243
|
function isLocalhost() {
|
|
213
244
|
const baseUrl = new _URL(Cypress.config('baseUrl'));
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var constants = require('./constants-
|
|
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 = "23.
|
|
8
|
+
var version = "23.4.0";
|
|
9
9
|
|
|
10
|
+
exports.HTTP_STATUS_CODES = constants.HTTP_STATUS_CODES;
|
|
10
11
|
exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
|
|
11
12
|
exports.STORAGE_KEYS = constants.STORAGE_KEYS;
|
|
12
13
|
exports.version = version;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var constants = require('./constants-
|
|
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 = "23.
|
|
8
|
+
var version = "23.4.0";
|
|
9
9
|
|
|
10
|
+
exports.HTTP_STATUS_CODES = constants.HTTP_STATUS_CODES;
|
|
10
11
|
exports.OIDC_RESPONSE_TYPES = constants.OIDC_RESPONSE_TYPES;
|
|
11
12
|
exports.STORAGE_KEYS = constants.STORAGE_KEYS;
|
|
12
13
|
exports.version = version;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { O as OIDC_RESPONSE_TYPES, S as STORAGE_KEYS } from './constants-
|
|
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 = "23.
|
|
4
|
+
var version = "23.4.0";
|
|
5
5
|
|
|
6
6
|
export { version };
|
|
@@ -8,6 +8,10 @@ const STORAGE_KEYS = {
|
|
|
8
8
|
const OIDC_RESPONSE_TYPES = {
|
|
9
9
|
ID_TOKEN: 'id_token'
|
|
10
10
|
};
|
|
11
|
+
const HTTP_STATUS_CODES = {
|
|
12
|
+
TOO_MANY_REQUESTS: 429
|
|
13
|
+
};
|
|
11
14
|
|
|
15
|
+
exports.HTTP_STATUS_CODES = HTTP_STATUS_CODES;
|
|
12
16
|
exports.OIDC_RESPONSE_TYPES = OIDC_RESPONSE_TYPES;
|
|
13
17
|
exports.STORAGE_KEYS = STORAGE_KEYS;
|
|
@@ -6,5 +6,8 @@ const STORAGE_KEYS = {
|
|
|
6
6
|
const OIDC_RESPONSE_TYPES = {
|
|
7
7
|
ID_TOKEN: 'id_token'
|
|
8
8
|
};
|
|
9
|
+
const HTTP_STATUS_CODES = {
|
|
10
|
+
TOO_MANY_REQUESTS: 429
|
|
11
|
+
};
|
|
9
12
|
|
|
10
|
-
export { OIDC_RESPONSE_TYPES as O, STORAGE_KEYS as S };
|
|
13
|
+
export { HTTP_STATUS_CODES as H, OIDC_RESPONSE_TYPES as O, STORAGE_KEYS as S };
|
|
@@ -8,6 +8,10 @@ const STORAGE_KEYS = {
|
|
|
8
8
|
const OIDC_RESPONSE_TYPES = {
|
|
9
9
|
ID_TOKEN: 'id_token'
|
|
10
10
|
};
|
|
11
|
+
const HTTP_STATUS_CODES = {
|
|
12
|
+
TOO_MANY_REQUESTS: 429
|
|
13
|
+
};
|
|
11
14
|
|
|
15
|
+
exports.HTTP_STATUS_CODES = HTTP_STATUS_CODES;
|
|
12
16
|
exports.OIDC_RESPONSE_TYPES = OIDC_RESPONSE_TYPES;
|
|
13
17
|
exports.STORAGE_KEYS = STORAGE_KEYS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/cypress",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.4.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": "23.
|
|
45
|
-
"@commercetools-frontend/application-shell": "23.
|
|
46
|
-
"@commercetools-frontend/constants": "23.
|
|
44
|
+
"@commercetools-frontend/application-config": "23.4.0",
|
|
45
|
+
"@commercetools-frontend/application-shell": "23.4.0",
|
|
46
|
+
"@commercetools-frontend/constants": "23.4.0",
|
|
47
47
|
"@manypkg/get-packages": "1.1.3",
|
|
48
48
|
"@types/semver": "^7.5.1",
|
|
49
49
|
"semver": "7.6.2",
|