@cuppet/core 1.3.8 → 2.0.1
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.
|
@@ -40,15 +40,10 @@ Given('that I have a multipart request body', async function (docString) {
|
|
|
40
40
|
const body = JSON.parse(docString);
|
|
41
41
|
await apiSteps.buildMultipartFormData(body);
|
|
42
42
|
});
|
|
43
|
-
Given(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const checkedProperty = await dataStorage.checkForSavedVariable(property);
|
|
48
|
-
const checkedParentObj = await dataStorage.checkForSavedVariable(parentObj);
|
|
49
|
-
await apiSteps.iPutValuesInRequestBody(checkedValue, checkedProperty, checkedParentObj);
|
|
50
|
-
}
|
|
51
|
-
);
|
|
43
|
+
Given('I put {string} to {string} property in the request body', async function (value, objectPath) {
|
|
44
|
+
const checkedValue = await dataStorage.checkForSavedVariable(value);
|
|
45
|
+
await apiSteps.iPutValuesInRequestBody(checkedValue, objectPath);
|
|
46
|
+
});
|
|
52
47
|
|
|
53
48
|
Given('I create json object from {string} file', async function (filePath) {
|
|
54
49
|
const checkedPath = await dataStorage.checkForSavedVariable(filePath);
|
|
@@ -14,4 +14,4 @@ Feature: Open DEMO QA (as base site) and use the elements section
|
|
|
14
14
|
And I wait for element with "#output" selector to appear within "2" seconds
|
|
15
15
|
And I should see the element with selector "#name"
|
|
16
16
|
And I should see the element with selector "#email"
|
|
17
|
-
And I should see the element with selector "p#currentAddress"
|
|
17
|
+
And I should see the element with selector "p#currentAddress"
|
package/package.json
CHANGED
package/src/apiFunctions.js
CHANGED
|
@@ -148,16 +148,28 @@ module.exports = {
|
|
|
148
148
|
* }
|
|
149
149
|
* @async
|
|
150
150
|
* @function prepareRequestBody
|
|
151
|
-
* @param value - the value
|
|
152
|
-
* @param
|
|
153
|
-
* @param object - parent object name
|
|
151
|
+
* @param value - the value to set
|
|
152
|
+
* @param objectPath - the path in dot notation (e.g., "home.user.firstName")
|
|
154
153
|
* @returns {Promise<Object>} - returns the request body object
|
|
155
154
|
*/
|
|
156
|
-
iPutValuesInRequestBody: async function (value,
|
|
155
|
+
iPutValuesInRequestBody: async function (value, objectPath) {
|
|
157
156
|
if (!this.request) {
|
|
158
157
|
this.request = {};
|
|
159
158
|
}
|
|
160
|
-
|
|
159
|
+
|
|
160
|
+
const keys = objectPath.split('.');
|
|
161
|
+
let current = this.request;
|
|
162
|
+
|
|
163
|
+
// Navigate/create the path, stopping before the last key
|
|
164
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
165
|
+
if (!current[keys[i]]) {
|
|
166
|
+
current[keys[i]] = {};
|
|
167
|
+
}
|
|
168
|
+
current = current[keys[i]];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Set the final value
|
|
172
|
+
current[keys[keys.length - 1]] = value;
|
|
161
173
|
return this.request;
|
|
162
174
|
},
|
|
163
175
|
|
|
@@ -188,13 +200,13 @@ module.exports = {
|
|
|
188
200
|
*
|
|
189
201
|
* @async
|
|
190
202
|
* @function propertyIs
|
|
191
|
-
* @param {string} property - The property of the response data to check.
|
|
203
|
+
* @param {string} property - The property of the response data to check. Written in root.parent.child syntax.
|
|
192
204
|
* @param {string} type - The type that the property should be.
|
|
193
205
|
* @throws {Error} - Will throw an error if the property is not of the specified type.
|
|
194
206
|
*/
|
|
195
207
|
propertyIs: async function (property, type) {
|
|
196
|
-
const value = this.response.data
|
|
197
|
-
|
|
208
|
+
const value = await helper.getPropertyValue(this.response.data, property);
|
|
209
|
+
assert.typeOf(value, type, `The property is not an ${type}`);
|
|
198
210
|
},
|
|
199
211
|
|
|
200
212
|
/**
|