Skip to content

Commit 3d759c1

Browse files
committed
fix(deps): update @socketsecurity/lib to v3.3.3 and fix Windows tests
- Move @socketsecurity/lib to dependencies (was in devDependencies) - Update @socketsecurity/lib to v3.3.3 - Make path resolution tests cross-platform compatible The path resolution tests were failing on Windows CI because: 1. Tests assumed Unix-style absolute paths (starting with /) 2. normalizePath() converts all backslashes to forward slashes Fixed by using normalizePath() on expected values to match actual output format (forward slashes on all platforms).
1 parent 028afc4 commit 3d759c1

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"update": "node scripts/update.mjs"
5656
},
5757
"dependencies": {
58-
"@socketsecurity/lib": "3.3.2"
58+
"@socketsecurity/lib": "3.3.3"
5959
},
6060
"devDependencies": {
6161
"@babel/generator": "7.28.5",

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/utils.test.mts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
* - create-request-body-json.test.mts
1111
*/
1212

13+
import path from 'node:path'
14+
1315
import { describe, expect, it } from 'vitest'
1416

17+
import { normalizePath } from '@socketsecurity/lib/path'
18+
1519
import {
1620
createRequestBodyForJson,
1721
normalizeBaseUrl,
@@ -63,7 +67,7 @@ describe('Path Resolution', () => {
6367
it('should resolve relative path to absolute', () => {
6468
const result = resolveBasePath('.')
6569
expect(result).toContain('socket-sdk-js')
66-
expect(result.startsWith('/')).toBe(true)
70+
expect(path.isAbsolute(result)).toBe(true)
6771
})
6872

6973
it('should resolve nested relative path', () => {
@@ -73,9 +77,10 @@ describe('Path Resolution', () => {
7377
})
7478

7579
it('should return absolute path unchanged', () => {
76-
const absolutePath = '/tmp/test'
80+
// Use a truly absolute path for cross-platform testing
81+
const absolutePath = normalizePath(path.resolve('/tmp/test'))
7782
const result = resolveBasePath(absolutePath)
78-
expect(result).toBe('/tmp/test')
83+
expect(result).toBe(absolutePath)
7984
})
8085

8186
it('should default to cwd when no argument provided', () => {
@@ -92,23 +97,27 @@ describe('Path Resolution', () => {
9297
expect(result).toHaveLength(2)
9398
expect(result[0]).toContain('socket-sdk-js/package.json')
9499
expect(result[1]).toContain('socket-sdk-js/src/index.ts')
95-
result.forEach(p => expect(p.startsWith('/')).toBe(true))
100+
result.forEach(p => expect(path.isAbsolute(p)).toBe(true))
96101
})
97102

98103
it('should handle absolute paths in array', () => {
99-
const paths = ['/tmp/test.txt', '/var/log/app.log']
104+
// Use truly absolute paths for cross-platform testing
105+
const path1 = normalizePath(path.resolve('/tmp/test.txt'))
106+
const path2 = normalizePath(path.resolve('/var/log/app.log'))
107+
const paths = [path1, path2]
100108
const result = resolveAbsPaths(paths)
101109

102-
expect(result).toEqual(['/tmp/test.txt', '/var/log/app.log'])
110+
expect(result).toEqual([path1, path2])
103111
})
104112

105113
it('should resolve relative to specified base path', () => {
106114
const paths = ['file1.txt', 'file2.txt']
107-
const result = resolveAbsPaths(paths, '/custom/base')
115+
const basePath = normalizePath(path.resolve('/custom/base'))
116+
const result = resolveAbsPaths(paths, basePath)
108117

109118
expect(result).toHaveLength(2)
110-
expect(result[0]).toBe('/custom/base/file1.txt')
111-
expect(result[1]).toBe('/custom/base/file2.txt')
119+
expect(result[0]).toBe(normalizePath(path.join(basePath, 'file1.txt')))
120+
expect(result[1]).toBe(normalizePath(path.join(basePath, 'file2.txt')))
112121
})
113122

114123
it('should handle empty array', () => {
@@ -117,11 +126,13 @@ describe('Path Resolution', () => {
117126
})
118127

119128
it('should handle mixed absolute and relative paths', () => {
120-
const paths = ['./relative.txt', '/absolute.txt']
121-
const result = resolveAbsPaths(paths, '/base')
129+
const basePath = normalizePath(path.resolve('/base'))
130+
const absolutePath = normalizePath(path.resolve('/absolute.txt'))
131+
const paths = ['./relative.txt', absolutePath]
132+
const result = resolveAbsPaths(paths, basePath)
122133

123-
expect(result[0]).toBe('/base/relative.txt')
124-
expect(result[1]).toBe('/absolute.txt')
134+
expect(result[0]).toBe(normalizePath(path.join(basePath, 'relative.txt')))
135+
expect(result[1]).toBe(absolutePath)
125136
})
126137
})
127138
})

0 commit comments

Comments
 (0)