artes 1.2.16 → 1.2.18

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 (38) hide show
  1. package/README.md +629 -533
  2. package/cucumber.config.js +171 -171
  3. package/docs/functionDefinitions.md +2401 -2401
  4. package/docs/stepDefinitions.md +391 -352
  5. package/executer.js +161 -161
  6. package/index.js +48 -48
  7. package/package.json +52 -51
  8. package/src/helper/contextManager/browserManager.js +63 -63
  9. package/src/helper/contextManager/requestManager.js +23 -23
  10. package/src/helper/controller/elementController.js +182 -182
  11. package/src/helper/controller/pomCollector.js +25 -25
  12. package/src/helper/executers/cleaner.js +19 -19
  13. package/src/helper/executers/exporter.js +15 -15
  14. package/src/helper/executers/helper.js +95 -95
  15. package/src/helper/executers/projectCreator.js +198 -198
  16. package/src/helper/executers/reportGenerator.js +58 -58
  17. package/src/helper/executers/testRunner.js +30 -30
  18. package/src/helper/executers/versionChecker.js +31 -31
  19. package/src/helper/imports/commons.js +56 -56
  20. package/src/helper/stepFunctions/APIActions.js +362 -362
  21. package/src/helper/stepFunctions/assertions.js +523 -523
  22. package/src/helper/stepFunctions/browserActions.js +22 -22
  23. package/src/helper/stepFunctions/elementInteractions.js +38 -38
  24. package/src/helper/stepFunctions/exporter.js +19 -19
  25. package/src/helper/stepFunctions/frameActions.js +50 -50
  26. package/src/helper/stepFunctions/keyboardActions.js +41 -41
  27. package/src/helper/stepFunctions/mouseActions.js +145 -145
  28. package/src/helper/stepFunctions/pageActions.js +27 -27
  29. package/src/hooks/context.js +15 -15
  30. package/src/hooks/hooks.js +257 -257
  31. package/src/stepDefinitions/API.steps.js +299 -299
  32. package/src/stepDefinitions/assertions.steps.js +861 -861
  33. package/src/stepDefinitions/browser.steps.js +7 -7
  34. package/src/stepDefinitions/frameActions.steps.js +76 -76
  35. package/src/stepDefinitions/keyboardActions.steps.js +226 -226
  36. package/src/stepDefinitions/mouseActions.steps.js +275 -275
  37. package/src/stepDefinitions/page.steps.js +71 -71
  38. package/src/stepDefinitions/random.steps.js +158 -158
