@jahia/cypress 1.0.10 → 1.1.2
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/.github/workflows/npm_publish.yml +18 -0
- package/.idea/runConfigurations.xml +10 -0
- package/dist/support/apollo/apollo.d.ts +3 -4
- package/dist/support/provisioning/executeGroovy.d.ts +8 -2
- package/dist/support/provisioning/executeGroovy.js +8 -2
- package/dist/support/provisioning/index.d.ts +1 -0
- package/dist/support/provisioning/index.js +1 -0
- package/dist/support/provisioning/installBundle.js +1 -4
- package/dist/support/provisioning/runProvisioningScript.d.ts +12 -7
- package/dist/support/provisioning/runProvisioningScript.js +24 -7
- package/dist/support/registerSupport.js +1 -0
- package/dist/support/repeatUntil.d.ts +1 -2
- package/jahia-cypress-v1.0.10.tgz +0 -0
- package/jahia-cypress-v1.1.0.tgz +0 -0
- package/package.json +2 -2
- package/src/support/apollo/apollo.ts +3 -3
- package/src/support/provisioning/executeGroovy.md +9 -0
- package/src/support/provisioning/executeGroovy.ts +15 -3
- package/src/support/provisioning/index.ts +1 -0
- package/src/support/provisioning/installBundle.ts +2 -5
- package/src/support/provisioning/runProvisioningScript.md +9 -0
- package/src/support/provisioning/runProvisioningScript.ts +36 -10
- package/src/support/registerSupport.ts +3 -2
- package/src/support/repeatUntil.ts +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Publish Package to npmjs
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [created]
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v2
|
|
10
|
+
# Setup .npmrc file to publish to npm
|
|
11
|
+
- uses: actions/setup-node@v2
|
|
12
|
+
with:
|
|
13
|
+
node-version: '16.x'
|
|
14
|
+
registry-url: 'https://registry.npmjs.org'
|
|
15
|
+
- run: npm run build
|
|
16
|
+
- run: npm publish --access public
|
|
17
|
+
env:
|
|
18
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="RunConfigurationProducerService">
|
|
4
|
+
<option name="ignoredProducers">
|
|
5
|
+
<set>
|
|
6
|
+
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
7
|
+
</set>
|
|
8
|
+
</option>
|
|
9
|
+
</component>
|
|
10
|
+
</project>
|
|
@@ -7,12 +7,11 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
declare type FileQueryOptions = Partial<QueryOptions> & {
|
|
10
|
+
export declare type FileQueryOptions = Partial<QueryOptions> & {
|
|
11
11
|
queryFile?: string;
|
|
12
12
|
};
|
|
13
|
-
declare type FileMutationOptions = Partial<MutationOptions> & {
|
|
13
|
+
export declare type FileMutationOptions = Partial<MutationOptions> & {
|
|
14
14
|
mutationFile?: string;
|
|
15
15
|
};
|
|
16
|
-
declare type ApolloOptions = (QueryOptions | MutationOptions | FileQueryOptions | FileMutationOptions) & Partial<Cypress.Loggable>;
|
|
16
|
+
export declare type ApolloOptions = (QueryOptions | MutationOptions | FileQueryOptions | FileMutationOptions) & Partial<Cypress.Loggable>;
|
|
17
17
|
export declare const apollo: (apollo: ApolloClient<any>, options: ApolloOptions) => void;
|
|
18
|
-
export {};
|
|
@@ -3,10 +3,16 @@ declare global {
|
|
|
3
3
|
interface Chainable<Subject> {
|
|
4
4
|
executeGroovy(scriptFile: string, replacements?: {
|
|
5
5
|
[key: string]: string;
|
|
6
|
-
}): Chainable<any>;
|
|
6
|
+
}, jahiaServer?: JahiaServer): Chainable<any>;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
declare type JahiaServer = {
|
|
11
|
+
url: string;
|
|
12
|
+
username: string;
|
|
13
|
+
password: string;
|
|
14
|
+
};
|
|
10
15
|
export declare const executeGroovy: (scriptFile: string, replacements?: {
|
|
11
16
|
[key: string]: string;
|
|
12
|
-
}) => void;
|
|
17
|
+
}, jahiaServer?: JahiaServer) => void;
|
|
18
|
+
export {};
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.executeGroovy = void 0;
|
|
5
5
|
/// <reference types="cypress" />
|
|
6
|
-
var
|
|
6
|
+
var serverDefaults = {
|
|
7
|
+
url: Cypress.config().baseUrl,
|
|
8
|
+
username: 'root',
|
|
9
|
+
password: Cypress.env('SUPER_USER_PASSWORD')
|
|
10
|
+
};
|
|
11
|
+
var executeGroovy = function (scriptFile, replacements, jahiaServer) {
|
|
12
|
+
if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
|
|
7
13
|
cy.runProvisioningScript({
|
|
8
14
|
fileContent: '- executeScript: "' + scriptFile + '"',
|
|
9
15
|
type: 'application/yaml'
|
|
@@ -11,6 +17,6 @@ var executeGroovy = function (scriptFile, replacements) {
|
|
|
11
17
|
fileName: scriptFile,
|
|
12
18
|
replacements: replacements,
|
|
13
19
|
type: 'text/plain'
|
|
14
|
-
}]).then(function (r) { return r[0]; });
|
|
20
|
+
}], jahiaServer).then(function (r) { return r[0]; });
|
|
15
21
|
};
|
|
16
22
|
exports.executeGroovy = executeGroovy;
|
|
@@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
exports.__esModule = true;
|
|
13
13
|
__exportStar(require("./executeGroovy"), exports);
|
|
14
14
|
__exportStar(require("./runProvisioningScript"), exports);
|
|
15
|
+
__exportStar(require("./installBundle"), exports);
|
|
@@ -4,10 +4,7 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.installBundle = void 0;
|
|
5
5
|
/// <reference types="cypress" />
|
|
6
6
|
var installBundle = function (bundleFile) {
|
|
7
|
-
cy.runProvisioningScript({
|
|
8
|
-
fileContent: '- installBundle: "' + bundleFile + '"',
|
|
9
|
-
type: 'application/yaml'
|
|
10
|
-
}, [{
|
|
7
|
+
cy.runProvisioningScript([{ installBundle: bundleFile }], [{
|
|
11
8
|
fileName: bundleFile,
|
|
12
9
|
type: 'text/plain'
|
|
13
10
|
}]);
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Cypress {
|
|
4
4
|
interface Chainable<Subject> {
|
|
5
|
-
runProvisioningScript(script: FormFile, files?: FormFile[]): Chainable<any>;
|
|
5
|
+
runProvisioningScript(script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer): Chainable<any>;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
declare type
|
|
9
|
+
export declare type StringDictionary = {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type FormFile = {
|
|
10
13
|
fileName?: string;
|
|
11
14
|
fileContent?: string;
|
|
12
15
|
type?: string;
|
|
13
16
|
encoding?: Cypress.Encodings;
|
|
14
|
-
replacements?:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
replacements?: StringDictionary;
|
|
18
|
+
};
|
|
19
|
+
export declare type JahiaServer = {
|
|
20
|
+
url: string;
|
|
21
|
+
username: string;
|
|
22
|
+
password: string;
|
|
17
23
|
};
|
|
18
|
-
export declare const runProvisioningScript: (script: FormFile, files?: FormFile[], options?: Cypress.Loggable) => void;
|
|
19
|
-
export {};
|
|
24
|
+
export declare const runProvisioningScript: (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable) => void;
|
|
@@ -15,7 +15,7 @@ function append(formFile, formData, key) {
|
|
|
15
15
|
if (formFile.fileContent) {
|
|
16
16
|
formData.append(key, processContent(formFile), formFile.fileName);
|
|
17
17
|
}
|
|
18
|
-
else {
|
|
18
|
+
else if (formFile.fileName) {
|
|
19
19
|
cy.fixture(formFile.fileName, (formFile.encoding ? formFile.encoding : 'binary')).then(function (content) {
|
|
20
20
|
if (typeof content === 'object') {
|
|
21
21
|
formFile.fileContent = JSON.stringify(content);
|
|
@@ -27,10 +27,27 @@ function append(formFile, formData, key) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
var
|
|
30
|
+
var serverDefaults = {
|
|
31
|
+
url: Cypress.config().baseUrl,
|
|
32
|
+
username: 'root',
|
|
33
|
+
password: Cypress.env('SUPER_USER_PASSWORD')
|
|
34
|
+
};
|
|
35
|
+
function isFormFile(script) {
|
|
36
|
+
return Boolean(script.fileContent || script.fileName);
|
|
37
|
+
}
|
|
38
|
+
var runProvisioningScript = function (script, files, jahiaServer, options) {
|
|
39
|
+
if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
|
|
31
40
|
if (options === void 0) { options = { log: true }; }
|
|
32
41
|
var formData = new FormData();
|
|
33
|
-
|
|
42
|
+
if (isFormFile(script)) {
|
|
43
|
+
append(script, formData, "script");
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
append({
|
|
47
|
+
fileContent: JSON.stringify(script),
|
|
48
|
+
type: 'application/json'
|
|
49
|
+
}, formData, "script");
|
|
50
|
+
}
|
|
34
51
|
if (files) {
|
|
35
52
|
files.forEach(function (f) {
|
|
36
53
|
append(f, formData, "file");
|
|
@@ -44,7 +61,7 @@ var runProvisioningScript = function (script, files, options) {
|
|
|
44
61
|
autoEnd: false,
|
|
45
62
|
name: 'runProvisioningScript',
|
|
46
63
|
displayName: 'provScript',
|
|
47
|
-
message: "Run " + (script.fileName ? script.fileName : 'inline script'),
|
|
64
|
+
message: "Run " + (isFormFile(script) && script.fileName ? script.fileName : 'inline script') + " towards server: " + jahiaServer.url,
|
|
48
65
|
consoleProps: function () {
|
|
49
66
|
return {
|
|
50
67
|
Script: script,
|
|
@@ -56,11 +73,11 @@ var runProvisioningScript = function (script, files, options) {
|
|
|
56
73
|
});
|
|
57
74
|
}
|
|
58
75
|
cy.request({
|
|
59
|
-
url:
|
|
76
|
+
url: jahiaServer.url + "/modules/api/provisioning",
|
|
60
77
|
method: 'POST',
|
|
61
78
|
auth: {
|
|
62
|
-
user:
|
|
63
|
-
pass:
|
|
79
|
+
user: jahiaServer.username,
|
|
80
|
+
pass: jahiaServer.password,
|
|
64
81
|
sendImmediately: true
|
|
65
82
|
},
|
|
66
83
|
body: formData,
|
|
@@ -16,6 +16,7 @@ var registerSupport = function () {
|
|
|
16
16
|
Cypress.Commands.add('apollo', { prevSubject: 'optional' }, apollo_1.apollo);
|
|
17
17
|
Cypress.Commands.add('runProvisioningScript', provisioning_1.runProvisioningScript);
|
|
18
18
|
Cypress.Commands.add('executeGroovy', provisioning_1.executeGroovy);
|
|
19
|
+
Cypress.Commands.add('installBundle', provisioning_1.installBundle);
|
|
19
20
|
Cypress.Commands.add('login', login_1.login);
|
|
20
21
|
Cypress.Commands.add('logout', logout_1.logout);
|
|
21
22
|
Cypress.Commands.add('repeatUntil', repeatUntil_1.repeatUntil);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
-
declare type RepeatUntilOptions = {
|
|
2
|
+
export declare type RepeatUntilOptions = {
|
|
3
3
|
attempts: number;
|
|
4
4
|
callback: () => void;
|
|
5
5
|
delay: number;
|
|
@@ -12,4 +12,3 @@ declare global {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export declare const repeatUntil: (selector: string, options?: Partial<RepeatUntilOptions>) => void;
|
|
15
|
-
export {};
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jahia/cypress",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsc",
|
|
6
6
|
"lint": "eslint src -c .eslintrc.json --ext .ts"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@apollo/client": "^3.4.9",
|
|
21
|
-
"cypress-terminal-report": "^3.
|
|
21
|
+
"cypress-terminal-report": "^3.4.2",
|
|
22
22
|
"graphql": "^15.5.0",
|
|
23
23
|
"graphql-tag": "^2.11.0"
|
|
24
24
|
}
|
|
@@ -15,9 +15,9 @@ declare global {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
type FileQueryOptions = Partial<QueryOptions> & { queryFile?: string }
|
|
19
|
-
type FileMutationOptions = Partial<MutationOptions> & { mutationFile?: string }
|
|
20
|
-
type ApolloOptions = (QueryOptions | MutationOptions | FileQueryOptions | FileMutationOptions) & Partial<Cypress.Loggable>;
|
|
18
|
+
export type FileQueryOptions = Partial<QueryOptions> & { queryFile?: string }
|
|
19
|
+
export type FileMutationOptions = Partial<MutationOptions> & { mutationFile?: string }
|
|
20
|
+
export type ApolloOptions = (QueryOptions | MutationOptions | FileQueryOptions | FileMutationOptions) & Partial<Cypress.Loggable>;
|
|
21
21
|
|
|
22
22
|
function isQuery(options: ApolloOptions): options is QueryOptions {
|
|
23
23
|
return (<QueryOptions>options).query !== undefined;
|
|
@@ -10,6 +10,7 @@ This commands execute a groovy script from fixtures folder
|
|
|
10
10
|
|
|
11
11
|
```
|
|
12
12
|
cy.executeGroovy('script.groovy')
|
|
13
|
+
cy.executeGroovy('script.groovy', null, {url: 'http://jahia-processing.jahia.net:8080', username: 'root', password: 'root1234'})
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
### Arguments
|
|
@@ -18,6 +19,14 @@ cy.executeGroovy('script.groovy')
|
|
|
18
19
|
|
|
19
20
|
The name of the script file, in fixtures folder
|
|
20
21
|
|
|
22
|
+
#### > jahiaServer (`JahiaServer`)
|
|
23
|
+
|
|
24
|
+
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 (for example a processig node).
|
|
25
|
+
|
|
26
|
+
- url: (`string`) : The url of the server (for example: http://processing.jahia.net:8080)
|
|
27
|
+
- username: (`string`) : Root user
|
|
28
|
+
- password: (`string`) : Password for the root user
|
|
29
|
+
|
|
21
30
|
### Yields
|
|
22
31
|
|
|
23
32
|
The groovy script result (set with `setResult()` within groovy code)
|
|
@@ -9,12 +9,24 @@ declare global {
|
|
|
9
9
|
namespace Cypress {
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
11
|
interface Chainable<Subject> {
|
|
12
|
-
executeGroovy(scriptFile: string, replacements?: { [key: string]: string }): Chainable<any>
|
|
12
|
+
executeGroovy(scriptFile: string, replacements?: { [key: string]: string }, jahiaServer?: JahiaServer): Chainable<any>
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
type JahiaServer = {
|
|
18
|
+
url: string;
|
|
19
|
+
username: string;
|
|
20
|
+
password: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const serverDefaults = {
|
|
24
|
+
url: Cypress.config().baseUrl,
|
|
25
|
+
username: 'root',
|
|
26
|
+
password: Cypress.env('SUPER_USER_PASSWORD')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const executeGroovy = function (scriptFile: string, replacements?: { [key: string]: string }, jahiaServer: JahiaServer = serverDefaults): void {
|
|
18
30
|
cy.runProvisioningScript({
|
|
19
31
|
fileContent: '- executeScript: "' + scriptFile + '"',
|
|
20
32
|
type: 'application/yaml'
|
|
@@ -22,5 +34,5 @@ export const executeGroovy = function (scriptFile: string, replacements?: { [key
|
|
|
22
34
|
fileName: scriptFile,
|
|
23
35
|
replacements,
|
|
24
36
|
type: 'text/plain'
|
|
25
|
-
}]).then(r => r[0])
|
|
37
|
+
}], jahiaServer).then(r => r[0])
|
|
26
38
|
}
|
|
@@ -15,11 +15,8 @@ declare global {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const installBundle = function (bundleFile: string): void {
|
|
18
|
-
cy.runProvisioningScript({
|
|
19
|
-
fileContent: '- installBundle: "' + bundleFile + '"',
|
|
20
|
-
type: 'application/yaml'
|
|
21
|
-
}, [{
|
|
18
|
+
cy.runProvisioningScript([{ installBundle: bundleFile }], [{
|
|
22
19
|
fileName: bundleFile,
|
|
23
20
|
type: 'text/plain'
|
|
24
21
|
}])
|
|
25
|
-
}
|
|
22
|
+
}
|
|
@@ -12,6 +12,7 @@ This commands execute a provisioning script
|
|
|
12
12
|
cy.runProvisioningScript({fileName:'prov.yaml', type:'application/yaml'})
|
|
13
13
|
cy.runProvisioningScript({fileName:'prov.yaml', type:'application/yaml'}, [{fileName: 'file1.zip'}])
|
|
14
14
|
cy.runProvisioningScript({fileContent:'- startBundle: "module"', type:'application/yaml'})
|
|
15
|
+
cy.runProvisioningScript({fileContent:'- startBundle: "module"', type:'application/yaml'}, null, {url: 'http://jahia-processing.jahia.net:8080', username: 'root', password: 'root1234'})
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
### Arguments
|
|
@@ -24,6 +25,14 @@ The script can be specified either from an external file (using fileName) or inl
|
|
|
24
25
|
- fileContent: (`string`) : The content of the script. If specified, fileName is ignored.
|
|
25
26
|
- type: (`string`) : Content type, either `application/yaml` or `application/json`
|
|
26
27
|
|
|
28
|
+
#### > jahiaServer (`JahiaServer`)
|
|
29
|
+
|
|
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 (for example a processig node).
|
|
31
|
+
|
|
32
|
+
- url: (`string`) : The url of the server (for example: http://processing.jahia.net:8080)
|
|
33
|
+
- username: (`string`) : Root user
|
|
34
|
+
- password: (`string`) : Password for the root user
|
|
35
|
+
|
|
27
36
|
#### > files (`FormFile[]`)
|
|
28
37
|
|
|
29
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
|
|
@@ -9,17 +9,25 @@ declare global {
|
|
|
9
9
|
namespace Cypress {
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
11
|
interface Chainable<Subject> {
|
|
12
|
-
runProvisioningScript(script: FormFile, files?: FormFile[]): Chainable<any>
|
|
12
|
+
runProvisioningScript(script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer): Chainable<any>
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
type
|
|
17
|
+
export type StringDictionary = { [key: string]: string }
|
|
18
|
+
|
|
19
|
+
export type FormFile = {
|
|
18
20
|
fileName?: string,
|
|
19
21
|
fileContent?: string,
|
|
20
22
|
type?: string,
|
|
21
23
|
encoding?: Cypress.Encodings
|
|
22
|
-
replacements?:
|
|
24
|
+
replacements?: StringDictionary
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type JahiaServer = {
|
|
28
|
+
url: string;
|
|
29
|
+
username: string;
|
|
30
|
+
password: string
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
function processContent(formFile: FormFile) {
|
|
@@ -34,7 +42,7 @@ function processContent(formFile: FormFile) {
|
|
|
34
42
|
function append(formFile: FormFile, formData: FormData, key: string) {
|
|
35
43
|
if (formFile.fileContent) {
|
|
36
44
|
formData.append(key, processContent(formFile), formFile.fileName);
|
|
37
|
-
} else {
|
|
45
|
+
} else if (formFile.fileName) {
|
|
38
46
|
cy.fixture(formFile.fileName, (formFile.encoding ? formFile.encoding : 'binary')).then(content => {
|
|
39
47
|
if (typeof content === 'object') {
|
|
40
48
|
formFile.fileContent = JSON.stringify(content);
|
|
@@ -46,10 +54,28 @@ function append(formFile: FormFile, formData: FormData, key: string) {
|
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
|
|
57
|
+
const serverDefaults: JahiaServer = {
|
|
58
|
+
url: Cypress.config().baseUrl,
|
|
59
|
+
username: 'root',
|
|
60
|
+
password: Cypress.env('SUPER_USER_PASSWORD')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isFormFile(script: FormFile | StringDictionary[]): script is FormFile {
|
|
64
|
+
return Boolean((script as FormFile).fileContent || (script as FormFile).fileName);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log:true}): void => {
|
|
50
68
|
const formData = new FormData()
|
|
51
69
|
|
|
52
|
-
|
|
70
|
+
if (isFormFile(script)) {
|
|
71
|
+
append(script, formData, "script")
|
|
72
|
+
} else {
|
|
73
|
+
append({
|
|
74
|
+
fileContent: JSON.stringify(script),
|
|
75
|
+
type: 'application/json'
|
|
76
|
+
}, formData, "script");
|
|
77
|
+
}
|
|
78
|
+
|
|
53
79
|
if (files) {
|
|
54
80
|
files.forEach((f) => {
|
|
55
81
|
append(f, formData, "file")
|
|
@@ -65,7 +91,7 @@ export const runProvisioningScript = (script: FormFile, files?: FormFile[], opti
|
|
|
65
91
|
autoEnd: false,
|
|
66
92
|
name: 'runProvisioningScript',
|
|
67
93
|
displayName: 'provScript',
|
|
68
|
-
message: `Run ${script.fileName ? script.fileName : 'inline script'}`,
|
|
94
|
+
message: `Run ${isFormFile(script) && script.fileName ? script.fileName : 'inline script'} towards server: ${jahiaServer.url}`,
|
|
69
95
|
consoleProps: () => {
|
|
70
96
|
return {
|
|
71
97
|
Script: script,
|
|
@@ -78,11 +104,11 @@ export const runProvisioningScript = (script: FormFile, files?: FormFile[], opti
|
|
|
78
104
|
}
|
|
79
105
|
|
|
80
106
|
cy.request({
|
|
81
|
-
url: `${
|
|
107
|
+
url: `${jahiaServer.url}/modules/api/provisioning`,
|
|
82
108
|
method: 'POST',
|
|
83
109
|
auth: {
|
|
84
|
-
user:
|
|
85
|
-
pass:
|
|
110
|
+
user: jahiaServer.username,
|
|
111
|
+
pass: jahiaServer.password,
|
|
86
112
|
sendImmediately: true,
|
|
87
113
|
},
|
|
88
114
|
body: formData,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {apollo, apolloClient} from "./apollo"
|
|
2
|
-
import {executeGroovy, runProvisioningScript} from "./provisioning"
|
|
2
|
+
import {executeGroovy, runProvisioningScript, installBundle} from "./provisioning"
|
|
3
3
|
import {login} from "./login"
|
|
4
4
|
import {logout} from "./logout"
|
|
5
5
|
import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector'
|
|
@@ -12,6 +12,7 @@ export const registerSupport = (): void => {
|
|
|
12
12
|
|
|
13
13
|
Cypress.Commands.add('runProvisioningScript', runProvisioningScript)
|
|
14
14
|
Cypress.Commands.add('executeGroovy', executeGroovy)
|
|
15
|
+
Cypress.Commands.add('installBundle', installBundle)
|
|
15
16
|
|
|
16
17
|
Cypress.Commands.add('login', login)
|
|
17
18
|
Cypress.Commands.add('logout', logout)
|
|
@@ -20,4 +21,4 @@ export const registerSupport = (): void => {
|
|
|
20
21
|
Cypress.Commands.overwrite('fixture', fixture)
|
|
21
22
|
|
|
22
23
|
installLogsCollector()
|
|
23
|
-
}
|
|
24
|
+
}
|