@jahia/cypress 8.0.0 → 8.1.1

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +65 -0
  3. package/dist/injections/bash-data.d.ts +1 -0
  4. package/dist/injections/bash-data.js +57 -0
  5. package/dist/injections/chars-data.d.ts +1 -0
  6. package/dist/injections/chars-data.js +25 -0
  7. package/dist/injections/htmlentities-data.d.ts +1 -0
  8. package/dist/injections/htmlentities-data.js +22 -0
  9. package/dist/injections/numbers-data.d.ts +1 -0
  10. package/dist/injections/numbers-data.js +66 -0
  11. package/dist/injections/sql-data.d.ts +1 -0
  12. package/dist/injections/sql-data.js +82 -0
  13. package/dist/injections/xss-data.d.ts +1 -0
  14. package/dist/injections/xss-data.js +740 -0
  15. package/dist/support/apollo/apollo.d.ts +2 -0
  16. package/dist/support/apollo/apollo.js +77 -15
  17. package/dist/support/browserHelper.d.ts +10 -0
  18. package/dist/support/browserHelper.js +167 -0
  19. package/dist/support/index.d.ts +3 -0
  20. package/dist/support/index.js +3 -0
  21. package/dist/support/jfaker.d.ts +60 -0
  22. package/dist/support/jfaker.js +241 -0
  23. package/dist/support/modSince.d.ts +52 -0
  24. package/dist/support/modSince.js +185 -0
  25. package/dist/support/provisioning/executeGroovy.js +41 -2
  26. package/dist/support/provisioning/runProvisioningScript.d.ts +1 -1
  27. package/dist/support/provisioning/runProvisioningScript.js +84 -7
  28. package/dist/support/registerSupport.js +34 -0
  29. package/dist/utils/JahiaPlatformHelper.d.ts +9 -0
  30. package/dist/utils/JahiaPlatformHelper.js +17 -6
  31. package/docs/browser-helper.md +158 -0
  32. package/docs/jfaker.md +450 -0
  33. package/package.json +3 -1
  34. package/src/injections/bash-data.ts +54 -0
  35. package/src/injections/chars-data.ts +22 -0
  36. package/src/injections/htmlentities-data.ts +19 -0
  37. package/src/injections/numbers-data.ts +63 -0
  38. package/src/injections/sql-data.ts +79 -0
  39. package/src/injections/xss-data.ts +737 -0
  40. package/src/support/apollo/apollo.ts +74 -11
  41. package/src/support/browserHelper.ts +186 -0
  42. package/src/support/index.ts +3 -0
  43. package/src/support/jfaker.ts +245 -0
  44. package/src/support/modSince.ts +229 -0
  45. package/src/support/provisioning/executeGroovy.md +7 -1
  46. package/src/support/provisioning/executeGroovy.ts +46 -2
  47. package/src/support/provisioning/runProvisioningScript.ts +89 -12
  48. package/src/support/registerSupport.ts +29 -0
  49. package/src/utils/JahiaPlatformHelper.ts +16 -5
  50. package/tests/cypress/e2e/jfaker.spec.ts +411 -0
  51. package/tests/cypress/e2e/modSince.spec.ts +334 -0
  52. package/tests/cypress.config.ts +23 -0
  53. package/tests/package.json +41 -0
  54. package/tests/reporter-config.json +13 -0
  55. package/tests/yarn.lock +8578 -0
  56. package/tsconfig.json +3 -0
