artes 1.7.14 → 1.7.16

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.7.14",
3
+ "version": "1.7.16",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  const { context } = require("../../hooks/context");
2
+ const path = require("path");
2
3
 
3
4
  let elements = {};
4
5
 
@@ -93,6 +94,10 @@ function getElement(element) {
93
94
  return locator;
94
95
  }
95
96
 
97
+ function normalizeCrossplatformPath(inputPath) {
98
+ return path.normalize(inputPath.replace(/\\/g, "/"));
99
+ }
100
+
96
101
  function pathToCamelCase(path) {
97
102
  const cleaned = path.replace(/\[(\d+)\]/g, "_$1");
98
103
  const parts = cleaned.split(".");
@@ -219,6 +224,7 @@ module.exports = {
219
224
  getSelector,
220
225
  extractVarsFromResponse,
221
226
  pathToCamelCase,
227
+ normalizeCrossplatformPath,
222
228
  saveVar,
223
229
  resolveVariable,
224
230
  };
@@ -7,6 +7,7 @@ const {
7
7
  pathToCamelCase,
8
8
  saveVar,
9
9
  resolveVariable,
10
+ normalizeCrossplatformPath
10
11
  } = require("../controller/elementController");
11
12
  const { context } = require("../../hooks/context");
12
13
 
@@ -56,6 +57,7 @@ module.exports = {
56
57
  selector,
57
58
  extractVarsFromResponse,
58
59
  pathToCamelCase,
60
+ normalizeCrossplatformPath,
59
61
  saveVar,
60
62
  resolveVariable,
61
63
  random,
@@ -5,6 +5,7 @@ const {
5
5
  selector,
6
6
  resolveVariable,
7
7
  moduleConfig,
8
+ normalizeCrossplatformPath
8
9
  } = require("../imports/commons");
9
10
 
10
11
  function getMimeType(filePath) {
@@ -112,7 +113,7 @@ function processForm(requestBody) {
112
113
 
113
114
  if (typeof value === "string") {
114
115
 
115
- const normalizedValue = path.normalize(value);
116
+ const normalizedValue = normalizeCrossplatformPath(value);
116
117
 
117
118
  const looksLikeFilePath =
118
119
  normalizedValue.endsWith(".pdf") ||
@@ -122,7 +123,7 @@ function processForm(requestBody) {
122
123
  normalizedValue.endsWith(".txt") ||
123
124
  normalizedValue.endsWith(".doc") ||
124
125
  normalizedValue.endsWith(".docx") ||
125
- normalizedValue.includes(path.sep);
126
+ normalizedValue.includes("/");
126
127
 
127
128
  if (looksLikeFilePath) {
128
129
  try {
@@ -7,6 +7,7 @@ const {
7
7
  random,
8
8
  moduleConfig,
9
9
  resolveVariable,
10
+ normalizeCrossplatformPath
10
11
  } = require("../helper/imports/commons");
11
12
  const { api } = require("../helper/stepFunctions/exporter");
12
13
  const path = require("path");
@@ -389,14 +390,13 @@ When(
389
390
  async (file, variable) => {
390
391
  file = await resolveVariable(file);
391
392
 
392
- const normalizedFile = path.normalize(file);
393
+ const normalizedFile = normalizeCrossplatformPath(file);
393
394
 
394
395
  const filePath = path.isAbsolute(normalizedFile)
395
396
  ? normalizedFile
396
397
  : path.join(moduleConfig.projectPath, normalizedFile);
397
398
 
398
399
  const fileData = fs.readFileSync(filePath);
399
- const base64Data = fileData.toString("base64");
400
- context.vars[variable] = base64Data;
400
+ context.vars[variable] = fileData.toString("base64");
401
401
  },
402
402
  );