artes 1.1.35 → 1.1.37

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.35",
3
+ "version": "1.1.37",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@ When(
17
17
  "User sends GET request to {string} with payload:",
18
18
  async function (url, payload) {
19
19
  await api.get(url, payload);
20
- },
20
+ }
21
21
  );
22
22
 
23
23
  When(
@@ -25,7 +25,7 @@ When(
25
25
  async function (url, vars) {
26
26
  await api.get(url);
27
27
  await extractVarsFromResponse(context.response["Response Body"], vars);
28
- },
28
+ }
29
29
  );
30
30
 
31
31
  When(
@@ -33,7 +33,7 @@ When(
33
33
  async function (url, vars, payload) {
34
34
  await api.get(url, payload);
35
35
  await extractVarsFromResponse(context.response["Response Body"], vars);
36
- },
36
+ }
37
37
  );
38
38
 
39
39
  When("User sends HEAD request to {string}", async function (url) {
@@ -44,7 +44,7 @@ When(
44
44
  "User sends POST request to {string} with payload:",
45
45
  async function (url, payload) {
46
46
  await api.post(url, payload);
47
- },
47
+ }
48
48
  );
49
49
 
50
50
  When(
@@ -52,14 +52,14 @@ When(
52
52
  async function (url, vars, payload) {
53
53
  await api.post(url, payload);
54
54
  await extractVarsFromResponse(context.response["Response Body"], vars);
55
- },
55
+ }
56
56
  );
57
57
 
58
58
  When(
59
59
  "User sends multipart POST request to {string} with payload:",
60
60
  async (url, payload) => {
61
61
  await api.post(url, payload, "multipart");
62
- },
62
+ }
63
63
  );
64
64
 
65
65
  When(
@@ -67,14 +67,14 @@ When(
67
67
  async (url, vars, payload) => {
68
68
  await api.post(url, payload, "multipart");
69
69
  await extractVarsFromResponse(context.response["Response Body"], vars);
70
- },
70
+ }
71
71
  );
72
72
 
73
73
  When(
74
74
  "User sends x-www-form-urlencoded POST request to {string} with payload:",
75
75
  async (url, payload) => {
76
76
  await api.post(url, payload, "application/x-www-form-urlencoded");
77
- },
77
+ }
78
78
  );
79
79
 
80
80
  When(
@@ -82,14 +82,14 @@ When(
82
82
  async (url, vars, payload) => {
83
83
  await api.post(url, payload, "application/x-www-form-urlencoded");
84
84
  await extractVarsFromResponse(context.response["Response Body"], vars);
85
- },
85
+ }
86
86
  );
87
87
 
88
88
  When(
89
89
  "User sends PUT request to {string} with payload:",
90
90
  async function (url, payload) {
91
91
  await api.put(url, payload);
92
- },
92
+ }
93
93
  );
94
94
 
95
95
  When(
@@ -97,14 +97,14 @@ When(
97
97
  async function (url, vars, payload) {
98
98
  await api.put(url, payload);
99
99
  await extractVarsFromResponse(context.response["Response Body"], vars);
100
- },
100
+ }
101
101
  );
102
102
 
103
103
  When(
104
104
  "User sends multipart PUT request to {string} with payload:",
105
105
  async function (url, payload) {
106
106
  await api.put(url, payload, "multipart");
107
- },
107
+ }
108
108
  );
109
109
 
110
110
  When(
@@ -112,14 +112,14 @@ When(
112
112
  async function (url, vars, payload) {
113
113
  await api.put(url, payload, "multipart");
114
114
  await extractVarsFromResponse(context.response["Response Body"], vars);
115
- },
115
+ }
116
116
  );
117
117
 
118
118
  When(
119
119
  "User sends x-www-form-urlencoded PUT request to {string} with payload:",
120
120
  async (url, payload) => {
121
121
  await api.put(url, payload, "application/x-www-form-urlencoded");
122
- },
122
+ }
123
123
  );
124
124
 
125
125
  When(
@@ -127,14 +127,14 @@ When(
127
127
  async (url, vars, payload) => {
128
128
  await api.put(url, payload, "application/x-www-form-urlencoded");
129
129
  await extractVarsFromResponse(context.response["Response Body"], vars);
130
- },
130
+ }
131
131
  );
132
132
 
133
133
  When(
134
134
  "User sends PATCH request to {string} with payload:",
135
135
  async function (url, payload) {
136
136
  await api.patch(url, payload);
137
- },
137
+ }
138
138
  );
139
139
 
140
140
  When(
@@ -142,14 +142,14 @@ When(
142
142
  async function (url, vars, payload) {
143
143
  await api.patch(url, payload);
144
144
  await extractVarsFromResponse(context.response["Response Body"], vars);
145
- },
145
+ }
146
146
  );
147
147
 
148
148
  When(
149
149
  "User sends multipart PATCH request to {string} with payload:",
150
150
  async function (url, payload) {
151
151
  await api.patch(url, payload, "multipart");
152
- },
152
+ }
153
153
  );
154
154
 