@@ -0,0 +1,52 @@
1
+ /** Cypress environment variable key used to store the current Jahia version. */
2
+ export declare const JAHIA_VERSION_ENV_VAR = "CYPRESS_JAHIA_VERSION";
3
+ declare global {
4
+ namespace Mocha {
5
+ interface TestFunction {
6
+ since(requiredVersion: string, title: string, fn?: Func): Test;
7
+ since(requiredVersion: string, title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test;
8
+ }
9
+ interface ExclusiveTestFunction {
10
+ since(requiredVersion: string, title: string, fn?: Func): Test;
11
+ since(requiredVersion: string, title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test;
12
+ }
13
+ interface PendingTestFunction {
14
+ since(requiredVersion: string, title: string, fn?: Func): Test;
15
+ since(requiredVersion: string, title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test;
16
+ }
17
+ interface SuiteFunction {
18
+ since(requiredVersion: string, title: string, fn: (this: Suite) => void): Suite;
19
+ }
20
+ interface ExclusiveSuiteFunction {
21
+ since(requiredVersion: string, title: string, fn: (this: Suite) => void): Suite;
22
+ }
23
+ interface PendingSuiteFunction {
24
+ since(requiredVersion: string, title: string, fn: (this: Suite) => void): Suite;
25
+ }
26
+ }
27
+ }
28
+ /**
29
+ * Fetches the Jahia version from the GraphQL API, strips the `-SNAPSHOT` suffix,
30
+ * and caches the result in `Cypress.env(JAHIA_VERSION_ENV_VAR)`.
31
+ */
32
+ export declare const initializeVersionSupport: () => Cypress.Chainable<any>;
33
+ /**
34
+ * Attaches `.since()` to `it`, `it.only`, `it.skip`, `describe`, `describe.only`,
35
+ * and `describe.skip`. Safe to call multiple times — subsequent calls are no-ops.
36
+ */
37
+ export declare const registerVersionSupport: () => void;
38
+ /**
39
+ * Enables version-gated testing for the Cypress suite.
40
+ * Registers `it.since`, `describe.since` (and their `.only`/`.skip` variants),
41
+ * then fetches the running Jahia version in a root `before()` hook.
42
+ *
43
+ * @example
44
+ * it.since('8.2.0', 'works on 8.2+', () => { ... });
45
+ * describe.since('8.2.0', 'suite for 8.2+', () => { ... });
46
+ */
47
+ declare function enable(): void;
48
+ /** Public API for Jahia version-gated testing. */
49
+ export declare const modSince: {
50
+ enable: typeof enable;
51
+ };
52
+ export {};
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modSince = exports.registerVersionSupport = exports.initializeVersionSupport = exports.JAHIA_VERSION_ENV_VAR = void 0;
4
+ var compare_versions_1 = require("compare-versions");
5
+ // Intentionally keep explicit path to avoid edge case errors in runtime
6
+ var JahiaPlatformHelper_1 = require("../utils/JahiaPlatformHelper");
7
+ /** Cypress environment variable key used to store the current Jahia version. */
8
+ exports.JAHIA_VERSION_ENV_VAR = 'CYPRESS_JAHIA_VERSION';
9
+ // ─── Internal helpers ────────────────────────────────────────────────────────
10
+ /**
11
+ * Returns `true` when `current` satisfies `>= required`.
12
+ * Treats missing, empty, or unparseable versions as unsupported.
13
+ * @param current - The running Jahia version read from `Cypress.env`.
14
+ * @param required - Minimum version the test or suite needs.
15
+ */
16
+ var isSupported = function (current, required) {
17
+ if (!(current === null || current === void 0 ? void 0 : current.trim())) {
18
+ return false;
19
+ }
20
+ try {
21
+ return (0, compare_versions_1.compare)(String(current), required, '>=');
22
+ }
23
+ catch (_a) {
24
+ return false;
25
+ }
26
+ };
27
+ /**
28
+ * Validates `since(...)` arguments and throws a descriptive error on misuse.
29
+ * Detects the common mistake of swapping `requiredVersion` and `title`.
30
+ * @param version - Version string passed as the first argument.
31
+ * @param title - Title string passed as the second argument.
32
+ * @param scope - Label used in the error message (e.g. `"it.since"`).
33
+ */
34
+ var assertArgs = function (version, title, scope) {
35
+ if (!(0, compare_versions_1.validate)(version)) {
36
+ var hint = (0, compare_versions_1.validate)(title) ? ' (arguments appear swapped)' : '';
37
+ throw new Error("[".concat(scope, "] Invalid version: \"").concat(version, "\"").concat(hint, "."));
38
+ }
39
+ };
40
+ /**
41
+ * Builds a human-readable message explaining why a test or suite was skipped.
42
+ * @param scope - Label for the helper (e.g. `"it.since"` or `"describe.since"`).
43
+ * @param title - Original test or suite title.
44
+ * @param required - Minimum version the test or suite needs.
45
+ * @param current - The running Jahia version; `undefined` when not yet fetched.
46
+ */
47
+ var skipReason = function (scope, title, required, current) {
48
+ return current ?
49
+ "[".concat(scope, "] Skipping \"").concat(title, "\" \u2014 ").concat(exports.JAHIA_VERSION_ENV_VAR, "=\"").concat(current, "\" < required ").concat(required, ".") :
50
+ "[".concat(scope, "] Skipping \"").concat(title, "\" \u2014 ").concat(exports.JAHIA_VERSION_ENV_VAR, " is not set. Required: ").concat(required, ".");
51
+ };
52
+ // ─── Public API ───────────────────────────────────────────────────────────────
53
+ /**
54
+ * Fetches the Jahia version from the GraphQL API, strips the `-SNAPSHOT` suffix,
55
+ * and caches the result in `Cypress.env(JAHIA_VERSION_ENV_VAR)`.
56
+ */
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ var initializeVersionSupport = function () {
59
+ var cachedVersion = Cypress.env(exports.JAHIA_VERSION_ENV_VAR);
60
+ if (typeof cachedVersion === 'string' && cachedVersion.trim() !== '') {
61
+ return cy.wrap(cachedVersion, { log: false });
62
+ }
63
+ return (0, JahiaPlatformHelper_1.getJahiaVersion)().then(function (jahiaVersion) {
64
+ var _a;
65
+ var version = ((_a = jahiaVersion === null || jahiaVersion === void 0 ? void 0 : jahiaVersion.release) === null || _a === void 0 ? void 0 : _a.replace('-SNAPSHOT', '')) || '0.0.0.1';
66
+ Cypress.env(exports.JAHIA_VERSION_ENV_VAR, version);
67
+ return version;
68
+ });
69
+ };
70
+ exports.initializeVersionSupport = initializeVersionSupport;
71
+ /**
72
+ * Attaches `.since()` to `it`, `it.only`, `it.skip`, `describe`, `describe.only`,
73
+ * and `describe.skip`. Safe to call multiple times — subsequent calls are no-ops.
74
+ */
75
+ var registerVersionSupport = function () {
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
+ var mochaIt = globalThis.it;
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ var mochaDescribe = globalThis.describe;
80
+ if (!mochaIt) {
81
+ throw new Error('Unable to register version support because Mocha `it` is not available.');
82
+ }
83
+ if (!mochaDescribe) {
84
+ throw new Error('Unable to register version support because Mocha `describe` is not available.');
85
+ }
86
+ var _loop_1 = function (target) {
87
+ if (typeof target.since === 'function') {
88
+ return "continue";
89
+ }
90
+ var isSkip = target === mochaIt.skip;
91
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
+ target.since = function (version, title, configOrFn, maybeFn) {
93
+ assertArgs(version, title, 'it.since');
94
+ if (isSkip) {
95
+ // It.skip.since: always skip unconditionally, preserve the title
96
+ return typeof configOrFn === 'function' || configOrFn === undefined ?
97
+ target(title, configOrFn) :
98
+ target(title, configOrFn, maybeFn);
99
+ }
100
+ var userFn = typeof configOrFn === 'function' ? configOrFn : maybeFn;
101
+ var wrappedFn = function () {
102
+ var current = Cypress.env(exports.JAHIA_VERSION_ENV_VAR);
103
+ if (!isSupported(current, version)) {
104
+ console.warn(skipReason('it.since', title, version, current));
105
+ this.skip();
106
+ }
107
+ else if (typeof userFn === 'function') {
108
+ return userFn.call(this);
109
+ }
110
+ };
111
+ return typeof configOrFn === 'object' && configOrFn !== null ?
112
+ target(title, configOrFn, wrappedFn) :
113
+ target(title, wrappedFn);
114
+ };
115
+ };
116
+ // Attach .since() to it / it.only / it.skip
117
+ for (var _i = 0, _a = [mochaIt, mochaIt.only, mochaIt.skip]; _i < _a.length; _i++) {
118
+ var target = _a[_i];
119
+ _loop_1(target);
120
+ }
121
+ var _loop_2 = function (target) {
122
+ if (typeof target.since === 'function') {
123
+ return "continue";
124
+ }
125
+ var isSkip = target === mochaDescribe.skip;
126
+ target.since = function (version, title, fn) {
127
+ assertArgs(version, title, 'describe.since');
128
+ if (isSkip) {
129
+ // Describe.skip.since: always skip unconditionally, preserve the title
130
+ return target(title, fn);
131
+ }
132
+ return target(title, function () {
133
+ // Suite-level runtime check runs after the global before() has fetched the version
134
+ before(function () {
135
+ var current = Cypress.env(exports.JAHIA_VERSION_ENV_VAR);
136
+ if (!isSupported(current, version)) {
137
+ console.warn(skipReason('describe.since', title, version, current));
138
+ this.skip();
139
+ }
140
+ });
141
+ fn.call(this);
142
+ });
143
+ };
144
+ };
145
+ // Attach .since() to describe / describe.only / describe.skip
146
+ for (var _b = 0, _c = [mochaDescribe, mochaDescribe.only, mochaDescribe.skip]; _b < _c.length; _b++) {
147
+ var target = _c[_b];
148
+ _loop_2(target);
149
+ }
150
+ // Compatibility shim: redirect accidental it.skip(version, title, fn) → it.skip.since(...)
151
+ var origItSkip = mochaIt.skip;
152
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
+ mochaIt.skip = Object.assign(function (title, configOrTitle, maybeFn) {
154
+ if ((0, compare_versions_1.validate)(title) && typeof configOrTitle === 'string' && typeof maybeFn === 'function') {
155
+ return origItSkip.since(title, configOrTitle, maybeFn);
156
+ }
157
+ return typeof configOrTitle === 'function' || configOrTitle === undefined ?
158
+ origItSkip(title, configOrTitle) :
159
+ origItSkip(title, configOrTitle, maybeFn);
160
+ }, { since: origItSkip.since });
161
+ var origDescribeSkip = mochaDescribe.skip;
162
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
+ mochaDescribe.skip = Object.assign(function (title, fnOrTitle, maybeFn) {
164
+ if ((0, compare_versions_1.validate)(title) && typeof fnOrTitle === 'string' && typeof maybeFn === 'function') {
165
+ return origDescribeSkip.since(title, fnOrTitle, maybeFn);
166
+ }
167
+ return origDescribeSkip(title, fnOrTitle);
168
+ }, { since: origDescribeSkip.since });
169
+ };
170
+ exports.registerVersionSupport = registerVersionSupport;
171
+ /**
172
+ * Enables version-gated testing for the Cypress suite.
173
+ * Registers `it.since`, `describe.since` (and their `.only`/`.skip` variants),
174
+ * then fetches the running Jahia version in a root `before()` hook.
175
+ *
176
+ * @example
177
+ * it.since('8.2.0', 'works on 8.2+', () => { ... });
178
+ * describe.since('8.2.0', 'suite for 8.2+', () => { ... });
179
+ */
180
+ function enable() {
181
+ (0, exports.registerVersionSupport)();
182
+ before(function () { return (0, exports.initializeVersionSupport)(); });
183
+ }
184
+ /** Public API for Jahia version-gated testing. */
185
+ exports.modSince = { enable: enable };
@@ -10,6 +10,36 @@ var serverDefaults = {
10
10
  };
11
11
  var executeGroovy = function (scriptFile, replacements, jahiaServer) {
12
12
  if (jahiaServer === void 0) { jahiaServer = serverDefaults; }
13
+ var result;
14
+ var duration;
15
+ var scriptContent;
16
+ var startTime = Date.now();
17
+ var replacementsLabel = replacements && Object.keys(replacements).length > 0 ?
18
+ " \u2014 ".concat(JSON.stringify(replacements)) :
19
+ '';
20
+ var logger = Cypress.log({
21
+ autoEnd: false,
22
+ name: 'executeGroovy',
23
+ displayName: 'groovy',
24
+ message: "".concat(scriptFile).concat(replacementsLabel),
25
+ consoleProps: function () { return ({
26
+ Script: scriptFile,
27
+ 'Script Content': scriptContent !== null && scriptContent !== void 0 ? scriptContent : '(loading...)',
28
+ Replacements: replacements !== null && replacements !== void 0 ? replacements : {},
29
+ Server: jahiaServer.url,
30
+ Duration: duration === undefined ? 'pending' : "".concat(duration, "ms"),
31
+ Result: result
32
+ }); }
33
+ });
34
+ cy.fixture(scriptFile, 'utf-8').then(function (content) {
35
+ var processed = content;
36
+ if (replacements) {
37
+ Object.keys(replacements).forEach(function (k) {
38
+ processed = processed.replaceAll(k, replacements[k]);
39
+ });
40
+ }
41
+ scriptContent = processed;
42
+ });
13
43
  cy.runProvisioningScript({
14
44
  script: {
15
45
  fileContent: '- executeScript: "' + scriptFile + '"',
@@ -21,7 +51,16 @@ var executeGroovy = function (scriptFile, replacements, jahiaServer) {
21
51
  type: 'text/plain',
22
52
  encoding: 'utf-8'
23
53
  }],
24
- jahiaServer: jahiaServer
25
- }).then(function (r) { return r[0]; });
54
+ jahiaServer: jahiaServer,
55
+ options: { log: false }
56
+ }).then(function (r) {
57
+ result = r === null || r === void 0 ? void 0 : r[0];
58
+ duration = Date.now() - startTime;
59
+ var hasFailed = typeof result === 'string' && result.includes('.failed');
60
+ var prefix = hasFailed ? '❌ ' : '✅ ';
61
+ logger.set('message', "".concat(prefix).concat(scriptFile).concat(replacementsLabel));
62
+ logger === null || logger === void 0 ? void 0 : logger.end();
63
+ return result;
64
+ });
26
65
  };
27
66
  exports.executeGroovy = executeGroovy;
@@ -29,4 +29,4 @@ export type JahiaServer = {
29
29
  username: string;
30
30
  password: string;
31
31
  };
32
- export declare const runProvisioningScript: ({ script, files, jahiaServer, options, requestOptions }: RunProvisioningScriptParams) => void;
32
+ export declare const runProvisioningScript: (paramsOrScript: RunProvisioningScriptParams | FormFile | StringDictionary[], ...rest: any[]) => void;
@@ -52,10 +52,71 @@ var serverDefaults = {
52
52
  password: Cypress.env('SUPER_USER_PASSWORD')
53
53
  };
54
54
  function isFormFile(script) {
55
- return Boolean(script.fileContent || script.fileName);
55
+ return Boolean((script === null || script === void 0 ? void 0 : script.fileContent) || (script === null || script === void 0 ? void 0 : script.fileName));
56
56
  }
57
- var runProvisioningScript = function (_a) {
58
- 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;
57
+ function getScriptSummary(script) {
58
+ if (isFormFile(script)) {
59
+ if (script.fileName) {
60
+ return script.fileName;
61
+ }
62
+ if (script.fileContent) {
63
+ // Parse first operation and its value from YAML list: "- operationName: value"
64
+ var yamlMatch = script.fileContent.match(/^\s*-\s+(\w+)\s*:\s*"?([^"\n]+)"?/m);
65
+ if (yamlMatch) {
66
+ return "".concat(yamlMatch[1], ": ").concat(yamlMatch[2].trim());
67
+ }
68
+ // Parse first operation name from JSON array: [{"operationName": ...}]
69
+ try {
70
+ var parsed = JSON.parse(script.fileContent);
71
+ if (Array.isArray(parsed) && parsed.length > 0) {
72
+ var ops_1 = parsed.map(function (op) { var _a; return (_a = Object.keys(op)[0]) !== null && _a !== void 0 ? _a : 'unknown'; });
73
+ return ops_1.length === 1 ? ops_1[0] : "[".concat(ops_1.join(', '), "]");
74
+ }
75
+ }
76
+ catch (_a) {
77
+ // Not valid JSON, fall through
78
+ }
79
+ }
80
+ return 'inline script';
81
+ }
82
+ if (!script || script.length === 0) {
83
+ return 'empty script';
84
+ }
85
+ var ops = script.map(function (op) { var _a; return (_a = Object.keys(op)[0]) !== null && _a !== void 0 ? _a : 'unknown'; });
86
+ return ops.length === 1 ? ops[0] : "[".concat(ops.join(', '), "]");
87
+ }
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ var runProvisioningScript = function (paramsOrScript) {
90
+ var _a, _b, _c, _d, _e;
91
+ var rest = [];
92
+ for (var _i = 1; _i < arguments.length; _i++) {
93
+ rest[_i - 1] = arguments[_i];
94
+ }
95
+ // Backward-compatible: support old positional signature
96
+ // runProvisioningScript(script, files, jahiaServer, options, timeout)
97
+ var script;
98
+ var files;
99
+ var jahiaServer;
100
+ var options;
101
+ var requestOptions;
102
+ var isLegacyCall = Array.isArray(paramsOrScript) ||
103
+ paramsOrScript.fileContent !== undefined ||
104
+ paramsOrScript.fileName !== undefined;
105
+ if (isLegacyCall) {
106
+ script = paramsOrScript;
107
+ files = rest[0];
108
+ jahiaServer = (_a = rest[1]) !== null && _a !== void 0 ? _a : serverDefaults;
109
+ options = (_b = rest[2]) !== null && _b !== void 0 ? _b : { log: true };
110
+ requestOptions = {};
111
+ }
112
+ else {
113
+ var params = paramsOrScript;
114
+ script = params.script;
115
+ files = params.files;
116
+ jahiaServer = (_c = params.jahiaServer) !== null && _c !== void 0 ? _c : serverDefaults;
117
+ options = (_d = params.options) !== null && _d !== void 0 ? _d : { log: true };
118
+ requestOptions = (_e = params.requestOptions) !== null && _e !== void 0 ? _e : {};
119
+ }
59
120
  var formData = new FormData();
60
121
  if (isFormFile(script)) {
61
122
  append(script, formData, 'script');
@@ -76,18 +137,28 @@ var runProvisioningScript = function (_a) {
76
137
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
138
  var result;
78
139
  var logger;
140
+ var scriptSummary = getScriptSummary(script);
141
+ var replacementsFromFiles = files === null || files === void 0 ? void 0 : files.filter(function (f) { return f.replacements && Object.keys(f.replacements).length > 0; }).map(function (f) { return "".concat(f.fileName, ": ").concat(JSON.stringify(f.replacements)); });
79
142
  if (options.log) {
80
143
  logger = Cypress.log({
81
144
  autoEnd: false,
82
145
  name: 'runProvisioningScript',
83
146
  displayName: 'provScript',
84
- message: "Run ".concat(isFormFile(script) && script.fileName ? script.fileName : 'inline script', " towards server: ").concat(jahiaServer.url),
147
+ message: "".concat(scriptSummary, " @ ").concat(jahiaServer.url),
85
148
  consoleProps: function () {
149
+ var _a;
86
150
  return {
87
151
  Script: script,
88
- Files: files,
89
- Response: response,
90
- Yielded: result
152
+ Operations: isFormFile(script) ?
153
+ undefined :
154
+ script === null || script === void 0 ? void 0 : script.map(function (op) { return "".concat(Object.keys(op)[0], ": ").concat(Object.values(op)[0]); }),
155
+ Files: (_a = files === null || files === void 0 ? void 0 : files.map(function (f) { var _a; return (_a = f.fileName) !== null && _a !== void 0 ? _a : 'inline file'; })) !== null && _a !== void 0 ? _a : [],
156
+ Replacements: (replacementsFromFiles === null || replacementsFromFiles === void 0 ? void 0 : replacementsFromFiles.length) > 0 ? replacementsFromFiles : undefined,
157
+ Server: jahiaServer.url,
158
+ 'HTTP Status': response ? "".concat(response.status, " ").concat(response.statusText) : 'pending',
159
+ Duration: response ? "".concat(response.duration, "ms") : 'pending',
160
+ Result: result,
161
+ Response: response
91
162
  };
92
163
  }
93
164
  });
@@ -113,6 +184,12 @@ var runProvisioningScript = function (_a) {
113
184
  result = res;
114
185
  }
115
186
  logger === null || logger === void 0 ? void 0 : logger.end();
187
+ if (logger) {
188
+ var hasFailed = res.status !== 200 ||
189
+ (Array.isArray(result) && result.some(function (r) { return typeof r === 'string' && r.includes('.failed'); })); // eslint-disable-line @typescript-eslint/no-explicit-any
190
+ var prefix = hasFailed ? '❌ ' : '✅ ';
191
+ logger.set('message', "".concat(prefix).concat(scriptSummary, " @ ").concat(jahiaServer.url));
192
+ }
116
193
  return result;
117
194
  });
118
195
  };
@@ -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
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.registerSupport = void 0;
4
15
  var apollo_1 = require("./apollo");
@@ -8,6 +19,8 @@ var logout_1 = require("./logout");
8
19
  var fixture_1 = require("./fixture");
9
20
  var repeatUntil_1 = require("./repeatUntil");
10
21
  var testStep_1 = require("./testStep");
22
+ var jfaker_1 = require("./jfaker");
23
+ var modSince_1 = require("./modSince");
11
24
  var registerSupport = function () {
12
25
  Cypress.Commands.add('apolloClient', apollo_1.apolloClient);
13
26
  Cypress.Commands.add('apollo', { prevSubject: 'optional' }, apollo_1.apollo);
@@ -22,5 +35,26 @@ var registerSupport = function () {
22
35
  Cypress.Commands.add('repeatUntil', repeatUntil_1.repeatUntil);
23
36
  Cypress.Commands.overwrite('fixture', fixture_1.fixture);
24
37
  Cypress.Commands.add('step', testStep_1.step);
38
+ // Register it.since()/describe.since()
39
+ modSince_1.modSince.enable();
40
+ /**
41
+ * Override Cypress `type()` command to interpret special characters (e.g., {, }, etc.) either literally or as commands.
42
+ * The behavior is controlled by the `parseSpecialCharSequences` option, which can be set to `true`
43
+ * to enable command parsing or `false` to treat special characters as literal input.
44
+ *
45
+ * Since Cypress `clear()` command is an alias for `.type('{selectall}{del}')`,
46
+ * such case has to be handled to ensure that the special character sequences are properly interpreted when clearing the input.
47
+ * Also cover older Cypress versions which were using {backspace} was used instead of {del} .
48
+ */
49
+ Cypress.Commands.overwrite('type', function (originalFn, element, text, options) {
50
+ if (options === void 0) { options = {}; }
51
+ // Check if this is Cypress `.clear() call
52
+ var isCypressClearSequence = ['{selectall}{del}', '{selectall}{backspace}'].includes(text.toString());
53
+ // Do not override if this is `.clear()` call or data type is `faker`
54
+ var parseSpecialCharSequences = isCypressClearSequence || jfaker_1.jfaker.getDataType() === 'faker';
55
+ // Merge options with passed ones (if any)
56
+ var newOptions = __assign({ parseSpecialCharSequences: parseSpecialCharSequences }, options);
57
+ return originalFn(element, text, newOptions);
58
+ });
25
59
  };
26
60
  exports.registerSupport = registerSupport;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Fetches the Jahia version using a GraphQL query.
3
+ * @returns Cypress.Chainable that resolves to the Jahia version record (e.g., release: "8.0.0", ...).
4
+ * @note In rare cases tests might override baseUrl (e.g. when Jahia is configured with custom context path,
5
+ * but spec want to use just a host, without the context path), e.g.:
6
+ * it('Crawl pages', {baseUrl: serverURL.origin}, () => { ... })
7
+ * In such case(s) this call will fail because the GraphQL endpoint will not be found at the root of the host.
8
+ * To prevent such failure, we ensure GraphQL client uses full Jahia url as configured in env variable.
9
+ */
1
10
  export declare const getJahiaVersion: () => Cypress.Chainable;
2
11
  export declare const getStartedModulesVersion: () => Cypress.Chainable;
3
12
  export declare const getStartedModuleVersion: (moduleId: string) => Cypress.Chainable;
@@ -1,13 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getStartedModuleVersion = exports.getStartedModulesVersion = exports.getJahiaVersion = void 0;
4
+ /**
5
+ * Fetches the Jahia version using a GraphQL query.
6
+ * @returns Cypress.Chainable that resolves to the Jahia version record (e.g., release: "8.0.0", ...).
7
+ * @note In rare cases tests might override baseUrl (e.g. when Jahia is configured with custom context path,
8
+ * but spec want to use just a host, without the context path), e.g.:
9
+ * it('Crawl pages', {baseUrl: serverURL.origin}, () => { ... })
10
+ * In such case(s) this call will fail because the GraphQL endpoint will not be found at the root of the host.
11
+ * To prevent such failure, we ensure GraphQL client uses full Jahia url as configured in env variable.
12
+ */
4
13
  var getJahiaVersion = function () {
5
- return cy.apollo({
6
- fetchPolicy: 'no-cache',
7
- queryFile: 'graphql/jcr/query/getJahiaVersion.graphql'
8
- }).then(function (result) {
9
- var _a;
10
- return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.admin.jahia.version;
14
+ return cy.apolloClient({ url: Cypress.env('JAHIA_URL') || Cypress.config().baseUrl }).then(function () {
15
+ return cy.apollo({
16
+ fetchPolicy: 'no-cache',
17
+ queryFile: 'graphql/jcr/query/getJahiaVersion.graphql'
18
+ }).then(function (result) {
19
+ var _a;
20
+ return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.admin.jahia.version;
21
+ });
11
22
  });
12
23
  };
13
24
  exports.getJahiaVersion = getJahiaVersion;