artes 1.1.32 → 1.1.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -89,6 +89,14 @@ async function requestMaker(headers, data, requestDataType) {
89
89
  case "multipart":
90
90
  Object.assign(request, { multipart: data });
91
91
  break;
92
+ case "urlencoded":
93
+ case "application/x-www-form-urlencoded":
94
+ const urlEncodedData = new URLSearchParams(data).toString();
95
+ Object.assign(request, { data: urlEncodedData });
96
+ break;
97
+ case "form":
98
+ Object.assign(request, { form: data });
99
+ break;
92
100
  default:
93
101
  Object.assign(request, { data: data });
94
102
  }
@@ -180,6 +188,24 @@ const api = {
180
188
  requestDataType,
181
189
  );
182
190
  break;
191
+ case "urlencoded":
192
+ case "application/x-www-form-urlencoded":
193
+ req = await requestMaker(
194
+ {
195
+ ...payloadJSON?.headers,
196
+ "Content-Type": "application/x-www-form-urlencoded",
197
+ },
198
+ payloadJSON?.body || {},
199
+ requestDataType,
200
+ );
201
+ break;
202
+ case "form":
203
+ req = await requestMaker(
204
+ payloadJSON?.headers || {},
205
+ payloadJSON?.body || {},
206
+ requestDataType,
207
+ );
208
+ break;
183
209
  default:
