@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.
- package/CHANGELOG.md +35 -0
- package/README.md +69 -2
- package/dist/index.js +6 -2
- package/dist/injections/bash-data.d.ts +1 -0
- package/dist/injections/bash-data.js +57 -0
- package/dist/injections/chars-data.d.ts +1 -0
- package/dist/injections/chars-data.js +25 -0
- package/dist/injections/htmlentities-data.d.ts +1 -0
- package/dist/injections/htmlentities-data.js +22 -0
- package/dist/injections/numbers-data.d.ts +1 -0
- package/dist/injections/numbers-data.js +66 -0
- package/dist/injections/sql-data.d.ts +1 -0
- package/dist/injections/sql-data.js +82 -0
- package/dist/injections/xss-data.d.ts +1 -0
- package/dist/injections/xss-data.js +740 -0
- package/dist/page-object/baseComponent.d.ts +1 -2
- package/dist/page-object/baseComponent.js +10 -6
- package/dist/page-object/basePage.js +1 -1
- package/dist/page-object/html/iframe.d.ts +0 -1
- package/dist/page-object/html/iframe.js +2 -2
- package/dist/page-object/html/index.js +6 -2
- package/dist/page-object/index.js +6 -2
- package/dist/page-object/material/index.js +6 -2
- package/dist/page-object/material/muiinput.d.ts +0 -1
- package/dist/page-object/material/muiinput.js +1 -1
- package/dist/page-object/material/muiradio.js +1 -1
- package/dist/page-object/moonstone/accordion.d.ts +0 -1
- package/dist/page-object/moonstone/accordion.js +2 -2
- package/dist/page-object/moonstone/button.js +1 -1
- package/dist/page-object/moonstone/collapsible.js +1 -1
- package/dist/page-object/moonstone/dropdown.js +2 -2
- package/dist/page-object/moonstone/index.js +6 -2
- package/dist/page-object/moonstone/menu.js +9 -9
- package/dist/page-object/moonstone/pagination.js +3 -3
- package/dist/page-object/moonstone/primaryNav.js +2 -2
- package/dist/page-object/moonstone/secondaryNav.js +1 -1
- package/dist/page-object/moonstone/table.d.ts +0 -1
- package/dist/page-object/moonstone/table.js +5 -5
- package/dist/page-object/utils.d.ts +0 -1
- package/dist/page-object/utils.js +11 -12
- package/dist/plugins/env.js +2 -2
- package/dist/plugins/index.js +6 -2
- package/dist/plugins/registerPlugins.js +2 -2
- package/dist/support/apollo/apollo.d.ts +5 -4
- package/dist/support/apollo/apollo.js +80 -18
- package/dist/support/apollo/apolloClient.d.ts +1 -2
- package/dist/support/apollo/apolloClient.js +7 -7
- package/dist/support/apollo/index.js +6 -2
- package/dist/support/apollo/links.d.ts +1 -1
- package/dist/support/apollo/links.js +5 -6
- package/dist/support/browserHelper.d.ts +10 -0
- package/dist/support/browserHelper.js +167 -0
- package/dist/support/commands.js +1 -1
- package/dist/support/fixture.d.ts +1 -1
- package/dist/support/fixture.js +11 -7
- package/dist/support/index.d.ts +3 -0
- package/dist/support/index.js +9 -2
- package/dist/support/jfaker.d.ts +60 -0
- package/dist/support/jfaker.js +241 -0
- package/dist/support/jsErrorsLogger.js +13 -9
- package/dist/support/login.d.ts +0 -1
- package/dist/support/login.js +2 -2
- package/dist/support/logout.d.ts +0 -1
- package/dist/support/logout.js +1 -1
- package/dist/support/modSince.d.ts +52 -0
- package/dist/support/modSince.js +180 -0
- package/dist/support/provisioning/executeGroovy.d.ts +1 -1
- package/dist/support/provisioning/executeGroovy.js +42 -3
- package/dist/support/provisioning/index.js +6 -2
- package/dist/support/provisioning/installConfig.d.ts +0 -1
- package/dist/support/provisioning/installConfig.js +3 -3
- package/dist/support/provisioning/installModule.d.ts +0 -1
- package/dist/support/provisioning/installModule.js +1 -1
- package/dist/support/provisioning/runProvisioningScript.d.ts +4 -5
- package/dist/support/provisioning/runProvisioningScript.js +86 -9
- package/dist/support/provisioning/uninstallModule.d.ts +0 -1
- package/dist/support/provisioning/uninstallModule.js +1 -1
- package/dist/support/registerSupport.js +35 -1
- package/dist/support/repeatUntil.d.ts +1 -2
- package/dist/support/repeatUntil.js +2 -2
- package/dist/support/testStep.js +2 -2
- package/dist/utils/ClusterHelper.js +1 -1
- package/dist/utils/ExportHelper.d.ts +2 -2
- package/dist/utils/ExportHelper.js +14 -10
- package/dist/utils/GraphQLHelper.js +21 -17
- package/dist/utils/JCRHelper.d.ts +1 -1
- package/dist/utils/JCRHelper.js +1 -1
- package/dist/utils/JahiaPlatformHelper.js +2 -2
- package/dist/utils/Logger.js +6 -6
- package/dist/utils/PublicationAndWorkflowHelper.js +3 -3
- package/dist/utils/SAMHelper.d.ts +1 -1
- package/dist/utils/SAMHelper.js +4 -4
- package/dist/utils/SiteHelper.js +2 -2
- package/dist/utils/UsersHelper.js +2 -2
- package/dist/utils/VanityUrlHelper.js +1 -1
- package/dist/utils/index.js +6 -2
- package/docs/browser-helper.md +158 -0
- package/docs/jfaker.md +450 -0
- package/package.json +13 -10
- package/src/injections/bash-data.ts +54 -0
- package/src/injections/chars-data.ts +22 -0
- package/src/injections/htmlentities-data.ts +19 -0
- package/src/injections/numbers-data.ts +63 -0
- package/src/injections/sql-data.ts +79 -0
- package/src/injections/xss-data.ts +737 -0
- package/src/page-object/baseComponent.ts +6 -6
- package/src/page-object/html/iframe.ts +3 -3
- package/src/page-object/material/muiinput.ts +1 -1
- package/src/page-object/material/muiradio.ts +1 -1
- package/src/page-object/moonstone/accordion.ts +1 -1
- package/src/page-object/moonstone/button.ts +1 -1
- package/src/page-object/moonstone/collapsible.ts +1 -1
- package/src/page-object/moonstone/dropdown.ts +1 -1
- package/src/page-object/moonstone/menu.ts +1 -1
- package/src/page-object/moonstone/pagination.ts +1 -1
- package/src/page-object/moonstone/primaryNav.ts +1 -1
- package/src/page-object/moonstone/secondaryNav.ts +1 -1
- package/src/page-object/moonstone/table.ts +2 -2
- package/src/support/apollo/apollo.ts +74 -11
- package/src/support/apollo/links.ts +1 -2
- package/src/support/browserHelper.ts +186 -0
- package/src/support/index.ts +3 -0
- package/src/support/jfaker.ts +245 -0
- package/src/support/modSince.ts +222 -0
- package/src/support/provisioning/executeGroovy.md +7 -1
- package/src/support/provisioning/executeGroovy.ts +46 -2
- package/src/support/provisioning/runProvisioningScript.ts +89 -12
- package/src/support/registerSupport.ts +29 -0
- package/tests/cypress/e2e/jfaker.spec.ts +411 -0
- package/tests/cypress/e2e/modSince.spec.ts +306 -0
- package/tests/cypress.config.ts +23 -0
- package/tests/package.json +41 -0
- package/tests/reporter-config.json +13 -0
- package/tests/yarn.lock +8578 -0
- package/tsconfig.json +3 -0
package/dist/utils/SAMHelper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.waitUntilSAMStatusGreen = exports.waitUntilSAMStatus = exports.healthCheck = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Simple health check query
|
|
@@ -42,7 +42,7 @@ var waitUntilSAMStatus = function (_a) {
|
|
|
42
42
|
var statusCount = 0;
|
|
43
43
|
var lastGraphqlResponse = {};
|
|
44
44
|
cy.waitUntil(function () {
|
|
45
|
-
return exports.healthCheck(severity, probeHealthFilter, probeNamesFilter).then(function (result) {
|
|
45
|
+
return (0, exports.healthCheck)(severity, probeHealthFilter, probeNamesFilter).then(function (result) {
|
|
46
46
|
lastGraphqlResponse = result;
|
|
47
47
|
var healthStatus = result === null || result === void 0 ? void 0 : result.status;
|
|
48
48
|
if (healthStatus) {
|
|
@@ -52,7 +52,7 @@ var waitUntilSAMStatus = function (_a) {
|
|
|
52
52
|
});
|
|
53
53
|
}, {
|
|
54
54
|
errorMsg: function () {
|
|
55
|
-
return "Timeout waiting for SAM to be "
|
|
55
|
+
return "Timeout waiting for SAM to be ".concat(expectedHealth, " for severity: ").concat(severity, " and probeHealthFilter: ").concat(probeHealthFilter, ". Last GraphQL response: ").concat(JSON.stringify(lastGraphqlResponse));
|
|
56
56
|
},
|
|
57
57
|
timeout: timeout,
|
|
58
58
|
verbose: true,
|
|
@@ -76,6 +76,6 @@ var waitUntilSAMStatusGreen = function (severity, timeout, interval, greenMatchC
|
|
|
76
76
|
if (interval === void 0) { interval = 500; }
|
|
77
77
|
if (greenMatchCount === void 0) { greenMatchCount = 10; }
|
|
78
78
|
// We use YELLOW as the probeHealthFilter because we are not interested in potential GREEN probes in the response
|
|
79
|
-
exports.waitUntilSAMStatus({ expectedHealth: 'GREEN', severity: severity, probeHealthFilter: 'YELLOW', timeout: timeout, interval: interval, statusMatchCount: greenMatchCount });
|
|
79
|
+
(0, exports.waitUntilSAMStatus)({ expectedHealth: 'GREEN', severity: severity, probeHealthFilter: 'YELLOW', timeout: timeout, interval: interval, statusMatchCount: greenMatchCount });
|
|
80
80
|
};
|
|
81
81
|
exports.waitUntilSAMStatusGreen = waitUntilSAMStatusGreen;
|
package/dist/utils/SiteHelper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.editSite = exports.disableModule = exports.enableModule = exports.deleteSite = exports.createSite = void 0;
|
|
4
4
|
// eslint-disable-next-line default-param-last
|
|
5
5
|
var createSite = function (siteKey, config, jahiaServer) {
|
|
@@ -32,7 +32,7 @@ exports.enableModule = enableModule;
|
|
|
32
32
|
var disableModule = function (moduleName, siteKey) {
|
|
33
33
|
cy.apollo({
|
|
34
34
|
mutationFile: 'graphql/jcr/mutation/disableModule.graphql',
|
|
35
|
-
variables: { moduleName: moduleName, pathOrId: "/sites/"
|
|
35
|
+
variables: { moduleName: moduleName, pathOrId: "/sites/".concat(siteKey) }
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
exports.disableModule = disableModule;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addUserToGroup = exports.deleteGroup = exports.createGroup = exports.deleteUser = exports.getUserPath = exports.createUser = exports.revokeRoles = exports.grantRoles = void 0;
|
|
4
4
|
var grantRoles = function (pathOrId, roleNames, principalName, principalType) {
|
|
5
5
|
cy.log('Grant role(s) ' + roleNames + ' with principal type ' + principalType + ' to ' + principalName + ' on node ' + pathOrId);
|
|
@@ -79,7 +79,7 @@ var addUserToGroup = function (userName, groupName, siteKey) {
|
|
|
79
79
|
cy.executeGroovy('groovy/admin/addUserToGroup.groovy', {
|
|
80
80
|
USER_NAME: userName,
|
|
81
81
|
GROUP_NAME: groupName,
|
|
82
|
-
SITE_KEY: siteKey ? "\""
|
|
82
|
+
SITE_KEY: siteKey ? "\"".concat(siteKey, "\"") : 'null'
|
|
83
83
|
});
|
|
84
84
|
};
|
|
85
85
|
exports.addUserToGroup = addUserToGroup;
|
package/dist/utils/index.js
CHANGED
|
@@ -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.
|
|
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
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./JCRHelper"), exports);
|
|
14
18
|
__exportStar(require("./PublicationAndWorkflowHelper"), exports);
|
|
15
19
|
__exportStar(require("./SiteHelper"), exports);
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Browser Helpers
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Browser Helpers module provides exported helper functions for debugging and managing browser storage (`cookies`, `localStorage`, `sessionStorage`) in Cypress tests.
|
|
6
|
+
|
|
7
|
+
Warning: These helpers log full storage/cookie values by design. Use carefully in automated runs to avoid leaking tokens, credentials, or session identifiers in logs.
|
|
8
|
+
|
|
9
|
+
## Import and Usage Model
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import {BrowserHelper} from '@jahia/cypress';
|
|
13
|
+
|
|
14
|
+
it('inspects browser state', () => {
|
|
15
|
+
cy.login();
|
|
16
|
+
BrowserHelper.logCookies();
|
|
17
|
+
BrowserHelper.logLocalStorage();
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Available Helpers
|
|
22
|
+
|
|
23
|
+
### `BrowserHelper.logCookies()`
|
|
24
|
+
|
|
25
|
+
Logs all available cookies with metadata and values.
|
|
26
|
+
|
|
27
|
+
- Returns: `Cypress.Chainable<void>`
|
|
28
|
+
- Typical use: inspect authentication and security cookie attributes during debugging
|
|
29
|
+
|
|
30
|
+
### `BrowserHelper.logCookie(cookieName)`
|
|
31
|
+
|
|
32
|
+
Logs one cookie by name in a detailed format.
|
|
33
|
+
|
|
34
|
+
- Parameters: `cookieName: string`
|
|
35
|
+
- Returns: `Cypress.Chainable<void>`
|
|
36
|
+
|
|
37
|
+
### `BrowserHelper.clearSessionCookies()`
|
|
38
|
+
|
|
39
|
+
Clears only session cookies.
|
|
40
|
+
|
|
41
|
+
- Returns: `Cypress.Chainable<void>`
|
|
42
|
+
|
|
43
|
+
### `BrowserHelper.clearPersistentCookies()`
|
|
44
|
+
|
|
45
|
+
Clears only persistent cookies.
|
|
46
|
+
|
|
47
|
+
- Returns: `Cypress.Chainable<void>`
|
|
48
|
+
|
|
49
|
+
### `BrowserHelper.simulateClose()`
|
|
50
|
+
|
|
51
|
+
Simulates a browser close by clearing `sessionStorage` and session cookies only.
|
|
52
|
+
|
|
53
|
+
- Returns: `void`
|
|
54
|
+
- Clears: session cookies + all `sessionStorage`
|
|
55
|
+
- Keeps: persistent cookies + `localStorage`
|
|
56
|
+
|
|
57
|
+
### `BrowserHelper.resetState()`
|
|
58
|
+
|
|
59
|
+
Resets browser client-side state by clearing all cookies and all storages.
|
|
60
|
+
|
|
61
|
+
- Returns: `void`
|
|
62
|
+
- Clears: all cookies + all `localStorage` + all `sessionStorage`
|
|
63
|
+
|
|
64
|
+
### `BrowserHelper.logSessionStorage()`
|
|
65
|
+
|
|
66
|
+
Logs all `sessionStorage` entries grouped by origin.
|
|
67
|
+
|
|
68
|
+
- Returns: `Cypress.Chainable<void>`
|
|
69
|
+
|
|
70
|
+
### `BrowserHelper.logLocalStorage()`
|
|
71
|
+
|
|
72
|
+
Logs all `localStorage` entries grouped by origin.
|
|
73
|
+
|
|
74
|
+
- Returns: `Cypress.Chainable<void>`
|
|
75
|
+
|
|
76
|
+
## Integration Examples
|
|
77
|
+
|
|
78
|
+
### Authentication Debugging
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import {BrowserHelper} from '@jahia/cypress';
|
|
82
|
+
|
|
83
|
+
describe('Authentication Flow', () => {
|
|
84
|
+
it('keeps session after reload', () => {
|
|
85
|
+
cy.step('Login', () => {
|
|
86
|
+
cy.login('testuser@example.com', 'password');
|
|
87
|
+
BrowserHelper.logCookie('JSESSIONID');
|
|
88
|
+
cy.get('[data-testid="dashboard"]').should('be.visible');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
cy.step('Reload page', () => {
|
|
92
|
+
cy.reload();
|
|
93
|
+
BrowserHelper.logCookie('JSESSIONID');
|
|
94
|
+
cy.get('[data-testid="dashboard"]').should('be.visible');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Simulate Browser Close
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import {BrowserHelper} from '@jahia/cypress';
|
|
104
|
+
|
|
105
|
+
it('validates behavior after browser close', () => {
|
|
106
|
+
cy.login();
|
|
107
|
+
BrowserHelper.logCookies();
|
|
108
|
+
|
|
109
|
+
// Simulate browser close (clears session cookies and session storage)
|
|
110
|
+
BrowserHelper.simulateClose();
|
|
111
|
+
|
|
112
|
+
// Visit the app again to see the effect of reset
|
|
113
|
+
cy.visit(url);
|
|
114
|
+
|
|
115
|
+
BrowserHelper.logCookies();
|
|
116
|
+
BrowserHelper.logSessionStorage();
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Simulate Browser Reset (clear all cookies and storages)
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import {BrowserHelper} from '@jahia/cypress';
|
|
124
|
+
|
|
125
|
+
it('validates behavior after full browser reset', () => {
|
|
126
|
+
cy.login();
|
|
127
|
+
BrowserHelper.logCookies();
|
|
128
|
+
|
|
129
|
+
// Reset all browser state
|
|
130
|
+
BrowserHelper.resetState();
|
|
131
|
+
|
|
132
|
+
// Visit the app again to see the effect of reset
|
|
133
|
+
cy.visit(url);
|
|
134
|
+
|
|
135
|
+
BrowserHelper.logCookies();
|
|
136
|
+
BrowserHelper.logSessionStorage();
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Best Practices
|
|
141
|
+
|
|
142
|
+
1. Use these helpers for interactive debugging, not as regular test assertions.
|
|
143
|
+
2. Avoid running full storage/cookie logging in CI unless required.
|
|
144
|
+
3. Prefer targeted checks (`logCookie`) over full dumps (`logCookies`) for sensitive environments.
|
|
145
|
+
4. Use `resetState()` for hard test isolation, and `simulateClose()` for realistic session lifecycle checks.
|
|
146
|
+
|
|
147
|
+
## API Reference
|
|
148
|
+
|
|
149
|
+
| Helper | Parameters | Returns | Description |
|
|
150
|
+
|--------|------------|---------|-------------|
|
|
151
|
+
| `BrowserHelper.logCookies()` | - | `Cypress.Chainable<void>` | Logs all cookies with full metadata |
|
|
152
|
+
| `BrowserHelper.logCookie(cookieName)` | `string` | `Cypress.Chainable<void>` | Logs one cookie by name |
|
|
153
|
+
| `BrowserHelper.clearSessionCookies()` | - | `Cypress.Chainable<void>` | Clears session cookies only |
|
|
154
|
+
| `BrowserHelper.clearPersistentCookies()` | - | `Cypress.Chainable<void>` | Clears persistent cookies only |
|
|
155
|
+
| `BrowserHelper.simulateClose()` | - | `void` | Clears session storage and session cookies |
|
|
156
|
+
| `BrowserHelper.resetState()` | - | `void` | Clears all storages and all cookies |
|
|
157
|
+
| `BrowserHelper.logSessionStorage()` | - | `Cypress.Chainable<void>` | Logs all session storage data |
|
|
158
|
+
| `BrowserHelper.logLocalStorage()` | - | `Cypress.Chainable<void>` | Logs all local storage data |
|