@jahia/cypress 1.1.1 → 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/{workflows → .github/workflows}/npm_publish.yml +0 -0
- package/.idea/jahia-cypress.iml +9 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/runConfigurations.xml +10 -0
- package/.idea/sonarlint/issuestore/8/9/8995cd54601f633e8bca96b4e0b06ae4272afe02 +3 -0
- package/.idea/sonarlint/issuestore/index.pb +3 -0
- package/.idea/vcs.xml +6 -0
- package/dist/page-object/iframe.d.ts +10 -0
- package/dist/page-object/iframe.js +46 -0
- package/dist/page-object/moonstone/muiinput.d.ts +8 -0
- package/dist/page-object/moonstone/muiinput.js +36 -0
- package/dist/page-object/moonstone/muiradio.d.ts +5 -0
- package/dist/page-object/moonstone/muiradio.js +32 -0
- package/dist/support/apollo/apollo.d.ts +3 -4
- 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 +8 -8
- package/dist/support/provisioning/runProvisioningScript.js +14 -3
- package/dist/support/registerSupport.js +1 -0
- package/dist/support/reloadUntil.d.ts +15 -0
- package/dist/support/reloadUntil.js +50 -0
- package/dist/support/repeatUntil.d.ts +1 -2
- package/dist/support/waitUntil.d.ts +15 -0
- package/dist/support/waitUntil.js +44 -0
- package/jahia-cypress-v1.0.10.tgz +0 -0
- package/jahia-cypress-v1.1.0.tgz +0 -0
- package/package.json +1 -1
- package/src/support/apollo/apollo.ts +3 -3
- package/src/support/provisioning/index.ts +1 -0
- package/src/support/provisioning/installBundle.ts +2 -5
- package/src/support/provisioning/runProvisioningScript.ts +22 -8
- package/src/support/registerSupport.ts +3 -2
- package/src/support/repeatUntil.ts +1 -1
- package/yalc.lock +9 -0
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/jahia-cypress.iml" filepath="$PROJECT_DIR$/.idea/jahia-cypress.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -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>
|
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
import { BaseComponent } from "./baseComponent";
|
|
3
|
+
import Chainable = Cypress.Chainable;
|
|
4
|
+
export declare class IFrame extends BaseComponent {
|
|
5
|
+
static defaultSelector: string;
|
|
6
|
+
private body;
|
|
7
|
+
constructor(element: Chainable<JQuery>, assertion?: (s: JQuery) => void);
|
|
8
|
+
getBody(): Chainable<JQuery>;
|
|
9
|
+
enter(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.IFrame = void 0;
|
|
19
|
+
var baseComponent_1 = require("./baseComponent");
|
|
20
|
+
var IFrame = /** @class */ (function (_super) {
|
|
21
|
+
__extends(IFrame, _super);
|
|
22
|
+
function IFrame(element, assertion) {
|
|
23
|
+
var _this = _super.call(this, element, assertion) || this;
|
|
24
|
+
_this.get()
|
|
25
|
+
.should(function (f) {
|
|
26
|
+
var fr = f[0];
|
|
27
|
+
expect(fr.contentWindow.location.href).not.equals('about:blank');
|
|
28
|
+
expect(fr.contentWindow.document.readyState).equals('complete');
|
|
29
|
+
expect(fr.contentDocument.body).not.be.empty;
|
|
30
|
+
})
|
|
31
|
+
.its('0.contentDocument.body').as('framebody' + _this.id);
|
|
32
|
+
return _this;
|
|
33
|
+
}
|
|
34
|
+
IFrame.prototype.getBody = function () {
|
|
35
|
+
return cy.get('@framebody' + this.id);
|
|
36
|
+
};
|
|
37
|
+
IFrame.prototype.enter = function () {
|
|
38
|
+
this.get().then(function (f) {
|
|
39
|
+
var fr = f[0];
|
|
40
|
+
cy.visit(fr.contentWindow.location.href);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
IFrame.defaultSelector = 'iframe';
|
|
44
|
+
return IFrame;
|
|
45
|
+
}(baseComponent_1.BaseComponent));
|
|
46
|
+
exports.IFrame = IFrame;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
import { BaseComponent } from "../baseComponent";
|
|
3
|
+
import TypeOptions = Cypress.TypeOptions;
|
|
4
|
+
export declare class MUIInput extends BaseComponent {
|
|
5
|
+
static defaultSelector: string;
|
|
6
|
+
clear(): MUIInput;
|
|
7
|
+
type(text: string, options?: Partial<TypeOptions>): MUIInput;
|
|
8
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.MUIInput = void 0;
|
|
19
|
+
var baseComponent_1 = require("../baseComponent");
|
|
20
|
+
var MUIInput = /** @class */ (function (_super) {
|
|
21
|
+
__extends(MUIInput, _super);
|
|
22
|
+
function MUIInput() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
MUIInput.prototype.clear = function () {
|
|
26
|
+
this.get().clear();
|
|
27
|
+
return this;
|
|
28
|
+
};
|
|
29
|
+
MUIInput.prototype.type = function (text, options) {
|
|
30
|
+
this.get().type(text, options);
|
|
31
|
+
return this;
|
|
32
|
+
};
|
|
33
|
+
MUIInput.defaultSelector = 'div';
|
|
34
|
+
return MUIInput;
|
|
35
|
+
}(baseComponent_1.BaseComponent));
|
|
36
|
+
exports.MUIInput = MUIInput;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.MUIRadio = void 0;
|
|
19
|
+
var baseComponent_1 = require("../baseComponent");
|
|
20
|
+
var MUIRadio = /** @class */ (function (_super) {
|
|
21
|
+
__extends(MUIRadio, _super);
|
|
22
|
+
function MUIRadio() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
MUIRadio.prototype.click = function () {
|
|
26
|
+
this.get().click();
|
|
27
|
+
return this;
|
|
28
|
+
};
|
|
29
|
+
MUIRadio.defaultSelector = 'label';
|
|
30
|
+
return MUIRadio;
|
|
31
|
+
}(baseComponent_1.BaseComponent));
|
|
32
|
+
exports.MUIRadio = MUIRadio;
|
|
@@ -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 {};
|
|
@@ -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,23 +2,23 @@
|
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Cypress {
|
|
4
4
|
interface Chainable<Subject> {
|
|
5
|
-
runProvisioningScript(script: FormFile, files?: FormFile[], jahiaServer?: JahiaServer): 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
|
-
[key: string]: string;
|
|
16
|
-
};
|
|
17
|
+
replacements?: StringDictionary;
|
|
17
18
|
};
|
|
18
|
-
declare type JahiaServer = {
|
|
19
|
+
export declare type JahiaServer = {
|
|
19
20
|
url: string;
|
|
20
21
|
username: string;
|
|
21
22
|
password: string;
|
|
22
23
|
};
|
|
23
|
-
export declare const runProvisioningScript: (script: FormFile, files?: FormFile[], jahiaServer?: JahiaServer, options?: Cypress.Loggable) => void;
|
|
24
|
-
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);
|
|
@@ -32,11 +32,22 @@ var serverDefaults = {
|
|
|
32
32
|
username: 'root',
|
|
33
33
|
password: Cypress.env('SUPER_USER_PASSWORD')
|
|
34
34
|
};
|
|
35
|
+
function isFormFile(script) {
|
|
36
|
+
return Boolean(script.fileContent || script.fileName);
|
|
37
|
+
}
|
|
35
38
|
var runProvisioningScript = function (script, files, jahiaServer, options) {
|
|
36
39
|
if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
|
|
37
40
|
if (options === void 0) { options = { log: true }; }
|
|
38
41
|
var formData = new FormData();
|
|
39
|
-
|
|
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
|
+
}
|
|
40
51
|
if (files) {
|
|
41
52
|
files.forEach(function (f) {
|
|
42
53
|
append(f, formData, "file");
|
|
@@ -50,7 +61,7 @@ var runProvisioningScript = function (script, files, jahiaServer, options) {
|
|
|
50
61
|
autoEnd: false,
|
|
51
62
|
name: 'runProvisioningScript',
|
|
52
63
|
displayName: 'provScript',
|
|
53
|
-
message: "Run " + (script.fileName ? script.fileName : 'inline script') + " towards server: " + jahiaServer.url,
|
|
64
|
+
message: "Run " + (isFormFile(script) && script.fileName ? script.fileName : 'inline script') + " towards server: " + jahiaServer.url,
|
|
54
65
|
consoleProps: function () {
|
|
55
66
|
return {
|
|
56
67
|
Script: script,
|
|
@@ -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);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
declare type ReloadUntilOptions = {
|
|
3
|
+
attempts: number;
|
|
4
|
+
reloadCallback: () => void;
|
|
5
|
+
delay: number;
|
|
6
|
+
};
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Cypress {
|
|
9
|
+
interface Chainable<Subject> {
|
|
10
|
+
reloadUntil(selector: string, options: Partial<ReloadUntilOptions>): Chainable<Cypress.Response<any>>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const reloadUntil: (selector: string, options: Partial<ReloadUntilOptions>) => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
exports.__esModule = true;
|
|
15
|
+
exports.reloadUntil = void 0;
|
|
16
|
+
var defaultOptions = {
|
|
17
|
+
attempts: 10,
|
|
18
|
+
reloadCallback: function () { return cy.reload({ log: false }); },
|
|
19
|
+
delay: 1000
|
|
20
|
+
};
|
|
21
|
+
var reloadUntil = function (selector, options) {
|
|
22
|
+
options = __assign(__assign({}, defaultOptions), options);
|
|
23
|
+
var log = Cypress.log({
|
|
24
|
+
name: 'reloadUntil',
|
|
25
|
+
message: "Reload until " + selector + ", remaining attempts : " + options.attempts,
|
|
26
|
+
consoleProps: function () {
|
|
27
|
+
return {
|
|
28
|
+
attempts: options.attempts
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
var items = Cypress.$(selector);
|
|
33
|
+
if (items.length) {
|
|
34
|
+
log.set({ $el: items });
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (options.attempts > 1) {
|
|
38
|
+
log.end();
|
|
39
|
+
options.reloadCallback();
|
|
40
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
41
|
+
cy.wait(options.delay);
|
|
42
|
+
cy.reloadUntil(selector, __assign(__assign({}, options), { attempts: options.attempts - 1 }));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
var err = Error('Items not found.');
|
|
46
|
+
log.error(err);
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.reloadUntil = reloadUntil;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
declare type ReloadUntilOptions = {
|
|
3
|
+
attempts: number;
|
|
4
|
+
reloadCallback: () => void;
|
|
5
|
+
delay: number;
|
|
6
|
+
};
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Cypress {
|
|
9
|
+
interface Chainable<Subject> {
|
|
10
|
+
reloadUntil(selector: string, options: Partial<ReloadUntilOptions>): Chainable<Cypress.Response<any>>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const reloadUntil: (selector: string, options: Partial<ReloadUntilOptions>) => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
exports.__esModule = true;
|
|
15
|
+
exports.reloadUntil = void 0;
|
|
16
|
+
var defaultOptions = {
|
|
17
|
+
attempts: 10,
|
|
18
|
+
reloadCallback: function () { return cy.reload({ log: false }); },
|
|
19
|
+
delay: 1000
|
|
20
|
+
};
|
|
21
|
+
var reloadUntil = function (selector, options) {
|
|
22
|
+
options = __assign(__assign({}, defaultOptions), options);
|
|
23
|
+
var log = Cypress.log({
|
|
24
|
+
name: 'reloadUntil',
|
|
25
|
+
message: "Reload until " + selector + ", remaining attempts : " + options.attempts
|
|
26
|
+
});
|
|
27
|
+
var $items = Cypress.$(selector);
|
|
28
|
+
if ($items.length) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (options.attempts > 1) {
|
|
32
|
+
log.finish();
|
|
33
|
+
options.reloadCallback();
|
|
34
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
35
|
+
cy.wait(1000, { log: false });
|
|
36
|
+
cy.reloadUntil(selector, __assign(__assign({}, options), { attempts: options.attempts - 1 }));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
var err = Error('Items not found.');
|
|
40
|
+
log.error(err);
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.reloadUntil = reloadUntil;
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -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
|
+
}
|
|
@@ -9,20 +9,22 @@ 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[], jahiaServer?: JahiaServer): 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
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
type JahiaServer = {
|
|
27
|
+
export type JahiaServer = {
|
|
26
28
|
url: string;
|
|
27
29
|
username: string;
|
|
28
30
|
password: string
|
|
@@ -40,7 +42,7 @@ function processContent(formFile: FormFile) {
|
|
|
40
42
|
function append(formFile: FormFile, formData: FormData, key: string) {
|
|
41
43
|
if (formFile.fileContent) {
|
|
42
44
|
formData.append(key, processContent(formFile), formFile.fileName);
|
|
43
|
-
} else {
|
|
45
|
+
} else if (formFile.fileName) {
|
|
44
46
|
cy.fixture(formFile.fileName, (formFile.encoding ? formFile.encoding : 'binary')).then(content => {
|
|
45
47
|
if (typeof content === 'object') {
|
|
46
48
|
formFile.fileContent = JSON.stringify(content);
|
|
@@ -58,10 +60,22 @@ const serverDefaults: JahiaServer = {
|
|
|
58
60
|
password: Cypress.env('SUPER_USER_PASSWORD')
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
|
|
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 => {
|
|
62
68
|
const formData = new FormData()
|
|
63
69
|
|
|
64
|
-
|
|
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
|
+
|
|
65
79
|
if (files) {
|
|
66
80
|
files.forEach((f) => {
|
|
67
81
|
append(f, formData, "file")
|
|
@@ -77,7 +91,7 @@ export const runProvisioningScript = (script: FormFile, files?: FormFile[], jahi
|
|
|
77
91
|
autoEnd: false,
|
|
78
92
|
name: 'runProvisioningScript',
|
|
79
93
|
displayName: 'provScript',
|
|
80
|
-
message: `Run ${script.fileName ? script.fileName : 'inline script'} towards server: ${jahiaServer.url}`,
|
|
94
|
+
message: `Run ${isFormFile(script) && script.fileName ? script.fileName : 'inline script'} towards server: ${jahiaServer.url}`,
|
|
81
95
|
consoleProps: () => {
|
|
82
96
|
return {
|
|
83
97
|
Script: script,
|
|
@@ -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
|
+
}
|