@jahia/cypress 3.1.0 → 3.3.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.
@@ -1,6 +1,8 @@
1
1
  export declare const setNodeProperty: (pathOrId: string, property: string, value: string, language: string) => Cypress.Chainable;
2
+ export declare const deleteNodeProperty: (pathOrId: string, property: string, language: string) => Cypress.Chainable;
2
3
  export declare const deleteNode: (pathOrId: string) => Cypress.Chainable;
3
4
  export declare const grantRoles: (pathOrId: string, roleNames: Array<string>, principalName: string, principalType: string) => Cypress.Chainable;
5
+ export declare const publishAndWaitJobEnding: (path: string, languages?: string[]) => void;
4
6
  export declare const waitAllJobsFinished: (errorMessage?: string, timeout?: number) => void;
5
7
  export declare const addNode: (variables: {
6
8
  parentPathOrId: string;
@@ -9,5 +11,14 @@ export declare const addNode: (variables: {
9
11
  properties?: any[];
10
12
  children?: any[];
11
13
  }) => Cypress.Chainable;
12
- export declare const getNodeByPath: (path: string) => Cypress.Chainable;
14
+ export declare const getNodeByPath: (path: string, properties?: string[], language?: string) => Cypress.Chainable;
13
15
  export declare const createSite: (siteKey: string, templateSet?: string, serverName?: string, locale?: string, languages?: string) => void;
16
+ export declare const deleteSite: (siteKey: string) => void;
17
+ export declare const createUser: (userName: string, password: string, properties?: {
18
+ name: string;
19
+ value: string;
20
+ }[]) => void;
21
+ export declare const deleteUser: (userName: string) => void;
22
+ export declare const addVanityUrl: (pathOrId: string, language: string, url: string) => Cypress.Chainable;
23
+ export declare const getVanityUrl: (path: string, languages: Array<string>) => Cypress.Chainable;
24
+ export declare const removeVanityUrl: (pathOrId: string, url: string) => Cypress.Chainable;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.createSite = exports.getNodeByPath = exports.addNode = exports.waitAllJobsFinished = exports.grantRoles = exports.deleteNode = exports.setNodeProperty = void 0;
3
+ exports.removeVanityUrl = exports.getVanityUrl = exports.addVanityUrl = exports.deleteUser = exports.createUser = exports.deleteSite = exports.createSite = exports.getNodeByPath = exports.addNode = exports.waitAllJobsFinished = exports.publishAndWaitJobEnding = exports.grantRoles = exports.deleteNode = exports.deleteNodeProperty = exports.setNodeProperty = void 0;
4
4
  var setNodeProperty = function (pathOrId, property, value, language) {
5
5
  return cy.apollo({
6
6
  variables: {
@@ -13,6 +13,17 @@ var setNodeProperty = function (pathOrId, property, value, language) {
13
13
  });
14
14
  };
15
15
  exports.setNodeProperty = setNodeProperty;
16
+ var deleteNodeProperty = function (pathOrId, property, language) {
17
+ return cy.apollo({
18
+ variables: {
19
+ pathOrId: pathOrId,
20
+ property: property,
21
+ language: language
22
+ },
23
+ mutationFile: 'graphql/jcr/mutation/deleteNodeProperty.graphql'
24
+ });
25
+ };
26
+ exports.deleteNodeProperty = deleteNodeProperty;
16
27
  var deleteNode = function (pathOrId) {
17
28
  return cy.apollo({
18
29
  variables: {
@@ -35,6 +46,20 @@ var grantRoles = function (pathOrId, roleNames, principalName, principalType) {
35
46
  });
36
47
  };
37
48
  exports.grantRoles = grantRoles;
49
+ var publishAndWaitJobEnding = function (path, languages) {
50
+ if (languages === void 0) { languages = ['en']; }
51
+ cy.apollo({
52
+ variables: {
53
+ pathOrId: path,
54
+ languages: languages,
55
+ publishSubNodes: true,
56
+ includeSubTree: true
57
+ },
58
+ mutationFile: 'graphql/jcr/mutation/publishNode.graphql'
59
+ });
60
+ exports.waitAllJobsFinished('Publication timeout for node: ' + path, 60000);
61
+ };
62
+ exports.publishAndWaitJobEnding = publishAndWaitJobEnding;
38
63
  var waitAllJobsFinished = function (errorMessage, timeout) {
39
64
  if (timeout === void 0) { timeout = 60000; }
40
65
  cy.waitUntil(function () {
@@ -68,10 +93,12 @@ var addNode = function (variables) {
68
93
  });
69
94
  };
70
95
  exports.addNode = addNode;
71
- var getNodeByPath = function (path) {
96
+ var getNodeByPath = function (path, properties, language) {
72
97
  return cy.apollo({
73
98
  variables: {
74
- path: path
99
+ path: path,
100
+ properties: properties,
101
+ language: language
75
102
  },
76
103
  queryFile: 'graphql/jcr/query/getNodeByPath.graphql'
77
104
  });
@@ -88,3 +115,58 @@ var createSite = function (siteKey, templateSet, serverName, locale, languages)
88
115
  });
89
116
  };
90
117
  exports.createSite = createSite;
118
+ var deleteSite = function (siteKey) {
119
+ cy.executeGroovy('groovy/admin/deleteSite.groovy', {
120
+ SITEKEY: siteKey
121
+ });
122
+ };
123
+ exports.deleteSite = deleteSite;
124
+ var createUser = function (userName, password, properties) {
125
+ if (properties === void 0) { properties = []; }
126
+ var userProperties = properties.map(function (property) {
127
+ return 'properties.setProperty("' + property.name + '", "' + property.value + '")';
128
+ });
129
+ cy.executeGroovy('groovy/admin/createUser.groovy', {
130
+ USER_NAME: userName,
131
+ PASSWORD: password ? password : 'password',
132
+ USER_PROPERTIES: userProperties ? userProperties.join('\n') : ''
133
+ });
134
+ };
135
+ exports.createUser = createUser;
136
+ var deleteUser = function (userName) {
137
+ cy.executeGroovy('groovy/admin/deleteUser.groovy', {
138
+ USER_NAME: userName
139
+ });
140
+ };
141
+ exports.deleteUser = deleteUser;
142
+ var addVanityUrl = function (pathOrId, language, url) {
143
+ return cy.apollo({
144
+ variables: {
145
+ pathOrId: pathOrId,
146
+ language: language,
147
+ url: url
148
+ },
149
+ mutationFile: 'graphql/jcr/mutation/addVanityUrl.graphql'
150
+ });
151
+ };
152
+ exports.addVanityUrl = addVanityUrl;
153
+ var getVanityUrl = function (path, languages) {
154
+ return cy.apollo({
155
+ variables: {
156
+ path: path,
157
+ languages: languages
158
+ },
159
+ queryFile: 'graphql/jcr/query/getVanityUrls.graphql'
160
+ });
161
+ };
162
+ exports.getVanityUrl = getVanityUrl;
163
+ var removeVanityUrl = function (pathOrId, url) {
164
+ return cy.apollo({
165
+ variables: {
166
+ pathOrId: pathOrId,
167
+ url: url
168
+ },
169
+ mutationFile: 'graphql/jcr/mutation/removeVanityUrl.graphql'
170
+ });
171
+ };
172
+ exports.removeVanityUrl = removeVanityUrl;
@@ -0,0 +1,14 @@
1
+ mutation($pathOrId: String!, $language: String!, $url: String!){
2
+ jcr{
3
+ mutateNode(pathOrId: $pathOrId){
4
+ addVanityUrl(vanityUrlInputList: [{
5
+ language: $language,
6
+ active: true,
7
+ defaultMapping: true,
8
+ url: $url
9
+ }]){
10
+ uuid
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,9 @@
1
+ mutation($pathOrId: String!, $property: String!, $language: String){
2
+ jcr{
3
+ mutateNode(pathOrId: $pathOrId){
4
+ mutateProperty(name: $property){
5
+ delete(language: $language)
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ mutation publishNode($pathOrId: String!, $languages: [String]!, $publishSubNodes: Boolean!, $includeSubTree: Boolean!) {
2
+ jcr(workspace: EDIT) {
3
+ mutateNode(pathOrId: $pathOrId) {
4
+ publish(publishSubNodes: $publishSubNodes, languages: $languages, includeSubTree: $includeSubTree)
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ mutation($pathOrId: String!, $url: String!){
2
+ jcr {
3
+ mutateNode(pathOrId: $pathOrId) {
4
+ mutateVanityUrl(url: $url) {
5
+ delete
6
+ }
7
+ }
8
+ }
9
+ }
@@ -1,9 +1,9 @@
1
- query getNodeByPath($path: String!, $properties: [String]=[]) {
1
+ query getNodeByPath($path: String!, $properties: [String]=[], $language: String="") {
2
2
  jcr {
3
3
  nodeByPath(path: $path) {
4
4
  uuid
5
5
  name
6
- properties(names: $properties){
6
+ properties(names: $properties, language: $language){
7
7
  name
8
8
  value
9
9
  }
@@ -0,0 +1,9 @@
1
+ query($path: String!, $languages: [String]!) {
2
+ jcr {
3
+ nodeByPath(path: $path){
4
+ vanityUrls(languages: $languages){
5
+ url
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,20 @@
1
+ import org.jahia.services.content.JCRCallback
2
+ import org.jahia.services.content.JCRSessionWrapper
3
+ import org.jahia.services.content.JCRTemplate
4
+ import org.jahia.services.usermanager.JahiaUserManagerService
5
+ import javax.jcr.RepositoryException
6
+
7
+ JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback() {
8
+ @Override
9
+ Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
10
+ log.info("Create user : USER_NAME")
11
+ JahiaUserManagerService userManagerService = JahiaUserManagerService.getInstance()
12
+
13
+ Properties properties = new Properties()
14
+ USER_PROPERTIES
15
+
16
+ userManagerService.createUser("USER_NAME", null, "PASSWORD", properties, session)
17
+ session.save()
18
+ return null
19
+ }
20
+ })
@@ -0,0 +1,17 @@
1
+ import org.jahia.services.content.JCRCallback
2
+ import org.jahia.services.content.JCRSessionWrapper
3
+ import org.jahia.services.content.JCRTemplate
4
+ import org.jahia.services.usermanager.JahiaUserManagerService
5
+ import javax.jcr.RepositoryException
6
+
7
+ JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback() {
8
+ @Override
9
+ Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
10
+ log.info("Delete user : USER_NAME" );
11
+
12
+ JahiaUserManagerService userManagerService = JahiaUserManagerService.getInstance();
13
+ userManagerService.deleteUser(userManagerService.getUserPath("USER_NAME"), session);
14
+ session.save();
15
+ return null;
16
+ }
17
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -10,6 +10,17 @@ export const setNodeProperty = (pathOrId: string, property: string, value: strin
10
10
  });
11
11
  };
12
12
 
13
+ export const deleteNodeProperty = (pathOrId: string, property: string, language: string): Cypress.Chainable => {
14
+ return cy.apollo({
15
+ variables: {
16
+ pathOrId: pathOrId,
17
+ property: property,
18
+ language: language
19
+ },
20
+ mutationFile: 'graphql/jcr/mutation/deleteNodeProperty.graphql'
21
+ });
22
+ };
23
+
13
24
  export const deleteNode = (pathOrId: string): Cypress.Chainable => {
14
25
  return cy.apollo({
15
26
  variables: {
@@ -32,6 +43,19 @@ export const grantRoles = (pathOrId: string, roleNames: Array<string>, principal
32
43
  });
33
44
  };
34
45
 
46
+ export const publishAndWaitJobEnding = (path: string, languages: string[] = ['en']): void => {
47
+ cy.apollo({
48
+ variables: {
49
+ pathOrId: path,
50
+ languages: languages,
51
+ publishSubNodes: true,
52
+ includeSubTree: true
53
+ },
54
+ mutationFile: 'graphql/jcr/mutation/publishNode.graphql'
55
+ });
56
+ waitAllJobsFinished('Publication timeout for node: ' + path, 60000);
57
+ };
58
+
35
59
  export const waitAllJobsFinished = (errorMessage?: string, timeout = 60000): void => {
36
60
  cy.waitUntil(
37
61
  () =>
@@ -58,23 +82,25 @@ export const waitAllJobsFinished = (errorMessage?: string, timeout = 60000): voi
58
82
  cy.wait(2000);
59
83
  };
60
84
 
61
- export const addNode = (variables: {parentPathOrId: string, primaryNodeType: string, name: string, properties?: any[], children?: any[]}): Cypress.Chainable => {
85
+ export const addNode = (variables: { parentPathOrId: string, primaryNodeType: string, name: string, properties?: any[], children?: any[] }): Cypress.Chainable => {
62
86
  return cy.apollo({
63
87
  variables: variables,
64
88
  mutationFile: 'graphql/jcr/mutation/addNode.graphql'
65
89
  });
66
90
  };
67
91
 
68
- export const getNodeByPath = (path: string): Cypress.Chainable => {
92
+ export const getNodeByPath = (path: string, properties?: string[], language?:string): Cypress.Chainable => {
69
93
  return cy.apollo({
70
94
  variables: {
71
- path: path
95
+ path: path,
96
+ properties: properties,
97
+ language: language
72
98
  },
73
99
  queryFile: 'graphql/jcr/query/getNodeByPath.graphql'
74
100
  });
75
101
  };
76
102
 
77
- export const createSite = (siteKey: string, templateSet?: string, serverName?: string, locale?: string, languages?: string) => {
103
+ export const createSite = (siteKey: string, templateSet?: string, serverName?: string, locale?: string, languages?: string): void => {
78
104
  const definedLocale = locale ? locale : 'en';
79
105
  cy.executeGroovy('groovy/admin/createSite.groovy', {
80
106
  SITEKEY: siteKey,
@@ -84,3 +110,57 @@ export const createSite = (siteKey: string, templateSet?: string, serverName?: s
84
110
  LANGUAGES: languages ? `Arrays.asList(${languages})` : `Arrays.asList("${definedLocale}")`
85
111
  });
86
112
  };
113
+
114
+ export const deleteSite = (siteKey: string): void => {
115
+ cy.executeGroovy('groovy/admin/deleteSite.groovy', {
116
+ SITEKEY: siteKey
117
+ });
118
+ };
119
+
120
+ export const createUser = (userName: string, password: string, properties: { name: string, value: string }[] = []): void => {
121
+ const userProperties = properties.map(property => {
122
+ return 'properties.setProperty("' + property.name + '", "' + property.value + '")';
123
+ });
124
+ cy.executeGroovy('groovy/admin/createUser.groovy', {
125
+ USER_NAME: userName,
126
+ PASSWORD: password ? password : 'password',
127
+ USER_PROPERTIES: userProperties ? userProperties.join('\n') : ''
128
+ });
129
+ };
130
+
131
+ export const deleteUser = (userName: string): void => {
132
+ cy.executeGroovy('groovy/admin/deleteUser.groovy', {
133
+ USER_NAME: userName
134
+ });
135
+ };
136
+
137
+ export const addVanityUrl = (pathOrId: string, language: string, url: string): Cypress.Chainable => {
138
+ return cy.apollo({
139
+ variables: {
140
+ pathOrId: pathOrId,
141
+ language: language,
142
+ url: url
143
+ },
144
+ mutationFile: 'graphql/jcr/mutation/addVanityUrl.graphql'
145
+ });
146
+ };
147
+
148
+ export const getVanityUrl = (path: string, languages: Array<string>): Cypress.Chainable => {
149
+ return cy.apollo({
150
+ variables: {
151
+ path: path,
152
+ languages: languages
153
+ },
154
+ queryFile: 'graphql/jcr/query/getVanityUrls.graphql'
155
+ });
156
+ };
157
+
158
+ export const removeVanityUrl = (pathOrId: string, url: string): Cypress.Chainable => {
159
+ return cy.apollo({
160
+ variables: {
161
+ pathOrId: pathOrId,
162
+ url: url
163
+ },
164
+ mutationFile: 'graphql/jcr/mutation/removeVanityUrl.graphql'
165
+ });
166
+ };