@@ -3,6 +3,22 @@ import {BulkSuppressionRule} from "../../src/config";
33import { Violation , CodeLocation } from "../../src/results" ;
44import { RuleImpl } from "../../src/rules" ;
55import * as path from 'node:path' ;
6+ import * as os from 'node:os' ;
7+
8+ /**
9+ * Helper to create platform-appropriate absolute paths for testing
10+ * On Windows: C:\Users\...
11+ * On Unix: /Users/...
12+ */
13+ function createTestAbsolutePath ( ...segments : string [ ] ) : string {
14+ if ( os . platform ( ) === 'win32' ) {
15+ // Windows: start with C:\ drive
16+ return path . join ( 'C:' , path . sep , ...segments ) ;
17+ } else {
18+ // Unix: start with /
19+ return path . join ( path . sep , ...segments ) ;
20+ }
21+ }
622
723/**
824 * Tests specifically for Bug #2: Workspace Root vs Config Root inconsistency
@@ -80,7 +96,7 @@ describe('Bulk Suppressions - Workspace Root Path Resolution (Bug #2)', () => {
8096 */
8197 it ( 'BUG #2: Paths in config are resolved relative to WORKSPACE ROOT, not config file location' , ( ) => {
8298 // Workspace root (where -w flag points) - use platform-appropriate paths
83- const workspaceRoot = path . join ( path . sep , 'Users' , 'user' , 'workspace' , 'dreamhouse' ) ;
99+ const workspaceRoot = createTestAbsolutePath ( 'Users' , 'user' , 'workspace' , 'dreamhouse' ) ;
84100
85101 // Violation file path (absolute) - use platform-appropriate paths
86102 const violationFilePath = path . join ( workspaceRoot , 'force-app' , 'main' , 'default' , 'react-components' , 'utils.js' ) ;
@@ -115,7 +131,7 @@ describe('Bulk Suppressions - Workspace Root Path Resolution (Bug #2)', () => {
115131
116132 it ( 'BUG #2: Same directory level - workspace root equals config directory (worked before bug fix)' , ( ) => {
117133 // This case worked even with Bug #2 because workspace root === config root
118- const workspaceRoot = path . join ( path . sep , 'Users' , 'user' , 'workspace' , 'project' ) ;
134+ const workspaceRoot = createTestAbsolutePath ( 'Users' , 'user' , 'workspace' , 'project' ) ;
119135 const violationFilePath = path . join ( workspaceRoot , 'utils.js' ) ;
120136
121137 const violation = new MockViolation (
@@ -171,7 +187,7 @@ describe('Bulk Suppressions - Workspace Root Path Resolution (Bug #2)', () => {
171187 } ) ;
172188
173189 it ( 'BUG #2: Multiple files at different levels all resolve correctly from workspace root' , ( ) => {
174- const workspaceRoot = path . join ( path . sep , 'workspace' , 'project' ) ;
190+ const workspaceRoot = createTestAbsolutePath ( 'workspace' , 'project' ) ;
175191
176192 // Violations at different directory levels
177193 const violation1 = new MockViolation (
@@ -219,7 +235,7 @@ describe('Bulk Suppressions - Workspace Root Path Resolution (Bug #2)', () => {
219235 } ) ;
220236
221237 it ( 'BUG #2: Folder-level suppression from workspace root matches nested files' , ( ) => {
222- const workspaceRoot = path . join ( path . sep , 'workspace' , 'project' ) ;
238+ const workspaceRoot = createTestAbsolutePath ( 'workspace' , 'project' ) ;
223239
224240 // Violations in nested folder
225241 const violation1 = new MockViolation (
@@ -256,7 +272,7 @@ describe('Bulk Suppressions - Workspace Root Path Resolution (Bug #2)', () => {
256272
257273 it ( 'Config paths can be relative to workspace root (recommended)' , ( ) => {
258274 // This test documents the recommended usage: paths relative to workspace root
259- const workspaceRoot = path . join ( path . sep , 'workspace' , 'project' ) ;
275+ const workspaceRoot = createTestAbsolutePath ( 'workspace' , 'project' ) ;
260276 const violationFilePath = path . join ( workspaceRoot , 'src' , 'file.js' ) ;
261277
262278 const violation = new MockViolation (
@@ -287,7 +303,7 @@ describe('Bulk Suppressions - Workspace Root Path Resolution (Bug #2)', () => {
287303 * - Both resolve paths relative to workspace root
288304 * - Both fall back to absolute paths if workspace root is null
289305 */
290- const workspaceRoot = path . join ( path . sep , 'Users' , 'user' , 'dreamhouse' ) ;
306+ const workspaceRoot = createTestAbsolutePath ( 'Users' , 'user' , 'dreamhouse' ) ;
291307
292308 // Imagine ignores config: ["force-app/test/**"]
293309 // Imagine bulk suppressions: "force-app/main/default/utils.js"
0 commit comments