@jahia/cypress 7.4.0 → 8.1.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.
Files changed (135) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +69 -2
  3. package/dist/index.js +6 -2
  4. package/dist/injections/bash-data.d.ts +1 -0
  5. package/dist/injections/bash-data.js +57 -0
  6. package/dist/injections/chars-data.d.ts +1 -0
  7. package/dist/injections/chars-data.js +25 -0
  8. package/dist/injections/htmlentities-data.d.ts +1 -0
  9. package/dist/injections/htmlentities-data.js +22 -0
  10. package/dist/injections/numbers-data.d.ts +1 -0
  11. package/dist/injections/numbers-data.js +66 -0
  12. package/dist/injections/sql-data.d.ts +1 -0
  13. package/dist/injections/sql-data.js +82 -0
  14. package/dist/injections/xss-data.d.ts +1 -0
  15. package/dist/injections/xss-data.js +740 -0
  16. package/dist/page-object/baseComponent.d.ts +1 -2
  17. package/dist/page-object/baseComponent.js +10 -6
  18. package/dist/page-object/basePage.js +1 -1
  19. package/dist/page-object/html/iframe.d.ts +0 -1
  20. package/dist/page-object/html/iframe.js +2 -2
  21. package/dist/page-object/html/index.js +6 -2
  22. package/dist/page-object/index.js +6 -2
  23. package/dist/page-object/material/index.js +6 -2
  24. package/dist/page-object/material/muiinput.d.ts +0 -1
  25. package/dist/page-object/material/muiinput.js +1 -1
  26. package/dist/page-object/material/muiradio.js +1 -1
  27. package/dist/page-object/moonstone/accordion.d.ts +0 -1
  28. package/dist/page-object/moonstone/accordion.js +2 -2
  29. package/dist/page-object/moonstone/button.js +1 -1
  30. package/dist/page-object/moonstone/collapsible.js +1 -1
  31. package/dist/page-object/moonstone/dropdown.js +2 -2
  32. package/dist/page-object/moonstone/index.js +6 -2
  33. package/dist/page-object/moonstone/menu.js +9 -9
  34. package/dist/page-object/moonstone/pagination.js +3 -3
  35. package/dist/page-object/moonstone/primaryNav.js +2 -2
  36. package/dist/page-object/moonstone/secondaryNav.js +1 -1
  37. package/dist/page-object/moonstone/table.d.ts +0 -1
  38. package/dist/page-object/moonstone/table.js +5 -5
  39. package/dist/page-object/utils.d.ts +0 -1
  40. package/dist/page-object/utils.js +11 -12
  41. package/dist/plugins/env.js +2 -2
  42. package/dist/plugins/index.js +6 -2
  43. package/dist/plugins/registerPlugins.js +2 -2
  44. package/dist/support/apollo/apollo.d.ts +5 -4
  45. package/dist/support/apollo/apollo.js +80 -18
  46. package/dist/support/apollo/apolloClient.d.ts +1 -2
  47. package/dist/support/apollo/apolloClient.js +7 -7
  48. package/dist/support/apollo/index.js +6 -2
  49. package/dist/support/apollo/links.d.ts +1 -1
  50. package/dist/support/apollo/links.js +5 -6
  51. package/dist/support/browserHelper.d.ts +10 -0
  52. package/dist/support/browserHelper.js +167 -0
  53. package/dist/support/commands.js +1 -1
  54. package/dist/support/fixture.d.ts +1 -1
  55. package/dist/support/fixture.js +11 -7
  56. package/dist/support/index.d.ts +3 -0
  57. package/dist/support/index.js +9 -2
  58. package/dist/support/jfaker.d.ts +60 -0
  59. package/dist/support/jfaker.js +241 -0
  60. package/dist/support/jsErrorsLogger.js +13 -9
  61. package/dist/support/login.d.ts +0 -1
  62. package/dist/support/login.js +2 -2
  63. package/dist/support/logout.d.ts +0 -1
  64. package/dist/support/logout.js +1 -1
  65. package/dist/support/modSince.d.ts +52 -0
  66. package/dist/support/modSince.js +180 -0
  67. package/dist/support/provisioning/executeGroovy.d.ts +1 -1
  68. package/dist/support/provisioning/executeGroovy.js +42 -3
  69. package/dist/support/provisioning/index.js +6 -2
  70. package/dist/support/provisioning/installConfig.d.ts +0 -1
  71. package/dist/support/provisioning/installConfig.js +3 -3
  72. package/dist/support/provisioning/installModule.d.ts +0 -1
  73. package/dist/support/provisioning/installModule.js +1 -1
  74. package/dist/support/provisioning/runProvisioningScript.d.ts +4 -5
  75. package/dist/support/provisioning/runProvisioningScript.js +86 -9
  76. package/dist/support/provisioning/uninstallModule.d.ts +0 -1
  77. package/dist/support/provisioning/uninstallModule.js +1 -1
  78. package/dist/support/registerSupport.js +35 -1
  79. package/dist/support/repeatUntil.d.ts +1 -2
  80. package/dist/support/repeatUntil.js +2 -2
  81. package/dist/support/testStep.js +2 -2
  82. package/dist/utils/ClusterHelper.js +1 -1
  83. package/dist/utils/ExportHelper.d.ts +2 -2
  84. package/dist/utils/ExportHelper.js +14 -10
  85. package/dist/utils/GraphQLHelper.js +21 -17
  86. package/dist/utils/JCRHelper.d.ts +1 -1
  87. package/dist/utils/JCRHelper.js +1 -1
  88. package/dist/utils/JahiaPlatformHelper.js +2 -2
  89. package/dist/utils/Logger.js +6 -6
  90. package/dist/utils/PublicationAndWorkflowHelper.js +3 -3
  91. package/dist/utils/SAMHelper.d.ts +1 -1
  92. package/dist/utils/SAMHelper.js +4 -4
  93. package/dist/utils/SiteHelper.js +2 -2
  94. package/dist/utils/UsersHelper.js +2 -2
  95. package/dist/utils/VanityUrlHelper.js +1 -1
  96. package/dist/utils/index.js +6 -2
  97. package/docs/browser-helper.md +158 -0
  98. package/docs/jfaker.md +450 -0
  99. package/package.json +13 -10
  100. package/src/injections/bash-data.ts +54 -0
  101. package/src/injections/chars-data.ts +22 -0
  102. package/src/injections/htmlentities-data.ts +19 -0
  103. package/src/injections/numbers-data.ts +63 -0
  104. package/src/injections/sql-data.ts +79 -0
  105. package/src/injections/xss-data.ts +737 -0
  106. package/src/page-object/baseComponent.ts +6 -6
  107. package/src/page-object/html/iframe.ts +3 -3
  108. package/src/page-object/material/muiinput.ts +1 -1
  109. package/src/page-object/material/muiradio.ts +1 -1
  110. package/src/page-object/moonstone/accordion.ts +1 -1
  111. package/src/page-object/moonstone/button.ts +1 -1
  112. package/src/page-object/moonstone/collapsible.ts +1 -1
  113. package/src/page-object/moonstone/dropdown.ts +1 -1
  114. package/src/page-object/moonstone/menu.ts +1 -1
  115. package/src/page-object/moonstone/pagination.ts +1 -1
  116. package/src/page-object/moonstone/primaryNav.ts +1 -1
  117. package/src/page-object/moonstone/secondaryNav.ts +1 -1
  118. package/src/page-object/moonstone/table.ts +2 -2
  119. package/src/support/apollo/apollo.ts +74 -11
  120. package/src/support/apollo/links.ts +1 -2
  121. package/src/support/browserHelper.ts +186 -0
  122. package/src/support/index.ts +3 -0
  123. package/src/support/jfaker.ts +245 -0
  124. package/src/support/modSince.ts +222 -0
  125. package/src/support/provisioning/executeGroovy.md +7 -1
  126. package/src/support/provisioning/executeGroovy.ts +46 -2
  127. package/src/support/provisioning/runProvisioningScript.ts +89 -12
  128. package/src/support/registerSupport.ts +29 -0
  129. package/tests/cypress/e2e/jfaker.spec.ts +411 -0
  130. package/tests/cypress/e2e/modSince.spec.ts +306 -0
  131. package/tests/cypress.config.ts +23 -0
  132. package/tests/package.json +41 -0
  133. package/tests/reporter-config.json +13 -0
  134. package/tests/yarn.lock +8578 -0
  135. package/tsconfig.json +3 -0
