artes 1.7.4 → 1.7.6

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