@jahia/cypress 3.25.0 → 3.26.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.
- package/dist/page-object/moonstone/menu.d.ts +3 -0
- package/dist/page-object/moonstone/menu.js +4 -0
- package/dist/utils/JCRHelper.d.ts +1 -0
- package/dist/utils/JCRHelper.js +18 -1
- package/dist/utils/SAMHelper.d.ts +34 -0
- package/dist/utils/SAMHelper.js +60 -29
- package/fixtures/graphql/jcr/mutation/uploadFile.graphql +11 -0
- package/fixtures/graphql/sam/healthStatus.graphql +5 -3
- package/package.json +5 -4
- package/schema.graphql +808 -128
- package/src/page-object/moonstone/menu.ts +6 -0
- package/src/utils/JCRHelper.ts +17 -0
- package/src/utils/SAMHelper.ts +52 -21
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {BaseComponent} from '../baseComponent';
|
|
2
2
|
import {getComponentByRole} from '../utils';
|
|
3
|
+
import Chainable = Cypress.Chainable;
|
|
3
4
|
|
|
4
5
|
export class Menu extends BaseComponent {
|
|
5
6
|
static defaultSelector = '.moonstone-menu:not(.moonstone-hidden)'
|
|
7
|
+
static overlaySelector = '.moonstone-menu_overlay';
|
|
6
8
|
|
|
7
9
|
submenu(item: string, menu: string): Menu {
|
|
8
10
|
this.get().find('.moonstone-menuItem').contains(item).scrollIntoView().should('be.visible');
|
|
@@ -29,4 +31,8 @@ export class Menu extends BaseComponent {
|
|
|
29
31
|
this.get().find(`.moonstone-menuItem[data-sel-role="${item}"]`).trigger('click');
|
|
30
32
|
return this;
|
|
31
33
|
}
|
|
34
|
+
|
|
35
|
+
close(): Chainable<unknown> {
|
|
36
|
+
return cy.get(Menu.overlaySelector).click('topRight');
|
|
37
|
+
}
|
|
32
38
|
}
|
package/src/utils/JCRHelper.ts
CHANGED
|
@@ -87,3 +87,20 @@ export const getNodeTypes = (filter = {}): Cypress.Chainable => {
|
|
|
87
87
|
queryFile: 'graphql/jcr/query/getNodeTypes.graphql'
|
|
88
88
|
});
|
|
89
89
|
};
|
|
90
|
+
|
|
91
|
+
export const uploadFile = (fixturePath: string, parentPathOrId: string, name: string, mimeType: string): Cypress.Chainable => {
|
|
92
|
+
return cy.fixture(fixturePath, 'binary')
|
|
93
|
+
.then(image => {
|
|
94
|
+
const blob = Cypress.Blob.binaryStringToBlob(image, mimeType);
|
|
95
|
+
const file = new File([blob], name, {type: blob.type});
|
|
96
|
+
return cy.apollo({
|
|
97
|
+
mutationFile: 'graphql/jcr/mutation/uploadFile.graphql',
|
|
98
|
+
variables: {
|
|
99
|
+
parentPathOrId,
|
|
100
|
+
name,
|
|
101
|
+
mimeType,
|
|
102
|
+
file
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
package/src/utils/SAMHelper.ts
CHANGED
|
@@ -1,36 +1,67 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import Chainable = Cypress.Chainable
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let lastGraphqlResponse = {};
|
|
14
|
-
cy.waitUntil(() =>
|
|
15
|
-
cy.apollo({
|
|
4
|
+
/**
|
|
5
|
+
* Simple health check query
|
|
6
|
+
* @param severity the severity of the health check, default is MEDIUM
|
|
7
|
+
* @param probeHealthFilter the filter for the health check probes, default is GREEN
|
|
8
|
+
*/
|
|
9
|
+
export const healthCheck = (severity = 'MEDIUM', probeHealthFilter = 'GREEN'): Chainable<any> => {
|
|
10
|
+
return cy
|
|
11
|
+
.apollo({
|
|
16
12
|
fetchPolicy: 'no-cache',
|
|
17
13
|
queryFile: 'graphql/sam/healthStatus.graphql',
|
|
18
14
|
variables: {
|
|
19
|
-
severity
|
|
15
|
+
severity,
|
|
16
|
+
probeHealthFilter
|
|
20
17
|
}
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
})
|
|
19
|
+
.then((response: any) => {
|
|
20
|
+
return response?.data?.admin?.jahia?.healthCheck;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Wait until the health check returns the expected health
|
|
26
|
+
* @param expectedHealth the expected health status
|
|
27
|
+
* @param severity the severity of the health check, default is MEDIUM
|
|
28
|
+
* @param probeHealthFilter the filter for the health check probes, default is GREEN
|
|
29
|
+
* @param timeout the timeout in milliseconds, default is 60000
|
|
30
|
+
* @param interval the interval in milliseconds, default is 500
|
|
31
|
+
* @param statusMatchCount the number of consecutive status matches before the waitUntil resolves, default is 1
|
|
32
|
+
*/
|
|
33
|
+
export const waitUntilSAMStatus = ({expectedHealth, severity = 'MEDIUM', probeHealthFilter = 'GREEN', timeout = 60000, interval = 500, statusMatchCount = 1}) : void => {
|
|
34
|
+
let statusCount = 0;
|
|
35
|
+
let lastGraphqlResponse = {};
|
|
36
|
+
cy.waitUntil(() =>
|
|
37
|
+
healthCheck(severity, probeHealthFilter).then(result => {
|
|
38
|
+
lastGraphqlResponse = result;
|
|
39
|
+
const healthStatus = result?.status;
|
|
24
40
|
if (healthStatus) {
|
|
25
|
-
|
|
26
|
-
return
|
|
41
|
+
statusCount = healthStatus.health === expectedHealth ? statusCount + 1 : 0;
|
|
42
|
+
return statusCount >= statusMatchCount;
|
|
27
43
|
}
|
|
28
44
|
}),
|
|
29
45
|
{
|
|
30
|
-
errorMsg: `Timeout waiting for SAM to be
|
|
46
|
+
errorMsg: `Timeout waiting for SAM to be ${expectedHealth} for severity: ${severity} and probeHealthFilter: ${probeHealthFilter}. Last GraphQL response: ${JSON.stringify(lastGraphqlResponse)}`,
|
|
31
47
|
timeout: timeout,
|
|
32
48
|
verbose: true,
|
|
33
49
|
interval: interval
|
|
34
50
|
});
|
|
35
51
|
};
|
|
36
52
|
|
|
53
|
+
/**
|
|
54
|
+
When Jahia is starting or performing provisioning operations
|
|
55
|
+
it is expected for the SAM probe to alternate beween GREEN, YELLOW and RED statuses.
|
|
56
|
+
|
|
57
|
+
The primary use of this method is to wait until a Jahia platform stabilizes after a startup or
|
|
58
|
+
provisioning operation.
|
|
59
|
+
|
|
60
|
+
Instead of waiting only for one occurence of a GREEN status, this function will wait until the a
|
|
61
|
+
GREEN status was returned a number of consecutive times (greenMatchCount).
|
|
62
|
+
*/
|
|
63
|
+
export const waitUntilSAMStatusGreen = (severity = 'MEDIUM', timeout = 60000, interval = 500, greenMatchCount = 10) : void => {
|
|
64
|
+
// We use YELLOW as the probeHealthFilter because we are not interested in potential GREEN probes in the response
|
|
65
|
+
waitUntilSAMStatus({expectedHealth: 'GREEN', severity, probeHealthFilter: 'YELLOW', timeout, interval, statusMatchCount: greenMatchCount});
|
|
66
|
+
};
|
|
67
|
+
|