@@ -25,9 +25,10 @@ var __rest = (this && this.__rest) || function (s, e) {
25
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
- exports.__esModule = true;
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.apollo = void 0;
30
30
  var graphql_tag_1 = __importDefault(require("graphql-tag"));
31
+ var graphql_1 = require("graphql");
31
32
  function isQuery(options) {
32
33
  return options.query !== undefined;
33
34
  }
@@ -37,53 +38,114 @@ function isQueryFile(options) {
37
38
  function isMutationFile(options) {
38
39
  return options.mutationFile !== undefined;
39
40
  }
41
+ function getOperationLabel(doc, opType) {
42
+ var _a, _b, _c, _d, _e;
43
+ var opDef = (0, graphql_1.getOperationAST)(doc);
44
+ if ((_a = opDef === null || opDef === void 0 ? void 0 : opDef.name) === null || _a === void 0 ? void 0 : _a.value) {
45
+ return "[".concat(opType, "] ").concat(opDef.name.value);
46
+ }
47
+ // Anonymous operation: traverse up to 2 selection levels for a meaningful label
48
+ var firstSel = (_c = (_b = opDef === null || opDef === void 0 ? void 0 : opDef.selectionSet) === null || _b === void 0 ? void 0 : _b.selections) === null || _c === void 0 ? void 0 : _c[0];
49
+ if ((firstSel === null || firstSel === void 0 ? void 0 : firstSel.kind) === 'Field') {
50
+ var firstName = firstSel.name.value;
51
+ var secondSel = (_e = (_d = firstSel.selectionSet) === null || _d === void 0 ? void 0 : _d.selections) === null || _e === void 0 ? void 0 : _e[0];
52
+ if ((secondSel === null || secondSel === void 0 ? void 0 : secondSel.kind) === 'Field') {
53
+ return "[".concat(opType, "] ").concat(firstName, " \u203A ").concat(secondSel.name.value);
54
+ }
55
+ return "[".concat(opType, "] ").concat(firstName);
56
+ }
57
+ return "[".concat(opType, "]");
58
+ }
59
+ function getQueryBody(doc) {
60
+ var _a, _b, _c;
61
+ return (_c = (_b = (_a = doc === null || doc === void 0 ? void 0 : doc.loc) === null || _a === void 0 ? void 0 : _a.source) === null || _b === void 0 ? void 0 : _b.body) !== null && _c !== void 0 ? _c : (0, graphql_1.print)(doc);
62
+ }
40
63
  // eslint-disable-next-line default-param-last, @typescript-eslint/no-shadow
41
64
  var apollo = function (apollo, options) {
42
65
  if (apollo === void 0) { apollo = this.currentApolloClient; }
43
66
  var result;
44
67
  var logger;
68
+ var duration;
45
69
  var optionsWithDefaultCache = __assign({ fetchPolicy: 'no-cache' }, options);
46
70
  if (!apollo) {
47
71
  cy.apolloClient().apollo(optionsWithDefaultCache);
48
72
  }
49
73
  else if (isQueryFile(optionsWithDefaultCache)) {
50
- var queryFile = optionsWithDefaultCache.queryFile, apolloOptions_1 = __rest(optionsWithDefaultCache, ["queryFile"]);
51
- cy.fixture(queryFile).then(function (content) {
52
- cy.apollo(__assign({ query: graphql_tag_1["default"](content) }, apolloOptions_1));
74
+ var _a = optionsWithDefaultCache, queryFile_1 = _a.queryFile, sourcePackage_1 = _a.sourcePackage, apolloOptions_1 = __rest(_a, ["queryFile", "sourcePackage"]);
75
+ cy.fixture(queryFile_1).then(function (content) {
76
+ var fileLabel = sourcePackage_1 ? "".concat(queryFile_1, " @ ").concat(sourcePackage_1) : queryFile_1;
77
+ cy.apollo(__assign(__assign({ query: (0, graphql_tag_1.default)(content) }, apolloOptions_1), { _sourceFile: fileLabel }));
53
78
  });
54
79
  }
55
80
  else if (isMutationFile(optionsWithDefaultCache)) {
56
- var mutationFile = optionsWithDefaultCache.mutationFile, apolloOptions_2 = __rest(optionsWithDefaultCache, ["mutationFile"]);
57
- cy.fixture(mutationFile).then(function (content) {
58
- cy.apollo(__assign({ mutation: graphql_tag_1["default"](content) }, apolloOptions_2));
81
+ var _b = optionsWithDefaultCache, mutationFile_1 = _b.mutationFile, sourcePackage_2 = _b.sourcePackage, apolloOptions_2 = __rest(_b, ["mutationFile", "sourcePackage"]);
82
+ cy.fixture(mutationFile_1).then(function (content) {
83
+ var fileLabel = sourcePackage_2 ? "".concat(mutationFile_1, " @ ").concat(sourcePackage_2) : mutationFile_1;
84
+ cy.apollo(__assign(__assign({ mutation: (0, graphql_tag_1.default)(content) }, apolloOptions_2), { _sourceFile: fileLabel }));
59
85
  });
60
86
  }
61
87
  else {
62
- var _a = optionsWithDefaultCache.log, log = _a === void 0 ? true : _a, apolloOptions_3 = __rest(optionsWithDefaultCache, ["log"]);
88
+ var _c = optionsWithDefaultCache.log, log = _c === void 0 ? true : _c, apolloOptions = __rest(optionsWithDefaultCache, ["log"]);
89
+ var doc = isQuery(apolloOptions) ?
90
+ apolloOptions.query :
91
+ apolloOptions.mutation;
92
+ var opType_1 = isQuery(apolloOptions) ? 'Query' : 'Mutation';
93
+ var operationLabel_1 = getOperationLabel(doc, opType_1);
94
+ var queryBody_1 = getQueryBody(doc);
95
+ var variables_1 = apolloOptions.variables;
96
+ var sourceLabel_1 = optionsWithDefaultCache._sourceFile ? " (".concat(optionsWithDefaultCache._sourceFile, ")") : '';
97
+ var variablesLabel_1 = variables_1 && Object.keys(variables_1).length > 0 ?
98
+ " \u2014 ".concat(JSON.stringify(variables_1)) :
99
+ '';
63
100
  if (log) {
64
101
  logger = Cypress.log({
65
102
  autoEnd: false,
66
103
  name: 'apollo',
67
104
  displayName: 'apollo',
68
- message: isQuery(apolloOptions_3) ? "Execute Graphql Query: " + apolloOptions_3.query.loc.source.body : "Execute Graphql Mutation: " + apolloOptions_3.mutation.loc.source.body,
105
+ message: "".concat(operationLabel_1).concat(sourceLabel_1).concat(variablesLabel_1),
69
106
  consoleProps: function () {
70
- return {
71
- Options: apolloOptions_3,
72
- Yielded: result
73
- };
107
+ var _a;
108
+ var _b, _c, _d;
109
+ var errors = (_c = (_b = result === null || result === void 0 ? void 0 : result.errors) !== null && _b !== void 0 ? _b : result === null || result === void 0 ? void 0 : result.graphQLErrors) !== null && _c !== void 0 ? _c : null;
110
+ var isCaughtError = result instanceof Error;
111
+ var hasErrors = ((errors === null || errors === void 0 ? void 0 : errors.length) > 0) || isCaughtError;
112
+ return _a = {
113
+ Operation: operationLabel_1,
114
+ Variables: variables_1 !== null && variables_1 !== void 0 ? variables_1 : {}
115
+ },
116
+ _a["".concat(opType_1, " Body")] = queryBody_1,
117
+ _a.Duration = duration === undefined ? 'pending' : "".concat(duration, "ms"),
118
+ _a.Status = hasErrors ?
119
+ "error".concat(isCaughtError ? ": ".concat(result.message) : '') :
120
+ 'success',
121
+ _a.Data = (_d = result === null || result === void 0 ? void 0 : result.data) !== null && _d !== void 0 ? _d : null,
122
+ _a.Errors = errors,
123
+ _a.Yielded = result,
124
+ _a;
74
125
  }
75
126
  });
76
127
  }
77
- cy.wrap({}, { log: true })
78
- .then(function () { return (isQuery(optionsWithDefaultCache) ? apollo.query(optionsWithDefaultCache)["catch"](function (error) {
79
- cy.log("Caught Graphql Query Error: " + JSON.stringify(error));
128
+ var startTime_1 = Date.now();
129
+ cy.wrap({}, { log: false })
130
+ .then(function () { return (isQuery(optionsWithDefaultCache) ? apollo.query(optionsWithDefaultCache).catch(function (error) {
131
+ var _a;
132
+ cy.log("Caught GraphQL query error: ".concat((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : JSON.stringify(error)));
80
133
  return error;
81
- }) : apollo.mutate(optionsWithDefaultCache)["catch"](function (error) {
82
- cy.log("Caught Graphql Mutation Error: " + JSON.stringify(error));
134
+ }) : apollo.mutate(optionsWithDefaultCache).catch(function (error) {
135
+ var _a;
136
+ cy.log("Caught GraphQL mutation error: ".concat((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : JSON.stringify(error)));
83
137
  return error;
84
138
  }))
85
139
  .then(function (r) {
140
+ var _a;
86
141
  result = r;
142
+ duration = Date.now() - startTime_1;
143
+ if (logger) {
144
+ var errors = (_a = r === null || r === void 0 ? void 0 : r.errors) !== null && _a !== void 0 ? _a : r === null || r === void 0 ? void 0 : r.graphQLErrors;
145
+ var hasErrors = (r instanceof Error) || ((errors === null || errors === void 0 ? void 0 : errors.length) > 0);
146
+ var prefix = hasErrors ? '❌ ' : '✅ ';
147
+ logger.set('message', "".concat(prefix).concat(operationLabel_1).concat(sourceLabel_1).concat(variablesLabel_1));
148
+ }
87
149
  logger === null || logger === void 0 ? void 0 : logger.end();
88
150
  return r;
89
151
  }); });
@@ -1,4 +1,3 @@
1
- /// <reference types="cypress" />
2
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
3
2
  interface HostConfig {
4
3
  token?: string;
@@ -13,7 +12,7 @@ declare global {
13
12
  }
14
13
  }
15
14
  }
16
- export declare type ApolloClientOptions = Cypress.Loggable & {
15
+ export type ApolloClientOptions = Cypress.Loggable & {
17
16
  setCurrentApolloClient: boolean;
18
17
  };
19
18
  export declare const switchApolloClient: (config?: HostConfig, options?: ApolloClientOptions) => void;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apolloClient = exports.switchApolloClient = void 0;
4
4
  var core_1 = require("@apollo/client/core");
5
5
  var links_1 = require("./links");
@@ -11,7 +11,7 @@ var switchApolloClient = function (config, options) {
11
11
  }; }
12
12
  // Switch context to apollo client
13
13
  cy.visit(config.url || Cypress.config().baseUrl, { failOnStatusCode: false });
14
- return exports.apolloClient(config, options);
14
+ return (0, exports.apolloClient)(config, options);
15
15
  };
16
16
  exports.switchApolloClient = switchApolloClient;
17
17
  var apolloClient = function (config, options) {
@@ -22,17 +22,17 @@ var apolloClient = function (config, options) {
22
22
  }; }
23
23
  var headers = {};
24
24
  if (config.token !== undefined) {
25
- headers.authorization = "APIToken " + config.token;
25
+ headers.authorization = "APIToken ".concat(config.token);
26
26
  }
27
27
  else if (config.username !== undefined && config.password !== undefined) {
28
- headers.authorization = "Basic " + btoa(config.username + ':' + config.password);
28
+ headers.authorization = "Basic ".concat(btoa(config.username + ':' + config.password));
29
29
  }
30
30
  else {
31
- headers.authorization = "Basic " + btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'));
31
+ headers.authorization = "Basic ".concat(btoa('root:' + Cypress.env('SUPER_USER_PASSWORD')));
32
32
  }
33
- var links = [links_1.uploadLink, links_1.formDataHttpLink(config.url || Cypress.config().baseUrl, headers)];
33
+ var links = [links_1.uploadLink, (0, links_1.formDataHttpLink)(config.url || Cypress.config().baseUrl, headers)];
34
34
  var client = new core_1.ApolloClient({
35
- link: core_1.from(links),
35
+ link: (0, core_1.from)(links),
36
36
  cache: new core_1.InMemoryCache(),
37
37
  defaultOptions: {
38
38
  query: {
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -9,6 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
- exports.__esModule = true;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./apolloClient"), exports);
14
18
  __exportStar(require("./apollo"), exports);
@@ -1,3 +1,3 @@
1
1
  import { HttpLink } from '@apollo/client/link/http';
2
- export declare const formDataHttpLink: (baseUrl: string, headers: unknown) => HttpLink;
2
+ export declare const formDataHttpLink: (baseUrl: string, headers: Record<string, string>) => HttpLink;
3
3
  export declare const uploadLink: import("@apollo/client/core").ApolloLink;
@@ -13,15 +13,14 @@ var __assign = (this && this.__assign) || function () {
13
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
- exports.__esModule = true;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.uploadLink = exports.formDataHttpLink = void 0;
18
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
19
18
  var http_1 = require("@apollo/client/link/http");
20
19
  var cross_fetch_1 = __importDefault(require("cross-fetch"));
21
20
  var context_1 = require("@apollo/client/link/context");
22
21
  var formDataHttpLink = function (baseUrl, headers) {
23
22
  return new http_1.HttpLink({
24
- uri: baseUrl + "/modules/graphql",
23
+ uri: "".concat(baseUrl, "/modules/graphql"),
25
24
  headers: headers,
26
25
  fetch: function (uri, fetcherOptions) {
27
26
  var options = __assign({}, fetcherOptions);
@@ -38,14 +37,14 @@ var formDataHttpLink = function (baseUrl, headers) {
38
37
  }
39
38
  fetcherOptions.body = formData_1;
40
39
  delete fetcherOptions.headers['content-type'];
41
- return cross_fetch_1["default"](uri, fetcherOptions);
40
+ return (0, cross_fetch_1.default)(uri, fetcherOptions);
42
41
  }
43
- return cross_fetch_1["default"](uri, fetcherOptions);
42
+ return (0, cross_fetch_1.default)(uri, fetcherOptions);
44
43
  }
45
44
  });
46
45
  };
47
46
  exports.formDataHttpLink = formDataHttpLink;
48
- exports.uploadLink = context_1.setContext(function (operation, _a) {
47
+ exports.uploadLink = (0, context_1.setContext)(function (operation, _a) {
49
48
  var fetchOptions = _a.fetchOptions;
50
49
  var variables = operation.variables;
51
50
  var fileFound = false;
@@ -0,0 +1,10 @@
1
+ export declare const BrowserHelper: {
2
+ logCookies: () => Cypress.Chainable<void>;
3
+ logCookie: (cookieName: string) => Cypress.Chainable<void>;
4
+ logSessionStorage: () => Cypress.Chainable<void>;
5
+ logLocalStorage: () => Cypress.Chainable<void>;
6
+ clearSessionCookies: () => Cypress.Chainable<void>;
7
+ clearPersistentCookies: () => Cypress.Chainable<void>;
8
+ simulateClose: () => void;
9
+ resetState: () => void;
10
+ };
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ /*
3
+ * Contains helpers for printing or clearing browser's storage and cookies.
4
+ * These are intended for interactive debugging and log full values by design.
5
+ * Use with caution in automated tests to avoid exposing sensitive data in logs.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.BrowserHelper = void 0;
9
+ /**
10
+ * Prints cookie details in a structured format for debugging.
11
+ *
12
+ * Note: This helper logs the full cookie value by design.
13
+ * @param {Cypress.Cookie} cookie Cookie object returned by Cypress.
14
+ * @returns {void}
15
+ * @private
16
+ */
17
+ var printCookieValues = function (cookie) {
18
+ var cookieType = cookie.expiry ? 'Persistent' : 'Session';
19
+ var expiryDate = cookie.expiry ? new Date(cookie.expiry * 1000).toISOString() : 'Session only';
20
+ var daysUntilExpiry = cookie.expiry ? Math.round(((cookie.expiry * 1000) - Date.now()) / 1000 / 60 / 60 / 24) : null;
21
+ cy.log('-'.repeat(60));
22
+ cy.log("Cookie: ".concat(cookie.name));
23
+ cy.log('-'.repeat(60));
24
+ cy.log("Type: ".concat(cookieType));
25
+ cy.log("Value: ".concat(cookie.value));
26
+ cy.log("Domain: ".concat(cookie.domain));
27
+ cy.log("Path: ".concat(cookie.path));
28
+ cy.log("Secure: ".concat(cookie.secure ? '✔ Yes' : '✘ No'));
29
+ cy.log("HttpOnly: ".concat(cookie.httpOnly ? '✔ Yes' : '✘ No'));
30
+ cy.log("SameSite: ".concat(cookie.sameSite || '(not set)'));
31
+ if (cookie.expiry) {
32
+ cy.log("Expires: ".concat(expiryDate));
33
+ cy.log("Days left: ".concat(daysUntilExpiry, " days"));
34
+ cy.log("Unix time: ".concat(cookie.expiry));
35
+ }
36
+ else {
37
+ cy.log('Expires: When browser closes (session cookie)');
38
+ }
39
+ };
40
+ /**
41
+ * Clears cookies based on their persistence type.
42
+ * @param {'session'|'persistent'} [type='session'] Cookie category to clear.
43
+ * @returns {Cypress.Chainable<void>} Cypress chainable resolved when clearing is complete.
44
+ */
45
+ var clearCookiesByType = function (type) {
46
+ if (type === void 0) { type = 'session'; }
47
+ return cy.getCookies().then(function (cookies) {
48
+ var cookiesToClear = cookies.filter(function (cookie) { return (type === 'session' ? !cookie.expiry : Boolean(cookie.expiry)); });
49
+ cy.step("\uD83D\uDDD1\uFE0F CLEAR ".concat(cookiesToClear.length, " ").concat(type, " cookie(s):"), function () {
50
+ cookiesToClear.forEach(function (cookie) {
51
+ var info = cookie.expiry ? "expires ".concat(new Date(cookie.expiry * 1000).toISOString()) : 'session only';
52
+ cy.log(" ... clearing ".concat(cookie.name, " (").concat(info, ")"));
53
+ cy.clearCookie(cookie.name);
54
+ });
55
+ });
56
+ }).then(function () { return undefined; });
57
+ };
58
+ /**
59
+ * Logs all available cookies with metadata and values.
60
+ *
61
+ * Intended for interactive debugging when full cookie visibility is needed.
62
+ * @returns {Cypress.Chainable<void>} Cypress chainable resolved when logging is complete.
63
+ */
64
+ var logCookies = function () {
65
+ return cy.getCookies().then(function (cookies) {
66
+ if (cookies.length === 0) {
67
+ cy.log('No cookies found');
68
+ return;
69
+ }
70
+ cy.step("COOKIES REPORT - Total: ".concat(cookies.length), function () {
71
+ var sessionCookies = cookies.filter(function (c) { return !c.expiry; });
72
+ var persistentCookies = cookies.filter(function (c) { return Boolean(c.expiry); });
73
+ cy.log("Session Cookies: ".concat(sessionCookies.length));
74
+ cy.log("Persistent Cookies: ".concat(persistentCookies.length));
75
+ cookies.forEach(function (cookie) {
76
+ printCookieValues(cookie);
77
+ });
78
+ });
79
+ }).then(function () { return undefined; });
80
+ };
81
+ /**
82
+ * Logs a specific cookie by name in a detailed format.
83
+ *
84
+ * Intended for interactive debugging when full cookie visibility is needed.
85
+ * @param {string} cookieName Name of the cookie to read and print.
86
+ * @returns {Cypress.Chainable<void>} Cypress chainable resolved when logging is complete.
87
+ */
88
+ var logCookie = function (cookieName) {
89
+ return cy.getCookie(cookieName).then(function (cookie) {
90
+ if (!cookie) {
91
+ cy.log("Cookie \"".concat(cookieName, "\" not found"));
92
+ return;
93
+ }
94
+ printCookieValues(cookie);
95
+ }).then(function () { return undefined; });
96
+ };
97
+ /**
98
+ * Clears Session cookies
99
+ * @returns {Cypress.Chainable<void>} Cypress chainable resolved when logging is complete.
100
+ */
101
+ var clearSessionCookies = function () {
102
+ return clearCookiesByType('session').then(function () { return undefined; });
103
+ };
104
+ /**
105
+ * Clears Persistent cookies
106
+ * @returns {Cypress.Chainable<void>} Cypress chainable resolved when logging is complete.
107
+ */
108
+ var clearPersistentCookies = function () {
109
+ return clearCookiesByType('persistent').then(function () { return undefined; });
110
+ };
111
+ /**
112
+ * Simulates a browser close by clearing session storage and cookies.
113
+ * Persistent cookies are kept intentionally.
114
+ * @returns {void}
115
+ */
116
+ var simulateClose = function () {
117
+ cy.log('Simulating browser close...');
118
+ // Clear session storage
119
+ cy.clearAllSessionStorage();
120
+ // Clear session cookies only
121
+ clearSessionCookies();
122
+ cy.log('Browser close simulated (session storage and cookies are cleared)');
123
+ };
124
+ /**
125
+ * Resets browser state by clearing all storages and all cookies.
126
+ * Use this when a test needs a fully clean client-side state.
127
+ * @returns {void}
128
+ */
129
+ var resetState = function () {
130
+ cy.log('Reset browser state...');
131
+ // Clear all storage
132
+ cy.clearAllLocalStorage();
133
+ cy.clearAllSessionStorage();
134
+ // Clear all cookies
135
+ cy.clearAllCookies();
136
+ cy.log('Browser reset is done (all storages and cookies cleared)');
137
+ };
138
+ /**
139
+ * Logs all sessionStorage entries grouped by origin.
140
+ * Intended for interactive debugging and logs full values.
141
+ * @returns {Cypress.Chainable<void>} Cypress chainable resolved when logging is complete.
142
+ */
143
+ var logSessionStorage = function () {
144
+ return cy.getAllSessionStorage().then(function (session) {
145
+ cy.log("sessionStorage: ".concat(JSON.stringify(session)));
146
+ }).then(function () { return undefined; });
147
+ };
148
+ /**
149
+ * Logs all localStorage entries grouped by origin.
150
+ * Intended for interactive debugging and logs full values.
151
+ * @returns {Cypress.Chainable<void>} Cypress chainable resolved when logging is complete.
152
+ */
153
+ var logLocalStorage = function () {
154
+ return cy.getAllLocalStorage().then(function (local) {
155
+ cy.log("localStorage: ".concat(JSON.stringify(local)));
156
+ }).then(function () { return undefined; });
157
+ };
158
+ exports.BrowserHelper = {
159
+ logCookies: logCookies,
160
+ logCookie: logCookie,
161
+ logSessionStorage: logSessionStorage,
162
+ logLocalStorage: logLocalStorage,
163
+ clearSessionCookies: clearSessionCookies,
164
+ clearPersistentCookies: clearPersistentCookies,
165
+ simulateClose: simulateClose,
166
+ resetState: resetState
167
+ };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("cypress-wait-until");
4
4
  require("cypress-real-events");
@@ -1,2 +1,2 @@
1
1
  import Chainable = Cypress.Chainable;
2
- export declare const fixture: (originalCommand: (...args: any[]) => any, fixtureParam: string, ...args: any[]) => Chainable<any>;
2
+ export declare const fixture: (originalCommand: ((...args: any[]) => any), fixtureParam: string, ...args: any[]) => Chainable<any>;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
- to[j] = from[i];
5
- return to;
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
6
10
  };
7
- exports.__esModule = true;
11
+ Object.defineProperty(exports, "__esModule", { value: true });
8
12
  exports.fixture = void 0;
9
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
14
  var fixture = function (originalCommand, fixtureParam) {
@@ -13,9 +17,9 @@ var fixture = function (originalCommand, fixtureParam) {
13
17
  args[_i - 2] = arguments[_i];
14
18
  }
15
19
  return cy.wrap({}, { log: false }).then(function () {
16
- return originalCommand.apply(void 0, __spreadArray([fixtureParam], args)).then(function (f) {
20
+ return originalCommand.apply(void 0, __spreadArray([fixtureParam], args, false)).then(function (f) {
17
21
  return f;
18
- })["catch"](function () {
22
+ }).catch(function () {
19
23
  return null;
20
24
  });
21
25
  }).then(function (file) {
@@ -5,3 +5,6 @@ export * from './logout';
5
5
  export * from './repeatUntil';
6
6
  export * from './testStep';
7
7
  export * from './jsErrorsLogger';
8
+ export * from './jfaker';
9
+ export * from './browserHelper';
10
+ export * from './modSince';
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -9,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
- exports.__esModule = true;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./apollo"), exports);
14
18
  __exportStar(require("./provisioning"), exports);
15
19
  __exportStar(require("./login"), exports);
@@ -17,3 +21,6 @@ __exportStar(require("./logout"), exports);
17
21
  __exportStar(require("./repeatUntil"), exports);
18
22
  __exportStar(require("./testStep"), exports);
19
23
  __exportStar(require("./jsErrorsLogger"), exports);
24
+ __exportStar(require("./jfaker"), exports);
25
+ __exportStar(require("./browserHelper"), exports);
26
+ __exportStar(require("./modSince"), exports);
@@ -0,0 +1,60 @@
1
+ /**
2
+ * jfaker - A flexible data generator for Cypress tests, supporting both faker.js generated data and custom injection payloads.
3
+ *
4
+ * This module provides a unified interface to generate either faker data or custom injection payloads based on the method called and global settings.
5
+ * It uses a dynamic Proxy to handle method calls and determine whether to generate faker data or injection data.
6
+ *
7
+ * IMPORTANT:
8
+ * When using the generated strings from jfaker in Cypress commands like `.type()`, make sure to:
9
+ * use `parseSpecialCharSequences: false`, e.g.: `<input>.type(text, {parseSpecialCharSequences: false})`
10
+ * to prevent Cypress from interpreting special characters in the generated strings (e.g., {, }, [, ], etc.) as commands,
11
+ * which is especially important for injection payloads that may contain such characters.
12
+ */
13
+ /**
14
+ * Interface to Fake Data generator (using DeepApi proxy to handle dynamic method calls)
15
+ * @param {Record<string, unknown>} options Options for data generation (length for injections, faker options, safe flag), \
16
+ * e.g.: `{length: 100}` for injections to specify desired length of the generated string, \
17
+ * or `{provider: 'example.com'}` for faker to pass options to the faker method. \
18
+ * For faker data generation, an additional option `safe` can be set to `true` \
19
+ * to force faker generation regardless of global type settings \
20
+ * (useful for specific cases where faker data is needed even when global type is set to injection).
21
+ * @remarks
22
+ * Available injection methods:
23
+ * - `.xss()` - Generate XSS injection payloads
24
+ * - `.sql()` - Generate SQL injection payloads
25
+ * - `.bash()` - Generate Bash injection payloads
26
+ * - `.chars()` - Generate random special characters
27
+ * - `.htmlentities()` - Generate HTML entities
28
+ * - `.numbers()` - Generate random numbers entities and edge cases
29
+ * - or any faker.js method can also be called (e.g., `person.firstName()`, `internet.email()`)
30
+ *
31
+ * @returns {string} Generated data string based on the method called and options provided
32
+ *
33
+ * @see https://fakerjs.dev/api/ for available faker methods and options
34
+ * @example
35
+ * ```typescript
36
+ *
37
+ * // Generate faker data with entity.
38
+ * const name = jfaker.person.firstName();
39
+ *
40
+ * // Entity will always be generated using faker (safe: true)
41
+ * const name = jfaker.person.firstName({safe: true});
42
+ *
43
+ * // Generate faker data with options.
44
+ * const email = jfaker.internet.email({provider: 'example.com'});
45
+ *
46
+ * // Generate injection payloads (random between min and max items joined into a single string)..
47
+ * // Entity will always be generated using 'xss'.
48
+ * const xssName = jfaker.xss();
49
+ *
50
+ * // Generate injection payloads with specific length.
51
+ * // Entity will always be generated using 'xss'.
52
+ * const xssName = jfaker.xss({length: 100});
53
+ *
54
+ * // Use all SQL injections.
55
+ * // Entity will always be generated using 'sql'.
56
+ * const allSql = jfaker.sql({length: -1});
57
+ * ```
58
+ */
59
+ declare const jfaker: any;
60
+ export { jfaker };