155
155
  When(
@@ -157,14 +157,14 @@ When(
157
157
  async function (url, vars, payload) {
158
158
  await api.patch(url, payload, "multipart");
159
159
  await extractVarsFromResponse(context.response["Response Body"], vars);
160
- },
160
+ }
161
161
  );
162
162
 
163
163
  When(
164
164
  "User sends x-www-form-urlencoded PATCH request to {string} with payload:",
165
165
  async (url, payload) => {
166
166
  await api.patch(url, payload, "application/x-www-form-urlencoded");
167
- },
167
+ }
168
168
  );
169
169
 
170
170
  When(
@@ -172,7 +172,7 @@ When(
172
172
  async (url, vars, payload) => {
173
173
  await api.patch(url, payload, "application/x-www-form-urlencoded");
174
174
  await extractVarsFromResponse(context.response["Response Body"], vars);
175
- },
175
+ }
176
176
  );
177
177
 
178
178
  When("User sends DELETE request to {string}", async function (url) {
@@ -184,14 +184,14 @@ When(
184
184
  async function (url, vars) {
185
185
  await api.delete(url);
186
186
  await extractVarsFromResponse(context.response["Response Body"], vars);
187
- },
187
+ }
188
188
  );
189
189
 
190
190
  When(
191
191
  "User sends DELETE request to {string} with payload:",
192
192
  async function (url, payload) {
193
193
  await api.delete(url, payload);
194
- },
194
+ }
195
195
  );
196
196
 
197
197
  When(
@@ -199,7 +199,7 @@ When(
199
199
  async function (url, vars, payload) {
200
200
  await api.delete(url, payload);
201
201
  await extractVarsFromResponse(context.response["Response Body"], vars);
202
- },
202
+ }
203
203
  );
204
204
 
205
205
  When(
@@ -210,14 +210,14 @@ When(
210
210
  vars,
211
211
  customVarName,
212
212
  );
213
- },
213
+ }
214
214
  );
215
215
 
216
216
  When(
217
217
  "User saves {string} variable as {string}",
218
218
  async function (value, customVarName) {
219
219
  saveVar(value, customVarName);
220
- },
220
+ }
221
221
  );
222
222
 
223
223
  When("User wants to see saved variables", async function () {
@@ -268,25 +268,34 @@ When(
268
268
  default:
269
269
  throw new Error(`Unsupported HTTP method: ${httpMethod}`);
270
270
  }
271
- },
271
+ }
272
272
  );
273
273
 
274
- When(
275
- "User expects that request should have {int} status code",
276
- async function (expectedStatusCode) {
277
- const actualStatusCode = await context.response.Response.status();
278
- expect(actualStatusCode).toBe(expectedStatusCode);
274
+ Given(
275
+ "User sends GET request to {string} and save {string} variable from {string} array as {string} randomly with payload:",
276
+ async (endPoint, varName, fromArray, variableKey, payload) => {
277
+ await api.get(endPoint, payload);
278
+ let responseBody;
279
+ if (fromArray == "[]") {
280
+ responseBody = await context.response["Response Body"];
281
+ } else {
282
+ responseBody = await context.response["Response Body"][fromArray];
283
+ }
284
+ const randomContent =
285
+ responseBody[random.number.int({ min: 0, max: responseBody.length - 1 })];
286
+ context.vars[variableKey] = randomContent[varName];
279
287
  },
280
288
  );
281
289
 
282
- When(
283
- "User expects that response body should match {string} schema",
284
- async function (expectedSchema) {
285
- const schema = await selector(expectedSchema);
286
- const ajv = await new Ajv();
287
- const validate = await ajv.compile(schema);
288
- const responseBody = await context.response["Response Body"];
289
- const valid = await validate(responseBody);
290
- await expect(valid).toBe(true);
290
+
291
+ Given(
292
+ "User sets {string} date {int} days from today",
293
+ async function (dateName, days) {
294
+ const expiresAt =
295
+ days < 0
296
+ ? time().subtract(Math.abs(days), "day").toISOString()
297
+ : time().add(days, "day").toISOString();
298
+
299
+ context.vars[dateName] = expiresAt;
291
300
  },
292
- );
301
+ );
@@ -824,3 +824,30 @@ Then(
824
824
  expect(context.vars[field]).toBe(value);
825
825
  },
826
826
  );
827
+
828
+ Then('User expects that {string} should match {string}', async (value1, value2) => {
829
+ await expect(resolveVariable(value1)).toBe(value2)
830
+ })
831
+
832
+ When(
833
+ "User expects that response body should match {string} schema",
834
+ async function (expectedSchema) {
835
+ if(expectedSchema !="" ){
836
+ const schema = await selector(expectedSchema);
837
+ const ajv = await new Ajv();
838
+ const validate = await ajv.compile(schema);
839
+ const responseBody = await context.response["Response Body"];
840
+ const valid = await validate(responseBody);
841
+ await expect(valid).toBe(true);
842
+ }
843
+ }
844
+ );
845
+
846
+
847
+ When(
848
+ "User expects that request should have {int} status code",
849
+ async function (expectedStatusCode) {
850
+ const actualStatusCode = await context.response.Response.status();
851
+ expect(actualStatusCode).toBe(expectedStatusCode);
852
+ }
853
+ );