@cuppet/core 1.3.7 → 1.3.8

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.
@@ -43,7 +43,10 @@ Given('that I have a multipart request body', async function (docString) {
43
43
  Given(
44
44
  'I put {string} to {string} property of {string} element in the body',
45
45
  async function (value, property, parentObj) {
46
- await apiSteps.iPutValuesInRequestBody(value, property, parentObj);
46
+ const checkedValue = await dataStorage.checkForSavedVariable(value);
47
+ const checkedProperty = await dataStorage.checkForSavedVariable(property);
48
+ const checkedParentObj = await dataStorage.checkForSavedVariable(parentObj);
49
+ await apiSteps.iPutValuesInRequestBody(checkedValue, checkedProperty, checkedParentObj);
47
50
  }
48
51
  );
49
52
 
@@ -56,5 +59,7 @@ Given('I validate that the page is a valid XML', async function () {
56
59
  await apiSteps.validateXMLEndpoint(currentPath);
57
60
  });
58
61
  Then('the response header {string} should be {string}', async function (header, value) {
59
- await apiSteps.validateResponseHeader(header, value);
62
+ const checkedHeader = await dataStorage.checkForSavedVariable(header);
63
+ const checkedValue = await dataStorage.checkForSavedVariable(value);
64
+ await apiSteps.validateResponseHeader(checkedHeader, checkedValue);
60
65
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuppet/core",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Core testing framework components for Cuppet - BDD framework based on Cucumber and Puppeteer",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -154,11 +154,10 @@ module.exports = {
154
154
  * @returns {Promise<Object>} - returns the request body object
155
155
  */
156
156
  iPutValuesInRequestBody: async function (value, property, object) {
157
- const preparedValue = await storage.checkForVariable(value);
158
157
  if (!this.request) {
159
158
  this.request = {};
160
159
  }
161
- this.request[object][property] = preparedValue;
160
+ this.request[object][property] = value;
162
161
  return this.request;
163
162
  },
164
163
 
@@ -272,15 +271,9 @@ module.exports = {
272
271
  validateResponseHeader: async function (header, value) {
273
272
  // Resolve header and value from variables or user input.
274
273
  // The header is checked directly for faster execution as it is less likely to contain variables.
275
- const resolveHeader = await storage.checkForVariable(header);
276
- const resolveValue = await storage.checkForSavedVariable(value);
277
- const actualValue = this.response.headers[resolveHeader.toLowerCase()];
278
- assert.isDefined(actualValue, `The response header "${resolveHeader}" is not found!`);
279
- assert.strictEqual(
280
- actualValue,
281
- resolveValue,
282
- `The response header "${resolveHeader}" does not have the expected value`
283
- );
274
+ const actualValue = this.response.headers[header.toLowerCase()];
275
+ assert.isDefined(actualValue, `The response header "${header}" is not found!`);
276
+ assert.strictEqual(actualValue, value, `The response header "${header}" does not have the expected value`);
284
277
  },
285
278
 
286
279
  /**
@@ -94,7 +94,7 @@ module.exports = {
94
94
 
95
95
  /**
96
96
  * Check for variable existence or return the inputted value.
97
- * To be used in steps which can work both with JSON vars and direct user input
97
+ * Do not use separately in step definitions, use checkForSavedVariable instead.
98
98
  * @param variable
99
99
  * @returns {*}
100
100
  */
@@ -110,7 +110,11 @@ module.exports = {
110
110
  * @returns {Promise<*>}
111
111
  */
112
112
  checkForSavedVariable: async function (data) {
113
- return data.replace(/%([a-zA-Z_-]+)%/g, (match, p1) => {
113
+ // First check if the whole variable is stored
114
+ const resolvedData = this.checkForVariable(data);
115
+
116
+ // Then check for %% pattern replacements
117
+ return resolvedData.replace(/%([a-zA-Z_-]+)%/g, (match, p1) => {
114
118
  return this.checkForVariable(p1);
115
119
  });
116
120
  },