@jahia/cypress 4.4.0 → 5.0.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/dist/support/provisioning/executeGroovy.js +11 -7
- package/dist/support/provisioning/installBundle.js +7 -4
- package/dist/support/provisioning/runProvisioningScript.d.ts +10 -2
- package/dist/support/provisioning/runProvisioningScript.js +2 -8
- package/dist/support/provisioning/uninstallBundle.js +4 -2
- package/dist/utils/SiteHelper.js +6 -3
- package/package.json +1 -1
- package/src/support/provisioning/executeGroovy.ts +11 -7
- package/src/support/provisioning/installBundle.ts +7 -4
- package/src/support/provisioning/runProvisioningScript.md +74 -52
- package/src/support/provisioning/runProvisioningScript.ts +17 -8
- package/src/support/provisioning/uninstallBundle.ts +4 -2
- package/src/utils/SiteHelper.ts +6 -3
|
@@ -11,12 +11,16 @@ var serverDefaults = {
|
|
|
11
11
|
var executeGroovy = function (scriptFile, replacements, jahiaServer) {
|
|
12
12
|
if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
|
|
13
13
|
cy.runProvisioningScript({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
script: {
|
|
15
|
+
fileContent: '- executeScript: "' + scriptFile + '"',
|
|
16
|
+
type: 'application/yaml'
|
|
17
|
+
},
|
|
18
|
+
files: [{
|
|
19
|
+
fileName: scriptFile,
|
|
20
|
+
replacements: replacements,
|
|
21
|
+
type: 'text/plain'
|
|
22
|
+
}],
|
|
23
|
+
jahiaServer: jahiaServer
|
|
24
|
+
}).then(function (r) { return r[0]; });
|
|
21
25
|
};
|
|
22
26
|
exports.executeGroovy = executeGroovy;
|
|
@@ -4,9 +4,12 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.installBundle = void 0;
|
|
5
5
|
/// <reference types="cypress" />
|
|
6
6
|
var installBundle = function (bundleFile) {
|
|
7
|
-
cy.runProvisioningScript(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
cy.runProvisioningScript({
|
|
8
|
+
script: [{ installBundle: bundleFile }],
|
|
9
|
+
files: [{
|
|
10
|
+
fileName: bundleFile,
|
|
11
|
+
type: 'text/plain'
|
|
12
|
+
}]
|
|
13
|
+
});
|
|
11
14
|
};
|
|
12
15
|
exports.installBundle = installBundle;
|
|
@@ -3,10 +3,18 @@ import RequestOptions = Cypress.RequestOptions;
|
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Cypress {
|
|
5
5
|
interface Chainable<Subject> {
|
|
6
|
-
runProvisioningScript(
|
|
6
|
+
runProvisioningScript(params: RunProvisioningScriptParams): Chainable<void>;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
export interface RunProvisioningScriptParams {
|
|
11
|
+
script: FormFile | StringDictionary[];
|
|
12
|
+
files?: FormFile[];
|
|
13
|
+
/** Optional, defaults to serverDefaults */
|
|
14
|
+
jahiaServer?: JahiaServer;
|
|
15
|
+
options?: Cypress.Loggable;
|
|
16
|
+
requestOptions?: Partial<RequestOptions>;
|
|
17
|
+
}
|
|
10
18
|
export declare type StringDictionary = {
|
|
11
19
|
[key: string]: string;
|
|
12
20
|
};
|
|
@@ -22,4 +30,4 @@ export declare type JahiaServer = {
|
|
|
22
30
|
username: string;
|
|
23
31
|
password: string;
|
|
24
32
|
};
|
|
25
|
-
export declare const runProvisioningScript: (script
|
|
33
|
+
export declare const runProvisioningScript: ({ script, files, jahiaServer, options, requestOptions }: RunProvisioningScriptParams) => void;
|
|
@@ -46,11 +46,8 @@ var serverDefaults = {
|
|
|
46
46
|
function isFormFile(script) {
|
|
47
47
|
return Boolean(script.fileContent || script.fileName);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
|
|
52
|
-
if (options === void 0) { options = { log: true }; }
|
|
53
|
-
if (requestOptions === void 0) { requestOptions = {}; }
|
|
49
|
+
var runProvisioningScript = function (_a) {
|
|
50
|
+
var script = _a.script, files = _a.files, _b = _a.jahiaServer, jahiaServer = _b === void 0 ? serverDefaults : _b, _c = _a.options, options = _c === void 0 ? { log: true } : _c, _d = _a.requestOptions, requestOptions = _d === void 0 ? {} : _d;
|
|
54
51
|
var formData = new FormData();
|
|
55
52
|
if (isFormFile(script)) {
|
|
56
53
|
append(script, formData, 'script');
|
|
@@ -92,9 +89,6 @@ var runProvisioningScript = function (script, files, jahiaServer, options, timeo
|
|
|
92
89
|
pass: jahiaServer.password,
|
|
93
90
|
sendImmediately: true
|
|
94
91
|
}, body: formData, log: false }, requestOptions);
|
|
95
|
-
if (typeof timeout !== 'undefined') {
|
|
96
|
-
request.timeout = timeout;
|
|
97
|
-
}
|
|
98
92
|
cy.request(request).then(function (res) {
|
|
99
93
|
response = res;
|
|
100
94
|
expect(res.status, 'Script result').to.eq(200);
|
|
@@ -5,8 +5,10 @@ exports.uninstallBundle = void 0;
|
|
|
5
5
|
/// <reference types="cypress" />
|
|
6
6
|
var uninstallBundle = function (bundleSymbolicName) {
|
|
7
7
|
cy.runProvisioningScript({
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
script: {
|
|
9
|
+
fileContent: '- uninstallBundle: "' + bundleSymbolicName + '"\n',
|
|
10
|
+
type: 'application/yaml'
|
|
11
|
+
}
|
|
10
12
|
});
|
|
11
13
|
};
|
|
12
14
|
exports.uninstallBundle = uninstallBundle;
|
package/dist/utils/SiteHelper.js
CHANGED
|
@@ -21,9 +21,12 @@ var deleteSite = function (siteKey, jahiaServer) {
|
|
|
21
21
|
exports.deleteSite = deleteSite;
|
|
22
22
|
var enableModule = function (moduleName, siteKey, jahiaServer) {
|
|
23
23
|
cy.runProvisioningScript({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
script: {
|
|
25
|
+
fileContent: '- enable: "' + moduleName + '"\n site: "' + siteKey + '"',
|
|
26
|
+
type: 'application/yaml'
|
|
27
|
+
},
|
|
28
|
+
jahiaServer: jahiaServer
|
|
29
|
+
});
|
|
27
30
|
};
|
|
28
31
|
exports.enableModule = enableModule;
|
|
29
32
|
var disableModule = function (moduleName, siteKey) {
|
package/package.json
CHANGED
|
@@ -26,11 +26,15 @@ const serverDefaults = {
|
|
|
26
26
|
|
|
27
27
|
export const executeGroovy = function (scriptFile: string, replacements?: { [key: string]: string }, jahiaServer: JahiaServer = serverDefaults): void {
|
|
28
28
|
cy.runProvisioningScript({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
script: {
|
|
30
|
+
fileContent: '- executeScript: "' + scriptFile + '"',
|
|
31
|
+
type: 'application/yaml'
|
|
32
|
+
},
|
|
33
|
+
files: [{
|
|
34
|
+
fileName: scriptFile,
|
|
35
|
+
replacements,
|
|
36
|
+
type: 'text/plain'
|
|
37
|
+
}],
|
|
38
|
+
jahiaServer
|
|
39
|
+
}).then(r => r[0]);
|
|
36
40
|
};
|
|
@@ -13,8 +13,11 @@ declare global {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const installBundle = function (bundleFile: string): void {
|
|
16
|
-
cy.runProvisioningScript(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
cy.runProvisioningScript({
|
|
17
|
+
script: [{installBundle: bundleFile}],
|
|
18
|
+
files: [{
|
|
19
|
+
fileName: bundleFile,
|
|
20
|
+
type: 'text/plain'
|
|
21
|
+
}]
|
|
22
|
+
});
|
|
20
23
|
};
|
|
@@ -1,101 +1,123 @@
|
|
|
1
1
|
# runProvisioningScript
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This command executes a provisioning script.
|
|
4
4
|
|
|
5
|
-
> This can be used to install modules, import sites, execute
|
|
5
|
+
> This can be used to install modules, import sites, execute Groovy/GraphQL/SQL scripts with the help of the provisioning REST API.
|
|
6
6
|
|
|
7
7
|
## Syntax
|
|
8
8
|
|
|
9
9
|
### Usage
|
|
10
10
|
|
|
11
|
-
```
|
|
12
|
-
cy.runProvisioningScript({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
```javascript
|
|
12
|
+
cy.runProvisioningScript({
|
|
13
|
+
script: { fileName: 'prov.yaml', type: 'application/yaml' }
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
cy.runProvisioningScript({
|
|
17
|
+
script: { fileName: 'prov.yaml', type: 'application/yaml' },
|
|
18
|
+
files: [{ fileName: 'file1.zip' }]
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
cy.runProvisioningScript({
|
|
22
|
+
script: { fileContent: '- startBundle: "module"', type: 'application/yaml' }
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
cy.runProvisioningScript({
|
|
26
|
+
script: { fileContent: '- startBundle: "module"', type: 'application/yaml' },
|
|
27
|
+
jahiaServer: { url: 'http://jahia-processing.jahia.net:8080', username: 'root', password: 'root1234' }
|
|
28
|
+
});
|
|
16
29
|
```
|
|
17
30
|
|
|
18
31
|
### Arguments
|
|
19
32
|
|
|
20
|
-
####
|
|
33
|
+
#### `script` (`FormFile`)
|
|
21
34
|
|
|
22
|
-
The script can be specified either from an external file (using fileName) or inline (using fileContent)
|
|
35
|
+
The script can be specified either from an external file (using `fileName`) or inline (using `fileContent`).
|
|
23
36
|
|
|
24
|
-
- fileName
|
|
25
|
-
- fileContent
|
|
26
|
-
- type
|
|
37
|
+
- **fileName**: (`string`) - The name of the script file, located in the `fixtures` folder.
|
|
38
|
+
- **fileContent**: (`string`) - The content of the script. If specified, `fileName` is ignored.
|
|
39
|
+
- **type**: (`string`) - Content type, either `application/yaml` or `application/json`.
|
|
27
40
|
|
|
28
|
-
####
|
|
41
|
+
#### `jahiaServer` (`JahiaServer`)
|
|
29
42
|
|
|
30
|
-
A Jahia server can be specified if there is a need to use something other than default. This is useful when using Jahia in cluster, if there is a need to redirect a provisioning script to a specific Jahia server (
|
|
43
|
+
A Jahia server can be specified if there is a need to use something other than the default. This is useful when using Jahia in a cluster, or if there is a need to redirect a provisioning script to a specific Jahia server (e.g., a processing node).
|
|
31
44
|
|
|
32
|
-
- url
|
|
33
|
-
- username
|
|
34
|
-
- password
|
|
45
|
+
- **url**: (`string`) - The URL of the server (e.g., `http://processing.jahia.net:8080`).
|
|
46
|
+
- **username**: (`string`) - The root username.
|
|
47
|
+
- **password**: (`string`) - The password for the root user.
|
|
35
48
|
|
|
36
|
-
####
|
|
49
|
+
#### `files` (`FormFile[]`)
|
|
37
50
|
|
|
38
|
-
Additional files that can be referenced in the script. When an operation requires a URL, directly specify the file name (without protocol) to use one these files
|
|
51
|
+
Additional files that can be referenced in the script. When an operation requires a URL, directly specify the file name (without protocol) to use one of these files.
|
|
39
52
|
|
|
40
|
-
- fileName
|
|
41
|
-
- fileContent
|
|
42
|
-
- type
|
|
53
|
+
- **fileName**: (`string`) - The name of the file, located in the `fixtures` folder.
|
|
54
|
+
- **fileContent**: (`string`) - The content of the file. If specified, `fileName` is ignored.
|
|
55
|
+
- **type**: (`string`) - The content type of the file.
|
|
43
56
|
|
|
44
|
-
####
|
|
57
|
+
#### `options` (`Cypress.Loggable`)
|
|
45
58
|
|
|
46
|
-
|
|
59
|
+
Options for the Cypress command.
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
- **log**: (`boolean`) - Indicates whether the command should be logged or not.
|
|
49
62
|
|
|
50
|
-
|
|
63
|
+
#### `requestOptions` (`RequestOptions`)
|
|
51
64
|
|
|
52
|
-
|
|
65
|
+
Additional options for the Cypress request object. Some useful ones include:
|
|
53
66
|
|
|
54
|
-
|
|
55
|
-
- `
|
|
67
|
+
- **failOnStatusCode**: (`boolean`) - Useful when you expect a 4xx or 5xx error and need to test it.
|
|
68
|
+
- **timeout**: (`number`) - Useful when you need control over the timeout of the request.
|
|
56
69
|
|
|
57
70
|
### Yields
|
|
58
71
|
|
|
59
|
-
The provisioning script result, as JSON object
|
|
72
|
+
The provisioning script result, as a JSON object.
|
|
60
73
|
|
|
61
74
|
## Examples
|
|
62
75
|
|
|
63
|
-
### Execute a
|
|
76
|
+
### Execute a Script
|
|
64
77
|
|
|
65
|
-
Will run the script in `fixtures/provisioning/test.yaml
|
|
78
|
+
Will run the script in `fixtures/provisioning/test.yaml`:
|
|
66
79
|
|
|
67
|
-
```
|
|
68
|
-
cy.runProvisioningScript({
|
|
80
|
+
```javascript
|
|
81
|
+
cy.runProvisioningScript({
|
|
82
|
+
script: { fileName: 'provisioning/test.yaml', type: 'application/yaml' }
|
|
83
|
+
});
|
|
69
84
|
```
|
|
70
85
|
|
|
71
|
-
### Inline
|
|
86
|
+
### Inline Script with Additional File
|
|
72
87
|
|
|
73
|
-
Will install the bundle in `fixtures/bundle.jar
|
|
88
|
+
Will install the bundle in `fixtures/bundle.jar`:
|
|
74
89
|
|
|
75
|
-
```
|
|
76
|
-
cy.runProvisioningScript(
|
|
77
|
-
{fileContent: '- installBundle: "bundle.jar"',type: 'application/yaml'},
|
|
78
|
-
[
|
|
79
|
-
{ fileName:
|
|
90
|
+
```javascript
|
|
91
|
+
cy.runProvisioningScript({
|
|
92
|
+
script: { fileContent: '- installBundle: "bundle.jar"', type: 'application/yaml' },
|
|
93
|
+
files: [
|
|
94
|
+
{ fileName: 'bundle.jar', type: 'application/java-archive' }
|
|
80
95
|
]
|
|
81
|
-
)
|
|
96
|
+
});
|
|
82
97
|
```
|
|
83
98
|
|
|
84
|
-
|
|
99
|
+
### Use a Custom Jahia Server
|
|
85
100
|
|
|
86
|
-
|
|
101
|
+
Will run the script on a specific Jahia server:
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
cy.runProvisioningScript({
|
|
105
|
+
script: { fileName: 'prov.yaml', type: 'application/yaml' },
|
|
106
|
+
jahiaServer: { url: 'http://custom-server.jahia.net:8080', username: 'admin', password: 'admin123' }
|
|
107
|
+
});
|
|
108
|
+
```
|
|
87
109
|
|
|
88
|
-
|
|
110
|
+
## Rules
|
|
89
111
|
|
|
90
|
-
###
|
|
112
|
+
### Requirements
|
|
91
113
|
|
|
92
|
-
|
|
114
|
+
- `cy.runProvisioningScript()` must be chained off of `cy`.
|
|
93
115
|
|
|
94
116
|
## Command Log
|
|
95
117
|
|
|
96
|
-
When clicking on `
|
|
118
|
+
When clicking on `runProvisioningScript` within the command log, the console outputs the following:
|
|
97
119
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
120
|
+
- **Script**: The name and content of the script sent.
|
|
121
|
+
- **Files**: The name and content of every additional file sent.
|
|
122
|
+
- **Response**: The response from the REST call.
|
|
123
|
+
- **Yielded**: The JSON result yielded.
|
|
@@ -8,12 +8,20 @@ declare global {
|
|
|
8
8
|
namespace Cypress {
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
10
|
interface Chainable<Subject> {
|
|
11
|
-
|
|
12
|
-
runProvisioningScript(script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer): Chainable<any>
|
|
11
|
+
runProvisioningScript(params: RunProvisioningScriptParams): Chainable<void>;
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
|
|
16
|
+
export interface RunProvisioningScriptParams {
|
|
17
|
+
script: FormFile | StringDictionary[];
|
|
18
|
+
files?: FormFile[];
|
|
19
|
+
/** Optional, defaults to serverDefaults */
|
|
20
|
+
jahiaServer?: JahiaServer;
|
|
21
|
+
options?: Cypress.Loggable; // Optional, defaults to { log: true }
|
|
22
|
+
requestOptions?: Partial<RequestOptions>; // Optional, defaults to {}
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
export type StringDictionary = { [key: string]: string }
|
|
18
26
|
|
|
19
27
|
export type FormFile = {
|
|
@@ -68,8 +76,13 @@ function isFormFile(script: FormFile | StringDictionary[]): script is FormFile {
|
|
|
68
76
|
return Boolean((script as FormFile).fileContent || (script as FormFile).fileName);
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
export const runProvisioningScript = ({
|
|
80
|
+
script,
|
|
81
|
+
files,
|
|
82
|
+
jahiaServer = serverDefaults,
|
|
83
|
+
options = {log: true},
|
|
84
|
+
requestOptions = {}
|
|
85
|
+
}: RunProvisioningScriptParams): void => {
|
|
73
86
|
const formData = new FormData();
|
|
74
87
|
|
|
75
88
|
if (isFormFile(script)) {
|
|
@@ -123,10 +136,6 @@ export const runProvisioningScript = (script: FormFile | StringDictionary[], fil
|
|
|
123
136
|
...requestOptions
|
|
124
137
|
};
|
|
125
138
|
|
|
126
|
-
if (typeof timeout !== 'undefined') {
|
|
127
|
-
request.timeout = timeout;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
139
|
cy.request(request).then(res => {
|
|
131
140
|
response = res;
|
|
132
141
|
expect(res.status, 'Script result').to.eq(200);
|
|
@@ -14,7 +14,9 @@ declare global {
|
|
|
14
14
|
|
|
15
15
|
export const uninstallBundle = function (bundleSymbolicName: string): void {
|
|
16
16
|
cy.runProvisioningScript({
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
script: {
|
|
18
|
+
fileContent: '- uninstallBundle: "' + bundleSymbolicName + '"\n',
|
|
19
|
+
type: 'application/yaml'
|
|
20
|
+
}
|
|
19
21
|
});
|
|
20
22
|
};
|
package/src/utils/SiteHelper.ts
CHANGED
|
@@ -19,9 +19,12 @@ export const deleteSite = (siteKey: string, jahiaServer?: JahiaServer): void =>
|
|
|
19
19
|
|
|
20
20
|
export const enableModule = (moduleName: string, siteKey: string, jahiaServer?: JahiaServer): void => {
|
|
21
21
|
cy.runProvisioningScript({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
script: {
|
|
23
|
+
fileContent: '- enable: "' + moduleName + '"\n site: "' + siteKey + '"',
|
|
24
|
+
type: 'application/yaml'
|
|
25
|
+
},
|
|
26
|
+
jahiaServer
|
|
27
|
+
});
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
export const disableModule = (moduleName: string, siteKey: string): void => {
|