@dev-blinq/cucumber_client 1.0.1659-dev → 1.0.1661-dev

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.
@@ -292,25 +292,46 @@ const GherkinToObject = (gherkin) => {
292
292
 
293
293
  // remove lines starting with "Scenario:" or "Scenario Outline:" that contain the scenario name until the next scenario and then append the new scenario content
294
294
  // assumes that there are no multiple scenarios with the same name and having comments and tags in each scenario
295
- function updateExistingScenario({ featureFileContent, scenarioName, scenarioContent }) {
295
+ function updateExistingScenario({
296
+ featureFileContent,
297
+ scenarioName: newScenarioName,
298
+ scenarioContent: newScenarioContent,
299
+ }) {
296
300
  const featureFileObject = GherkinToObject(featureFileContent);
297
301
  if (featureFileObject.error) return "error";
302
+
298
303
  const results = [];
299
- let skipScenarioIndex = -1;
300
304
  results.push(`Feature: ${featureFileObject.featureName}`);
305
+
306
+ let indexOfScenarioToUpdate = -1;
307
+
308
+ for (let i = 0; i < featureFileObject.scenarios.length; i++) {
309
+ if (featureFileObject.scenarios[i].name === newScenarioName) {
310
+ indexOfScenarioToUpdate = i;
311
+ break;
312
+ }
313
+ }
314
+
301
315
  for (let i = 0; i < featureFileObject.scenarios.length; i++) {
302
316
  const scenario = featureFileObject.scenarios[i];
303
- if (scenario.name === scenarioName) {
304
- skipScenarioIndex = i;
317
+
318
+ if (i === indexOfScenarioToUpdate) {
319
+ results.push("");
320
+ results.push(newScenarioContent.trim());
321
+ results.push("");
305
322
  continue;
306
323
  }
307
- let scenarioContent = `${scenario.hasParams ? "Scenario Outline" : "Scenario"}: ${scenario.name}`;
324
+
325
+ let scenarioHeader = `${scenario.hasParams ? "Scenario Outline" : "Scenario"}: ${scenario.name}`;
308
326
  let tagsLine;
327
+
309
328
  if (scenario.tags?.length > 0) {
310
- tagsLine = `${scenario.tags.map((t) => `@${t}`).join(" ")}`;
329
+ tagsLine = scenario.tags.map((t) => `@${t}`).join(" ");
311
330
  }
331
+
312
332
  if (tagsLine) results.push("\t" + tagsLine);
313
- results.push(`\t${scenarioContent}`);
333
+ results.push(`\t${scenarioHeader}`);
334
+
314
335
  for (const step of scenario.steps) {
315
336
  if (step.type === "examples") {
316
337
  results.push(`\t\tExamples:`);
@@ -323,12 +344,10 @@ function updateExistingScenario({ featureFileContent, scenarioName, scenarioCont
323
344
  }
324
345
  results.push("");
325
346
  }
326
- let finalContent = results.join("\n");
327
- if (skipScenarioIndex !== -1) {
328
- finalContent = results.join("\n") + "\n" + scenarioContent;
329
- }
330
- return finalContent;
347
+
348
+ return results.join("\n");
331
349
  }
350
+
332
351
  export async function updateFeatureFile({ featureName, scenario, override, projectDir }) {
333
352
  const featureFilePath = path.join(projectDir, "features", featureName + ".feature");
334
353
  const isFeatureFileExists = existsSync(featureFilePath);
@@ -108,6 +108,7 @@ class ScenarioUploadService {
108
108
  {
109
109
  scenarioId,
110
110
  projectId,
111
+ testcase_id: process.env.TESTCASE_ID,
111
112
  },
112
113
  {
113
114
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1659-dev",
3
+ "version": "1.0.1661-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",