@jahia/cypress 4.3.0 → 4.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
+
import RequestOptions = Cypress.RequestOptions;
|
|
2
3
|
declare global {
|
|
3
4
|
namespace Cypress {
|
|
4
5
|
interface Chainable<Subject> {
|
|
@@ -21,4 +22,4 @@ export declare type JahiaServer = {
|
|
|
21
22
|
username: string;
|
|
22
23
|
password: string;
|
|
23
24
|
};
|
|
24
|
-
export declare const runProvisioningScript: (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable, timeout?: number) => void;
|
|
25
|
+
export declare const runProvisioningScript: (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable, timeout?: number, requestOptions?: Partial<RequestOptions>) => void;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
exports.__esModule = true;
|
|
3
14
|
exports.runProvisioningScript = void 0;
|
|
4
15
|
function processContent(formFile) {
|
|
@@ -36,9 +47,10 @@ function isFormFile(script) {
|
|
|
36
47
|
return Boolean(script.fileContent || script.fileName);
|
|
37
48
|
}
|
|
38
49
|
// eslint-disable-next-line default-param-last, max-params
|
|
39
|
-
var runProvisioningScript = function (script, files, jahiaServer, options, timeout) {
|
|
50
|
+
var runProvisioningScript = function (script, files, jahiaServer, options, timeout, requestOptions) {
|
|
40
51
|
if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
|
|
41
52
|
if (options === void 0) { options = { log: true }; }
|
|
53
|
+
if (requestOptions === void 0) { requestOptions = {}; }
|
|
42
54
|
var formData = new FormData();
|
|
43
55
|
if (isFormFile(script)) {
|
|
44
56
|
append(script, formData, 'script');
|
|
@@ -75,17 +87,11 @@ var runProvisioningScript = function (script, files, jahiaServer, options, timeo
|
|
|
75
87
|
}
|
|
76
88
|
});
|
|
77
89
|
}
|
|
78
|
-
var request = {
|
|
79
|
-
url: jahiaServer.url + "/modules/api/provisioning",
|
|
80
|
-
method: 'POST',
|
|
81
|
-
auth: {
|
|
90
|
+
var request = __assign({ url: jahiaServer.url + "/modules/api/provisioning", method: 'POST', auth: {
|
|
82
91
|
user: jahiaServer.username,
|
|
83
92
|
pass: jahiaServer.password,
|
|
84
93
|
sendImmediately: true
|
|
85
|
-
},
|
|
86
|
-
body: formData,
|
|
87
|
-
log: false
|
|
88
|
-
};
|
|
94
|
+
}, body: formData, log: false }, requestOptions);
|
|
89
95
|
if (typeof timeout !== 'undefined') {
|
|
90
96
|
request.timeout = timeout;
|
|
91
97
|
}
|
package/package.json
CHANGED
|
@@ -45,6 +45,15 @@ Additional files that can be referenced in the script. When an operation require
|
|
|
45
45
|
|
|
46
46
|
- `log` : should the command be logged or not
|
|
47
47
|
|
|
48
|
+
#### > timeout (`number`)
|
|
49
|
+
|
|
50
|
+
the timeout in milliseconds
|
|
51
|
+
|
|
52
|
+
#### > requestOptions (`RequestOptions`)
|
|
53
|
+
|
|
54
|
+
Addition options for the cypress request object, some useful ones are:
|
|
55
|
+
- `failOnStatusCode` : useful when you expect a 4xx or 5xx error and need to test it
|
|
56
|
+
|
|
48
57
|
### Yields
|
|
49
58
|
|
|
50
59
|
The provisioning script result, as JSON object
|
|
@@ -69,7 +69,7 @@ function isFormFile(script: FormFile | StringDictionary[]): script is FormFile {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// eslint-disable-next-line default-param-last, max-params
|
|
72
|
-
export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log: true}, timeout?: number): void => {
|
|
72
|
+
export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log: true}, timeout?: number, requestOptions: Partial<RequestOptions> = {}): void => {
|
|
73
73
|
const formData = new FormData();
|
|
74
74
|
|
|
75
75
|
if (isFormFile(script)) {
|
|
@@ -119,7 +119,8 @@ export const runProvisioningScript = (script: FormFile | StringDictionary[], fil
|
|
|
119
119
|
sendImmediately: true
|
|
120
120
|
},
|
|
121
121
|
body: formData,
|
|
122
|
-
log: false
|
|
122
|
+
log: false,
|
|
123
|
+
...requestOptions
|
|
123
124
|
};
|
|
124
125
|
|
|
125
126
|
if (typeof timeout !== 'undefined') {
|