@@ -1,300 +1,300 @@
1
- const {
2
- When,
3
- context,
4
- extractVarsFromResponse,
5
- saveVar,
6
- time,random
7
- } = require("../helper/imports/commons");
8
- const { api } = require("../helper/stepFunctions/exporter");
9
- const Ajv = require("ajv");
10
-
11
- When("User sends GET request to {string}", async function (url) {
12
- await api.get(url);
13
- });
14
-
15
- When(
16
- "User sends GET request to {string} with payload:",
17
- async function (url, payload) {
18
- await api.get(url, payload);
19
- }
20
- );
21
-
22
- When(
23
- "User sends GET request to {string} and saves {string} variables",
24
- async function (url, vars) {
25
- await api.get(url);
26
- await extractVarsFromResponse(context.response["Response Body"], vars);
27
- }
28
- );
29
-
30
- When(
31
- "User sends GET request to {string} with payload and saves {string} variables",
32
- async function (url, vars, payload) {
33
- await api.get(url, payload);
34
- await extractVarsFromResponse(context.response["Response Body"], vars);
35
- }
36
- );
37
-
38
- When("User sends HEAD request to {string}", async function (url) {
39
- await api.head(url);
40
- });
41
-
42
- When(
43
- "User sends POST request to {string} with payload:",
44
- async function (url, payload) {
45
- await api.post(url, payload);
46
- }
47
- );
48
-
49
- When(
50
- "User sends POST request to {string} with payload and saves {string} variables",
51
- async function (url, vars, payload) {
52
- await api.post(url, payload);
53
- await extractVarsFromResponse(context.response["Response Body"], vars);
54
- }
55
- );
56
-
57
- When(
58
- "User sends multipart POST request to {string} with payload:",
59
- async (url, payload) => {
60
- await api.post(url, payload, "multipart");
61
- }
62
- );
63
-
64
- When(
65
- "User sends multipart POST request to {string} with payload and saves {string} variables",
66
- async (url, vars, payload) => {
67
- await api.post(url, payload, "multipart");
68
- await extractVarsFromResponse(context.response["Response Body"], vars);
69
- }
70
- );
71
-
72
- When(
73
- "User sends x-www-form-urlencoded POST request to {string} with payload:",
74
- async (url, payload) => {
75
- await api.post(url, payload, "application/x-www-form-urlencoded");
76
- }
77
- );
78
-
79
- When(
80
- "User sends x-www-form-urlencoded POST request to {string} with payload and saves {string} variables",
81
- async (url, vars, payload) => {
82
- await api.post(url, payload, "application/x-www-form-urlencoded");
83
- await extractVarsFromResponse(context.response["Response Body"], vars);
84
- }
85
- );
86
-
87
- When(
88
- "User sends PUT request to {string} with payload:",
89
- async function (url, payload) {
90
- await api.put(url, payload);
91
- }
92
- );
93
-
94
- When(
95
- "User sends PUT request to {string} with payload and saves {string} variables",
96
- async function (url, vars, payload) {
97
- await api.put(url, payload);
98
- await extractVarsFromResponse(context.response["Response Body"], vars);
99
- }
100
- );
101
-
102
- When(
103
- "User sends multipart PUT request to {string} with payload:",
104
- async function (url, payload) {
105
- await api.put(url, payload, "multipart");
106
- }
107
- );
108
-
109
- When(
110
- "User sends multipart PUT request to {string} with payload and saves {string} variables",
111
- async function (url, vars, payload) {
112
- await api.put(url, payload, "multipart");
113
- await extractVarsFromResponse(context.response["Response Body"], vars);
114
- }
115
- );
116
-
117
- When(
118
- "User sends x-www-form-urlencoded PUT request to {string} with payload:",
119
- async (url, payload) => {
120
- await api.put(url, payload, "application/x-www-form-urlencoded");
121
- }
122
- );
123
-
124
- When(
125
- "User sends x-www-form-urlencoded PUT request to {string} with payload and saves {string} variables",
126
- async (url, vars, payload) => {
127
- await api.put(url, payload, "application/x-www-form-urlencoded");
128
- await extractVarsFromResponse(context.response["Response Body"], vars);
129
- }
130
- );
131
-
132
- When(
133
- "User sends PATCH request to {string} with payload:",
134
- async function (url, payload) {
135
- await api.patch(url, payload);
136
- }
137
- );
138
-
139
- When(
140
- "User sends PATCH request to {string} with payload and saves {string} variables",
141
- async function (url, vars, payload) {
142
- await api.patch(url, payload);
143
- await extractVarsFromResponse(context.response["Response Body"], vars);
144
- }
145
- );
146
-
147
- When(
148
- "User sends multipart PATCH request to {string} with payload:",
149
- async function (url, payload) {
150
- await api.patch(url, payload, "multipart");
151
- }
152
- );
153
-
154
- When(
155
- "User sends multipart PATCH request to {string} with payload and saves {string} variables",
156
- async function (url, vars, payload) {
157
- await api.patch(url, payload, "multipart");
158
- await extractVarsFromResponse(context.response["Response Body"], vars);
159
- }
160
- );
161
-
162
- When(
163
- "User sends x-www-form-urlencoded PATCH request to {string} with payload:",
164
- async (url, payload) => {
165
- await api.patch(url, payload, "application/x-www-form-urlencoded");
166
- }
167
- );
168
-
169
- When(
170
- "User sends x-www-form-urlencoded PATCH request to {string} with payload and saves {string} variables",
171
- async (url, vars, payload) => {
172
- await api.patch(url, payload, "application/x-www-form-urlencoded");
173
- await extractVarsFromResponse(context.response["Response Body"], vars);
174
- }
175
- );
176
-
177
- When("User sends DELETE request to {string}", async function (url) {
178
- await api.delete(url);
179
- });
180
-
181
- When(
182
- "User sends DELETE request to {string} and saves {string} variables",
183
- async function (url, vars) {
184
- await api.delete(url);
185
- await extractVarsFromResponse(context.response["Response Body"], vars);
186
- }
187
- );
188
-
189
- When(
190
- "User sends DELETE request to {string} with payload:",
191
- async function (url, payload) {
192
- await api.delete(url, payload);
193
- }
194
- );
195
-
196
- When(
197
- "User sends DELETE request to {string} with payload and saves {string}",
198
- async function (url, vars, payload) {
199
- await api.delete(url, payload);
200
- await extractVarsFromResponse(context.response["Response Body"], vars);
201
- }
202
- );
203
-
204
- When(
205
- "User saves {string} variable from response as {string}",
206
- async function (vars, customVarName) {
207
- await extractVarsFromResponse(
208
- context.response["Response Body"],
209
- vars,
210
- customVarName,
211
- );
212
- }
213
- );
214
-
215
- When(
216
- "User saves {string} variable as {string}",
217
- async function (value, customVarName) {
218
- saveVar(value, customVarName);
219
- }
220
- );
221
-
222
- When("User wants to see saved variables", async function () {
223
- console.log("\nVariables:", api.vars(), "\n");
224
- });
225
-
226
- When("User wants to see request body", async function () {
227
- console.log("Request Body: ", context.response["Request Body"]);
228
- });
229
-
230
- When("User wants to see response body", async function () {
231
- console.log("Response Body: ", context.response["Response Body"]);
232
- });
233
-
234
- When(
235
- "User sends {string} request to {string}",
236
- async function (method, url, reqParams) {
237
- const httpMethod = method.toUpperCase();
238
-
239
- let headers = {};
240
- let body;
241
-
242
- if (["POST", "PUT", "PATCH"].includes(httpMethod)) {
243
- const payload = JSON.parse(reqParams);
244
- headers = payload.headers || {};
245
- body = payload.body || {};
246
- }
247
-
248
- switch (httpMethod) {
249
- case "GET":
250
- await api.get(url);
251
- break;
252
- case "HEAD":
253
- await api.head(url);
254
- break;
255
- case "POST":
256
- await api.post(url, headers, body);
257
- break;
258
- case "PUT":
259
- await api.put(url, headers, body);
260
- break;
261
- case "PATCH":
262
- await api.patch(url, headers, body);
263
- break;
264
- case "DELETE":
265
- await api.delete(url);
266
- break;
267
- default:
268
- throw new Error(`Unsupported HTTP method: ${httpMethod}`);
269
- }
270
- }
271
- );
272
-
273
- When(
274
- "User sends GET request to {string} and save {string} variable from {string} array as {string} randomly with payload:",
275
- async (endPoint, varName, fromArray, variableKey, payload) => {
276
- await api.get(endPoint, payload);
277
- let responseBody;
278
- if (fromArray == "[]") {
279
- responseBody = await context.response["Response Body"];
280
- } else {
281
- responseBody = await context.response["Response Body"][fromArray];
282
- }
283
- const randomContent =
284
- responseBody[random.number.int({ min: 0, max: responseBody.length - 1 })];
285
- context.vars[variableKey] = randomContent[varName];
286
- },
287
- );
288
-
289
-
290
- When(
291
- "User sets {string} date {int} days from today",
292
- async function (dateName, days) {
293
- const expiresAt =
294
- days < 0
295
- ? time().subtract(Math.abs(days), "day").toISOString()
296
- : time().add(days, "day").toISOString();
297
-
298
- context.vars[dateName] = expiresAt;
299
- },
1
+ const {
2
+ When,
3
+ context,
4
+ extractVarsFromResponse,
5
+ saveVar,
6
+ time,random
7
+ } = require("../helper/imports/commons");
8
+ const { api } = require("../helper/stepFunctions/exporter");
9
+ const Ajv = require("ajv");
10
+
11
+ When("User sends GET request to {string}", async function (url) {
12
+ await api.get(url);
13
+ });
14
+
15
+ When(
16
+ "User sends GET request to {string} with payload:",
17
+ async function (url, payload) {
18
+ await api.get(url, payload);
19
+ }
20
+ );
21
+
22
+ When(
23
+ "User sends GET request to {string} and saves {string} variables",
24
+ async function (url, vars) {
25
+ await api.get(url);
26
+ await extractVarsFromResponse(context.response["Response Body"], vars);
27
+ }
28
+ );
29
+
30
+ When(
31
+ "User sends GET request to {string} with payload and saves {string} variables",
32
+ async function (url, vars, payload) {
33
+ await api.get(url, payload);
34
+ await extractVarsFromResponse(context.response["Response Body"], vars);
35
+ }
36
+ );
37
+
38
+ When("User sends HEAD request to {string}", async function (url) {
39
+ await api.head(url);
40
+ });
41
+
42
+ When(
43
+ "User sends POST request to {string} with payload:",
44
+ async function (url, payload) {
45
+ await api.post(url, payload);
46
+ }
47
+ );
48
+
49
+ When(
50
+ "User sends POST request to {string} with payload and saves {string} variables",
51
+ async function (url, vars, payload) {
52
+ await api.post(url, payload);
53
+ await extractVarsFromResponse(context.response["Response Body"], vars);
54
+ }
55
+ );
56
+
57
+ When(
58
+ "User sends multipart POST request to {string} with payload:",
59
+ async (url, payload) => {
60
+ await api.post(url, payload, "multipart");
61
+ }
62
+ );
63
+
64
+ When(
65
+ "User sends multipart POST request to {string} with payload and saves {string} variables",
66
+ async (url, vars, payload) => {
67
+ await api.post(url, payload, "multipart");
68
+ await extractVarsFromResponse(context.response["Response Body"], vars);
69
+ }
70
+ );
71
+
72
+ When(
73
+ "User sends x-www-form-urlencoded POST request to {string} with payload:",
74
+ async (url, payload) => {
75
+ await api.post(url, payload, "application/x-www-form-urlencoded");
76
+ }
77
+ );
78
+
79
+ When(
80
+ "User sends x-www-form-urlencoded POST request to {string} with payload and saves {string} variables",
81
+ async (url, vars, payload) => {
82
+ await api.post(url, payload, "application/x-www-form-urlencoded");
83
+ await extractVarsFromResponse(context.response["Response Body"], vars);
84
+ }
85
+ );
86
+
87
+ When(
88
+ "User sends PUT request to {string} with payload:",
89
+ async function (url, payload) {
90
+ await api.put(url, payload);
91
+ }
92
+ );
93
+
94
+ When(
95
+ "User sends PUT request to {string} with payload and saves {string} variables",
96
+ async function (url, vars, payload) {
97
+ await api.put(url, payload);
98
+ await extractVarsFromResponse(context.response["Response Body"], vars);
99
+ }
100
+ );
101
+
102
+ When(
103
+ "User sends multipart PUT request to {string} with payload:",
104
+ async function (url, payload) {
105
+ await api.put(url, payload, "multipart");
106
+ }
107
+ );
108
+
109
+ When(
110
+ "User sends multipart PUT request to {string} with payload and saves {string} variables",
111
+ async function (url, vars, payload) {
112
+ await api.put(url, payload, "multipart");
113
+ await extractVarsFromResponse(context.response["Response Body"], vars);
114
+ }
115
+ );
116
+
117
+ When(
118
+ "User sends x-www-form-urlencoded PUT request to {string} with payload:",
119
+ async (url, payload) => {
120
+ await api.put(url, payload, "application/x-www-form-urlencoded");
121
+ }
122
+ );
123
+
124
+ When(
125
+ "User sends x-www-form-urlencoded PUT request to {string} with payload and saves {string} variables",
126
+ async (url, vars, payload) => {
127
+ await api.put(url, payload, "application/x-www-form-urlencoded");
128
+ await extractVarsFromResponse(context.response["Response Body"], vars);
129
+ }
130
+ );
131
+
132
+ When(
133
+ "User sends PATCH request to {string} with payload:",
134
+ async function (url, payload) {
135
+ await api.patch(url, payload);
136
+ }
137
+ );
138
+
139
+ When(
140
+ "User sends PATCH request to {string} with payload and saves {string} variables",
141
+ async function (url, vars, payload) {
142
+ await api.patch(url, payload);
143
+ await extractVarsFromResponse(context.response["Response Body"], vars);
144
+ }
145
+ );
146
+
147
+ When(
148
+ "User sends multipart PATCH request to {string} with payload:",
149
+ async function (url, payload) {
150
+ await api.patch(url, payload, "multipart");
151
+ }
152
+ );
153
+
154
+ When(
155
+ "User sends multipart PATCH request to {string} with payload and saves {string} variables",
156
+ async function (url, vars, payload) {
157
+ await api.patch(url, payload, "multipart");
158
+ await extractVarsFromResponse(context.response["Response Body"], vars);
159
+ }
160
+ );
161
+
162
+ When(
163
+ "User sends x-www-form-urlencoded PATCH request to {string} with payload:",
164
+ async (url, payload) => {
165
+ await api.patch(url, payload, "application/x-www-form-urlencoded");
166
+ }
167
+ );
168
+
169
+ When(
170
+ "User sends x-www-form-urlencoded PATCH request to {string} with payload and saves {string} variables",
171
+ async (url, vars, payload) => {
172
+ await api.patch(url, payload, "application/x-www-form-urlencoded");
173
+ await extractVarsFromResponse(context.response["Response Body"], vars);
174
+ }
175
+ );
176
+
177
+ When("User sends DELETE request to {string}", async function (url) {
178
+ await api.delete(url);
179
+ });
180
+
181
+ When(
182
+ "User sends DELETE request to {string} and saves {string} variables",
183
+ async function (url, vars) {
184
+ await api.delete(url);
185
+ await extractVarsFromResponse(context.response["Response Body"], vars);
186
+ }
187
+ );
188
+
189
+ When(
190
+ "User sends DELETE request to {string} with payload:",
191
+ async function (url, payload) {
192
+ await api.delete(url, payload);
193
+ }
194
+ );
195
+
196
+ When(
197
+ "User sends DELETE request to {string} with payload and saves {string}",
198
+ async function (url, vars, payload) {
199
+ await api.delete(url, payload);
200
+ await extractVarsFromResponse(context.response["Response Body"], vars);
201
+ }
202
+ );
203
+
204
+ When(
205
+ "User saves {string} variable from response as {string}",
206
+ async function (vars, customVarName) {
207
+ await extractVarsFromResponse(
208
+ context.response["Response Body"],
209
+ vars,
210
+ customVarName,
211
+ );
212
+ }
213
+ );
214
+
215
+ When(
216
+ "User saves {string} variable as {string}",
217
+ async function (value, customVarName) {
218
+ saveVar(value, customVarName);
219
+ }
220
+ );
221
+
222
+ When("User wants to see saved variables", async function () {
223
+ console.log("\nVariables:", api.vars(), "\n");
224
+ });
225
+
226
+ When("User wants to see request body", async function () {
227
+ console.log("Request Body: ", context.response["Request Body"]);
228
+ });
229
+
230
+ When("User wants to see response body", async function () {
231
+ console.log("Response Body: ", context.response["Response Body"]);
232
+ });
233
+
234
+ When(
235
+ "User sends {string} request to {string}",
236
+ async function (method, url, reqParams) {
237
+ const httpMethod = method.toUpperCase();
238
+
239
+ let headers = {};
240
+ let body;
241
+
242
+ if (["POST", "PUT", "PATCH"].includes(httpMethod)) {
243
+ const payload = JSON.parse(reqParams);
244
+ headers = payload.headers || {};
245
+ body = payload.body || {};
246
+ }
247
+
248
+ switch (httpMethod) {
249
+ case "GET":
250
+ await api.get(url);
251
+ break;
252
+ case "HEAD":
253
+ await api.head(url);
254
+ break;
255
+ case "POST":
256
+ await api.post(url, headers, body);
257
+ break;
258
+ case "PUT":
259
+ await api.put(url, headers, body);
260
+ break;
261
+ case "PATCH":
262
+ await api.patch(url, headers, body);
263
+ break;
264
+ case "DELETE":
265
+ await api.delete(url);
266
+ break;
267
+ default:
268
+ throw new Error(`Unsupported HTTP method: ${httpMethod}`);
269
+ }
270
+ }
271
+ );
272
+
273
+ When(
274
+ "User sends GET request to {string} and save {string} variable from {string} array as {string} randomly with payload:",
275
+ async (endPoint, varName, fromArray, variableKey, payload) => {
276
+ await api.get(endPoint, payload);
277
+ let responseBody;
278
+ if (fromArray == "[]") {
279
+ responseBody = await context.response["Response Body"];
280
+ } else {
281
+ responseBody = await context.response["Response Body"][fromArray];
282
+ }
283
+ const randomContent =
284
+ responseBody[random.number.int({ min: 0, max: responseBody.length - 1 })];
285
+ context.vars[variableKey] = randomContent[varName];
286
+ },
287
+ );
288
+
289
+
290
+ When(
291
+ "User sets {string} date {int} days from today",
292
+ async function (dateName, days) {
293
+ const expiresAt =
294
+ days < 0
295
+ ? time().subtract(Math.abs(days), "day").toISOString()
296
+ : time().add(days, "day").toISOString();
297
+
298
+ context.vars[dateName] = expiresAt;
299
+ },
300
300
  );