@step-forge/step-forge 0.0.8 → 0.0.9

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.
@@ -81,3 +81,30 @@ Feature: Analyzer dependency verification
81
81
  And there are 2 errors for rule "dependency-check"
82
82
  And an error should mention "given.user"
83
83
  And an error should mention "given.account"
84
+
85
+ # --- Diagnostic range scenarios ---
86
+
87
+ Scenario: Undefined step diagnostic range covers only the step text
88
+ Given a feature file "undefined-step.feature"
89
+ When I analyze the files
90
+ Then there should be 1 error
91
+ And the error on line 4 should span columns 10 to 44
92
+
93
+ Scenario: Ambiguous step diagnostic range covers only the step text
94
+ Given a feature file "ambiguous-step.feature"
95
+ When I analyze the files
96
+ Then there should be 1 error
97
+ And the error on line 3 should span columns 11 to 30
98
+
99
+ Scenario: Missing dependency diagnostic range covers only the step text
100
+ Given a feature file "missing-given-dep.feature"
101
+ When I analyze the files
102
+ Then there should be 1 error
103
+ And the error on line 4 should span columns 10 to 25
104
+
105
+ Scenario: Each diagnostic range is correct with multiple errors
106
+ Given a feature file "missing-multiple-deps.feature"
107
+ When I analyze the files
108
+ Then there should be 2 errors
109
+ And the error on line 4 should span columns 10 to 25
110
+ And the error on line 5 should span columns 10 to 30
@@ -51,3 +51,17 @@ Then(
51
51
  expect(errors).toHaveLength(count);
52
52
  }
53
53
  );
54
+
55
+ Then(
56
+ "the error on line {int} should span columns {int} to {int}",
57
+ function (line: number, startCol: number, endCol: number) {
58
+ const errors = diagnostics.filter(
59
+ (d) => d.severity === "error" && d.range.startLine === line
60
+ );
61
+ expect(errors.length).toBeGreaterThanOrEqual(1);
62
+ const error = errors[0];
63
+ expect(error.range.startColumn).toEqual(startCol);
64
+ expect(error.range.endColumn).toEqual(endCol);
65
+ expect(error.range.endLine).toEqual(line);
66
+ }
67
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@step-forge/step-forge",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "module": "./dist/step-forge.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -126,7 +126,11 @@ function convertSteps(
126
126
  keyword: normalizeKeyword(step.keyword),
127
127
  text: step.text,
128
128
  line: step.location.line,
129
- column: step.location.column ?? 1,
129
+ // step.location.column points to the keyword start; shift past the
130
+ // keyword (which includes a trailing space) so column points to the
131
+ // start of the step text. This makes `column + text.length` produce
132
+ // the correct end position for diagnostic ranges.
133
+ column: (step.location.column ?? 1) + step.keyword.length,
130
134
  }));
131
135
  }
132
136