184
210
  req = await requestMaker(
185
211
  payloadJSON?.headers || {},
@@ -214,7 +240,24 @@ const api = {
214
240
  formRequest || {},
215
241
  requestDataType,
216
242
  );
217
-
243
+ break;
244
+ case "urlencoded":
245
+ case "application/x-www-form-urlencoded":
246
+ req = await requestMaker(
247
+ {
248
+ ...payloadJSON?.headers,
249
+ "Content-Type": "application/x-www-form-urlencoded",
250
+ },
251
+ payloadJSON?.body || {},
252
+ requestDataType,
253
+ );
254
+ break;
255
+ case "form":
256
+ req = await requestMaker(
257
+ payloadJSON?.headers || {},
258
+ payloadJSON?.body || {},
259
+ requestDataType,
260
+ );
218
261
  break;
219
262
  default:
220
263
  req = await requestMaker(
@@ -250,7 +293,24 @@ const api = {
250
293
  formRequest || {},
251
294
  requestDataType,
252
295
  );
253
-
296
+ break;
297
+ case "urlencoded":
298
+ case "application/x-www-form-urlencoded":
299
+ req = await requestMaker(
300
+ {
301
+ ...payloadJSON?.headers,
302
+ "Content-Type": "application/x-www-form-urlencoded",
303
+ },
304
+ payloadJSON?.body || {},
305
+ requestDataType,
306
+ );
307
+ break;
308
+ case "form":
309
+ req = await requestMaker(
310
+ payloadJSON?.headers || {},
311
+ payloadJSON?.body || {},
312
+ requestDataType,
313
+ );
254
314
  break;
255
315
  default:
256
316
  req = await requestMaker(
@@ -295,4 +355,4 @@ const api = {
295
355
  },
296
356
  };
297
357
 
298
- module.exports = { api };
358
+ module.exports = { api };
@@ -70,6 +70,21 @@ When(
70
70
  },
71
71
  );
72
72
 
73
+ When(
74
+ "User sends x-www-form-urlencoded POST request to {string} with payload:",
75
+ async (url, payload) => {
76
+ await api.post(url, payload, "application/x-www-form-urlencoded");
77
+ },
78
+ );
79
+
80
+ When(
81
+ "User sends x-www-form-urlencoded POST request to {string} with payload and saves {string} variables",
82
+ async (url, vars, payload) => {
83
+ await api.post(url, payload, "application/x-www-form-urlencoded");
84
+ await extractVarsFromResponse(context.response["Response Body"], vars);
85
+ },
86
+ );
87
+
73
88
  When(
74
89
  "User sends PUT request to {string} with payload:",
75
90
  async function (url, payload) {
@@ -100,6 +115,21 @@ When(
100
115
  },
101
116
  );
102
117
 
118
+ When(
119
+ "User sends x-www-form-urlencoded PUT request to {string} with payload:",
120
+ async (url, payload) => {
121
+ await api.put(url, payload, "application/x-www-form-urlencoded");
122
+ },
123
+ );
124
+
125
+ When(
126
+ "User sends x-www-form-urlencoded PUT request to {string} with payload and saves {string} variables",
127
+ async (url, vars, payload) => {
128
+ await api.put(url, payload, "application/x-www-form-urlencoded");
129
+ await extractVarsFromResponse(context.response["Response Body"], vars);
130
+ },
131
+ );
132
+
103
133
  When(
104
134
  "User sends PATCH request to {string} with payload:",
105
135
  async function (url, payload) {
@@ -130,6 +160,21 @@ When(
130
160
  },
131
161
  );
132
162
 
163
+ When(
164
+ "User sends x-www-form-urlencoded PATCH request to {string} with payload:",
165
+ async (url, payload) => {
166
+ await api.patch(url, payload, "application/x-www-form-urlencoded");
167
+ },
168
+ );
169
+
170
+ When(
171
+ "User sends x-www-form-urlencoded PATCH request to {string} with payload and saves {string} variables",
172
+ async (url, vars, payload) => {
173
+ await api.patch(url, payload, "application/x-www-form-urlencoded");
174
+ await extractVarsFromResponse(context.response["Response Body"], vars);
175
+ },
176
+ );
177
+
133
178
  When("User sends DELETE request to {string}", async function (url) {
134
179
  await api.delete(url);
135
180
  });
@@ -150,7 +195,7 @@ When(
150
195
  );
151
196
 
152
197
  When(
153
- "User sends DELETE request to {string} with payload and saves {string} variables",
198
+ "User sends DELETE request to {string} with payload and saves {string}",
154
199
  async function (url, vars, payload) {
155
200
  await api.delete(url, payload);
156
201
  await extractVarsFromResponse(context.response["Response Body"], vars);
@@ -1,13 +1,13 @@
1
1
  const { Given, context, random } = require("../helper/imports/commons");
2
2
  const { api } = require("../helper/stepFunctions/exporter");
3
3
 
4
- Given("User sets random word as {string} variable", async (key) => {
4
+ Given("User sets random word as {string}", async (key) => {
5
5
  const word = random.lorem.word();
6
6
  context.vars[key] = word;
7
7
  });
8
8
 
9
9
  Given(
10
- "User sets random word that has {int} character as {string} variable",
10
+ "User sets random word that has {int} character as {string}",
11
11
  async (key, count) => {
12
12
  const word = random.lorem.word(count);
13
13
  context.vars[key] = word;
@@ -15,20 +15,20 @@ Given(
15
15
  );
16
16
 
17
17
  Given(
18
- "User sets random word that has character between {int} and {int} as {string} variable",
18
+ "User sets random word that has character between {int} and {int} as {string}",
19
19
  async (key, from, to) => {
20
20
  const word = random.lorem.word({ length: { min: from, max: to } });
21
21
  context.vars[key] = word;
22
22
  },
23
23
  );
24
24
 
25
- Given("User sets random words as {string} variable", async (key) => {
25
+ Given("User sets random words as {string}", async (key) => {
26
26
  const words = random.lorem.words();
27
27
  context.vars[key] = words;
28
28
  });
29
29
 
30
30
  Given(
31
- "User sets random {int} words as {string} variable",
31
+ "User sets random {int} words as {string}",
32
32
  async (key, count) => {
33
33
  const words = random.lorem.words({ wordCount: count });
34
34
  context.vars[key] = words;
@@ -36,7 +36,7 @@ Given(
36
36
  );
37
37
 
38
38
  Given(
39
- "User sets random words that range between {int} and {int} as {string} variable",
39
+ "User sets random words that range between {int} and {int} as {string}",
40
40
  async (key, from, to) => {
41
41
  const words = random.lorem.words({ min: from, max: to });
42
42
  context.vars[key] = words;
@@ -44,7 +44,7 @@ Given(
44
44
  );
45
45
 
46
46
  Given(
47
- "User sets random number from {int} to {int} as {string} variable",
47
+ "User sets random number from {int} to {int} as {string}",
48
48
  async (from, to, key) => {
49
49
  const number = random.number.int({ min: from, max: to });
50
50
  context.vars[key] = number;
@@ -66,3 +66,24 @@ Given(
66
66
  context.vars[variableKey] = randomContent[varName];
67
67
  },
68
68
  );
69
+
70
+ Given("User sets email as a {string}", (key) => {
71
+ const email = random.internet.email();
72
+ context.vars[key] = email;
73
+ });
74
+
75
+ Given('User sets url as a {string}', (urlName) => {
76
+ const randomUrl = random.internet.url();
77
+ context.vars[urlName] = randomUrl;
78
+ })
79
+
80
+ Given('User sets random sentences that has {int} paragraph as {string}', (count, variable) => {
81
+ const sentences = random.lorem.paragraph(count);
82
+ context.vars[variable] = sentences;
83
+ })
84
+
85
+ Given("User sets random value from given {string} array as {string}", async (array, key) => {
86
+ const parsedArray = JSON.parse(array.replace(/'/g, '"'));
87
+ const randomValue = parsedArray[Math.floor(Math.random() * parsedArray.length)];
88
+ context.vars[key] = randomValue;
89
+ });