@jahia/cypress 1.1.3 → 1.1.5
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/apollo/apollo.js +14 -7
- package/dist/support/fixture.js +1 -1
- package/dist/support/provisioning/runProvisioningScript.d.ts +1 -1
- package/dist/support/provisioning/runProvisioningScript.js +7 -5
- package/package.json +1 -1
- package/src/support/apollo/apollo.ts +14 -7
- package/src/support/fixture.ts +1 -1
- package/src/support/provisioning/runProvisioningScript.ts +11 -3
- package/jahia-cypress.iml +0 -11
|
@@ -43,24 +43,25 @@ var apollo = function (apollo, options) {
|
|
|
43
43
|
}
|
|
44
44
|
var result;
|
|
45
45
|
var logger;
|
|
46
|
+
var optionsWithDefaultCache = __assign({ fetchPolicy: "no-cache" }, options);
|
|
46
47
|
if (!apollo) {
|
|
47
|
-
cy.apolloClient().apollo(
|
|
48
|
+
cy.apolloClient().apollo(optionsWithDefaultCache);
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
|
-
if (isQueryFile(
|
|
51
|
-
var queryFile =
|
|
51
|
+
if (isQueryFile(optionsWithDefaultCache)) {
|
|
52
|
+
var queryFile = optionsWithDefaultCache.queryFile, apolloOptions_1 = __rest(optionsWithDefaultCache, ["queryFile"]);
|
|
52
53
|
cy.fixture(queryFile).then(function (content) {
|
|
53
54
|
cy.apollo(__assign({ query: graphql_tag_1["default"](content) }, apolloOptions_1));
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
else if (isMutationFile(
|
|
57
|
-
var mutationFile =
|
|
57
|
+
else if (isMutationFile(optionsWithDefaultCache)) {
|
|
58
|
+
var mutationFile = optionsWithDefaultCache.mutationFile, apolloOptions_2 = __rest(optionsWithDefaultCache, ["mutationFile"]);
|
|
58
59
|
cy.fixture(mutationFile).then(function (content) {
|
|
59
60
|
cy.apollo(__assign({ mutation: graphql_tag_1["default"](content) }, apolloOptions_2));
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
else {
|
|
63
|
-
var _a =
|
|
64
|
+
var _a = optionsWithDefaultCache.log, log = _a === void 0 ? true : _a, apolloOptions_3 = __rest(optionsWithDefaultCache, ["log"]);
|
|
64
65
|
if (log) {
|
|
65
66
|
logger = Cypress.log({
|
|
66
67
|
autoEnd: false,
|
|
@@ -76,7 +77,13 @@ var apollo = function (apollo, options) {
|
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
cy.wrap({}, { log: false })
|
|
79
|
-
.then(function () { return (isQuery(
|
|
80
|
+
.then(function () { return (isQuery(optionsWithDefaultCache) ? apollo.query(optionsWithDefaultCache)["catch"](function (error) {
|
|
81
|
+
cy.log("Caught Graphql Query Error: " + JSON.stringify(error));
|
|
82
|
+
return error;
|
|
83
|
+
}) : apollo.mutate(optionsWithDefaultCache)["catch"](function (error) {
|
|
84
|
+
cy.log("Caught Graphql Mutation Error: " + JSON.stringify(error));
|
|
85
|
+
return error;
|
|
86
|
+
}))
|
|
80
87
|
.then(function (r) {
|
|
81
88
|
result = r;
|
|
82
89
|
logger === null || logger === void 0 ? void 0 : logger.end();
|
package/dist/support/fixture.js
CHANGED
|
@@ -25,7 +25,7 @@ var fixture = function (originalCommand, fixture) {
|
|
|
25
25
|
encoding = args[0];
|
|
26
26
|
}
|
|
27
27
|
try {
|
|
28
|
-
cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, { log: false, timeout:
|
|
28
|
+
cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, { log: false, timeout: 200 });
|
|
29
29
|
}
|
|
30
30
|
catch (e) {
|
|
31
31
|
console.log(e);
|
|
@@ -21,4 +21,4 @@ export declare type JahiaServer = {
|
|
|
21
21
|
username: string;
|
|
22
22
|
password: string;
|
|
23
23
|
};
|
|
24
|
-
export declare const runProvisioningScript: (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable) => void;
|
|
24
|
+
export declare const runProvisioningScript: (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable, timeout?: number) => void;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
3
2
|
exports.__esModule = true;
|
|
4
3
|
exports.runProvisioningScript = void 0;
|
|
5
|
-
/// <reference types="cypress" />
|
|
6
4
|
function processContent(formFile) {
|
|
7
5
|
var content = formFile.fileContent;
|
|
8
6
|
if (formFile.replacements) {
|
|
@@ -35,7 +33,7 @@ var serverDefaults = {
|
|
|
35
33
|
function isFormFile(script) {
|
|
36
34
|
return Boolean(script.fileContent || script.fileName);
|
|
37
35
|
}
|
|
38
|
-
var runProvisioningScript = function (script, files, jahiaServer, options) {
|
|
36
|
+
var runProvisioningScript = function (script, files, jahiaServer, options, timeout) {
|
|
39
37
|
if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
|
|
40
38
|
if (options === void 0) { options = { log: true }; }
|
|
41
39
|
var formData = new FormData();
|
|
@@ -72,7 +70,7 @@ var runProvisioningScript = function (script, files, jahiaServer, options) {
|
|
|
72
70
|
}
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
|
-
|
|
73
|
+
var request = {
|
|
76
74
|
url: jahiaServer.url + "/modules/api/provisioning",
|
|
77
75
|
method: 'POST',
|
|
78
76
|
auth: {
|
|
@@ -82,7 +80,11 @@ var runProvisioningScript = function (script, files, jahiaServer, options) {
|
|
|
82
80
|
},
|
|
83
81
|
body: formData,
|
|
84
82
|
log: false
|
|
85
|
-
}
|
|
83
|
+
};
|
|
84
|
+
if (typeof timeout !== 'undefined') {
|
|
85
|
+
request.timeout = timeout;
|
|
86
|
+
}
|
|
87
|
+
cy.request(request).then(function (res) {
|
|
86
88
|
response = res;
|
|
87
89
|
expect(res.status, 'Script result').to.eq(200);
|
|
88
90
|
try {
|
package/package.json
CHANGED
|
@@ -38,22 +38,23 @@ export const apollo = function (apollo: ApolloClient<any>, options: ApolloOption
|
|
|
38
38
|
|
|
39
39
|
let result : ApolloQueryResult<any> | FetchResult
|
|
40
40
|
let logger : Cypress.Log
|
|
41
|
+
const optionsWithDefaultCache: ApolloOptions = {fetchPolicy: "no-cache", ...options}
|
|
41
42
|
|
|
42
43
|
if (!apollo) {
|
|
43
|
-
cy.apolloClient().apollo(
|
|
44
|
+
cy.apolloClient().apollo(optionsWithDefaultCache)
|
|
44
45
|
} else {
|
|
45
|
-
if (isQueryFile(
|
|
46
|
-
const {queryFile, ...apolloOptions} =
|
|
46
|
+
if (isQueryFile(optionsWithDefaultCache)) {
|
|
47
|
+
const {queryFile, ...apolloOptions} = optionsWithDefaultCache
|
|
47
48
|
cy.fixture(queryFile).then(content => {
|
|
48
49
|
cy.apollo({query: gql(content), ...apolloOptions})
|
|
49
50
|
})
|
|
50
|
-
} else if (isMutationFile(
|
|
51
|
-
const {mutationFile, ...apolloOptions} =
|
|
51
|
+
} else if (isMutationFile(optionsWithDefaultCache)) {
|
|
52
|
+
const {mutationFile, ...apolloOptions} = optionsWithDefaultCache
|
|
52
53
|
cy.fixture(mutationFile).then(content => {
|
|
53
54
|
cy.apollo({mutation: gql(content), ...apolloOptions})
|
|
54
55
|
})
|
|
55
56
|
} else {
|
|
56
|
-
const {log = true, ...apolloOptions} =
|
|
57
|
+
const {log = true, ...apolloOptions} = optionsWithDefaultCache
|
|
57
58
|
if (log) {
|
|
58
59
|
logger = Cypress.log({
|
|
59
60
|
autoEnd: false,
|
|
@@ -70,7 +71,13 @@ export const apollo = function (apollo: ApolloClient<any>, options: ApolloOption
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
cy.wrap({}, {log: false})
|
|
73
|
-
.then(() => (isQuery(
|
|
74
|
+
.then(() => (isQuery(optionsWithDefaultCache) ? apollo.query(optionsWithDefaultCache).catch(error => {
|
|
75
|
+
cy.log(`Caught Graphql Query Error: ${JSON.stringify(error)}`);
|
|
76
|
+
return error;
|
|
77
|
+
}) : apollo.mutate(optionsWithDefaultCache).catch(error => {
|
|
78
|
+
cy.log(`Caught Graphql Mutation Error: ${JSON.stringify(error)}`);
|
|
79
|
+
return error;
|
|
80
|
+
}))
|
|
74
81
|
.then(r => {
|
|
75
82
|
result = r
|
|
76
83
|
logger?.end()
|
package/src/support/fixture.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const fixture = function(originalCommand: ((...args: any[]) => any), fixt
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
|
-
cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, {log: false, timeout:
|
|
19
|
+
cy.readFile('./node_modules/@jahia/cypress/fixtures/' + fixture, encoding, {log: false, timeout: 200})
|
|
20
20
|
} catch (e) {
|
|
21
21
|
console.log(e)
|
|
22
22
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
2
|
+
import RequestOptions = Cypress.RequestOptions;
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
// Load type definitions that come with Cypress module
|
|
4
6
|
/// <reference types="cypress" />
|
|
@@ -64,7 +66,7 @@ function isFormFile(script: FormFile | StringDictionary[]): script is FormFile {
|
|
|
64
66
|
return Boolean((script as FormFile).fileContent || (script as FormFile).fileName);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log:true}): void => {
|
|
69
|
+
export const runProvisioningScript = (script: FormFile | StringDictionary[], files?: FormFile[], jahiaServer: JahiaServer = serverDefaults, options: Cypress.Loggable = {log:true}, timeout?: number): void => {
|
|
68
70
|
const formData = new FormData()
|
|
69
71
|
|
|
70
72
|
if (isFormFile(script)) {
|
|
@@ -103,7 +105,7 @@ export const runProvisioningScript = (script: FormFile | StringDictionary[], fil
|
|
|
103
105
|
})
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
|
|
108
|
+
const request: Partial<RequestOptions> = {
|
|
107
109
|
url: `${jahiaServer.url}/modules/api/provisioning`,
|
|
108
110
|
method: 'POST',
|
|
109
111
|
auth: {
|
|
@@ -113,7 +115,13 @@ export const runProvisioningScript = (script: FormFile | StringDictionary[], fil
|
|
|
113
115
|
},
|
|
114
116
|
body: formData,
|
|
115
117
|
log: false
|
|
116
|
-
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if(typeof timeout !== 'undefined'){
|
|
121
|
+
request.timeout = timeout
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
cy.request(request).then(res => {
|
|
117
125
|
response = res
|
|
118
126
|
expect(res.status, 'Script result').to.eq(200)
|
|
119
127
|
try {
|
package/jahia-cypress.iml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$">
|
|
6
|
-
<sourceFolder url="file://$MODULE_DIR$/fixtures/groovy/admin" isTestSource="false" />
|
|
7
|
-
</content>
|
|
8
|
-
<orderEntry type="inheritedJdk" />
|
|
9
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
-
</component>
|
|
11
|
-
</module>
|