@jahia/cypress 3.21.1 → 3.22.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.
@@ -4,18 +4,18 @@ exports.apolloClient = exports.switchApolloClient = void 0;
4
4
  var core_1 = require("@apollo/client/core");
5
5
  var links_1 = require("./links");
6
6
  var switchApolloClient = function (config, options) {
7
- if (config === void 0) { config = { url: Cypress.config().baseUrl }; }
7
+ if (config === void 0) { config = {}; }
8
8
  if (options === void 0) { options = {
9
9
  log: true,
10
10
  setCurrentApolloClient: true
11
11
  }; }
12
12
  // Switch context to apollo client
13
- cy.visit(config.url, { failOnStatusCode: false });
13
+ cy.visit(config.url || Cypress.config().baseUrl, { failOnStatusCode: false });
14
14
  return exports.apolloClient(config, options);
15
15
  };
16
16
  exports.switchApolloClient = switchApolloClient;
17
17
  var apolloClient = function (config, options) {
18
- if (config === void 0) { config = { url: Cypress.config().baseUrl }; }
18
+ if (config === void 0) { config = {}; }
19
19
  if (options === void 0) { options = {
20
20
  log: true,
21
21
  setCurrentApolloClient: true
@@ -30,7 +30,7 @@ var apolloClient = function (config, options) {
30
30
  else {
31
31
  headers.authorization = "Basic " + btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'));
32
32
  }
33
- var links = [links_1.uploadLink, links_1.formDataHttpLink(config.url, headers)];
33
+ var links = [links_1.uploadLink, links_1.formDataHttpLink(config.url || Cypress.config().baseUrl, headers)];
34
34
  var client = new core_1.ApolloClient({
35
35
  link: core_1.from(links),
36
36
  cache: new core_1.InMemoryCache(),
@@ -17,6 +17,7 @@ var waitUntilSAMStatusGreen = function (severity, timeout, interval, greenMatchC
17
17
  if (interval === void 0) { interval = 500; }
18
18
  if (greenMatchCount === void 0) { greenMatchCount = 10; }
19
19
  var greenCount = 0;
20
+ var lastGraphqlResponse = {};
20
21
  cy.waitUntil(function () {
21
22
  return cy.apollo({
22
23
  fetchPolicy: 'no-cache',
@@ -25,15 +26,16 @@ var waitUntilSAMStatusGreen = function (severity, timeout, interval, greenMatchC
25
26
  severity: severity
26
27
  }
27
28
  }).then(function (result) {
28
- var _a, _b, _c, _d;
29
+ var _a, _b, _c, _d, _e, _f, _g;
29
30
  var healthStatus = (_d = (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.admin) === null || _b === void 0 ? void 0 : _b.jahia) === null || _c === void 0 ? void 0 : _c.healthCheck) === null || _d === void 0 ? void 0 : _d.status;
31
+ lastGraphqlResponse = (_g = (_f = (_e = result === null || result === void 0 ? void 0 : result.data) === null || _e === void 0 ? void 0 : _e.admin) === null || _f === void 0 ? void 0 : _f.jahia) === null || _g === void 0 ? void 0 : _g.healthCheck;
30
32
  if (healthStatus) {
31
33
  greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
32
34
  return greenCount >= greenMatchCount;
33
35
  }
34
36
  });
35
37
  }, {
36
- errorMsg: "Timeout waiting for SAM to be green for severity: " + severity,
38
+ errorMsg: "Timeout waiting for SAM to be green for severity: " + severity + ". Last GraphQL response: " + JSON.stringify(lastGraphqlResponse),
37
39
  timeout: timeout,
38
40
  verbose: true,
39
41
  interval: interval
@@ -6,6 +6,13 @@ query($severity: GqlProbeSeverity) {
6
6
  health
7
7
  message
8
8
  }
9
+ probes(health: YELLOW) {
10
+ name
11
+ status {
12
+ health
13
+ message
14
+ }
15
+ }
9
16
  }
10
17
  }
11
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.21.1",
3
+ "version": "3.22.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -22,16 +22,16 @@ export type ApolloClientOptions = Cypress.Loggable & {
22
22
  setCurrentApolloClient: boolean
23
23
  }
24
24
 
25
- export const switchApolloClient = function (config: HostConfig = {url: Cypress.config().baseUrl}, options: ApolloClientOptions = {
25
+ export const switchApolloClient = function (config: HostConfig = {}, options: ApolloClientOptions = {
26
26
  log: true,
27
27
  setCurrentApolloClient: true
28
28
  }): void {
29
29
  // Switch context to apollo client
30
- cy.visit(config.url, {failOnStatusCode: false});
30
+ cy.visit(config.url || Cypress.config().baseUrl, {failOnStatusCode: false});
31
31
  return apolloClient(config, options);
32
32
  };
33
33
 
34
- export const apolloClient = function (config: HostConfig = {url: Cypress.config().baseUrl}, options: ApolloClientOptions = {
34
+ export const apolloClient = function (config: HostConfig = {}, options: ApolloClientOptions = {
35
35
  log: true,
36
36
  setCurrentApolloClient: true
37
37
  }): void {
@@ -44,7 +44,7 @@ export const apolloClient = function (config: HostConfig = {url: Cypress.config(
44
44
  headers.authorization = `Basic ${btoa('root:' + Cypress.env('SUPER_USER_PASSWORD'))}`;
45
45
  }
46
46
 
47
- const links = [uploadLink, formDataHttpLink(config.url, headers)];
47
+ const links = [uploadLink, formDataHttpLink(config.url || Cypress.config().baseUrl, headers)];
48
48
 
49
49
  const client = new ApolloClient({
50
50
  link: from(links),
@@ -10,6 +10,7 @@
10
10
  */
11
11
  export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => {
12
12
  let greenCount = 0;
13
+ let lastGraphqlResponse = {};
13
14
  cy.waitUntil(() =>
14
15
  cy.apollo({
15
16
  fetchPolicy: 'no-cache',
@@ -19,13 +20,14 @@ export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, in
19
20
  }
20
21
  }).then(result => {
21
22
  const healthStatus = result?.data?.admin?.jahia?.healthCheck?.status;
23
+ lastGraphqlResponse = result?.data?.admin?.jahia?.healthCheck;
22
24
  if (healthStatus) {
23
25
  greenCount = healthStatus.health === 'GREEN' ? greenCount + 1 : 0;
24
26
  return greenCount >= greenMatchCount;
25
27
  }
26
28
  }),
27
29
  {
28
- errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}`,
30
+ errorMsg: `Timeout waiting for SAM to be green for severity: ${severity}. Last GraphQL response: ${JSON.stringify(lastGraphqlResponse)}`,
29
31
  timeout: timeout,
30
32
  verbose: true,
31
33
  interval: interval