Skip to content

test: add unit tests for path helpers in agent/src/path-segments.ts - #518

Merged
dmae97 merged 1 commit into
dmae97:mainfrom
anhnt256:test/path-segments-517
Nov 23, 2026
Merged

dmae97 merged 1 commit into
dmae97:mainfrom
anhnt256:test/path-segments-517

Conversation

@anhnt256

Copy link
Copy Markdown
Contributor

Adds unit tests for the path helpers in packages/agent/src/path-segments.ts, covering all five exported helpers:

  • normalizePathSlashes — backslash conversion
  • joinPathSegments — single-slash joins, empty relative, empty base, absolute relative returned as-is
  • collapsePathSegments — ./.. collapsing, and null when .. escapes above the root
  • canonicalizeLexicalPath — POSIX collapsing, root-escape null, drive-root clamping, drive-relative/UNC forms rejected
  • pathSegmentsOverlap — siblings, containment, case-insensitive comparison, different drives, fails closed on root-escaping paths

Verification:

  • Focused suite: 16/16 pass
  • Full packages/agent suite: 99 files, 1100/1100 tests pass
  • Mutation check: weakening the root-escape guard in collapsePathSegments (return null → continue) fails exactly the 3 fail-closed tests
  • tsgo --noEmit clean; npm run check passes biome and the JS/TS sub-checks (it stops at check:native on this machine because cargo is not installed — unrelated to this change, which adds one TypeScript test file)

Closes #517

@dmae97
dmae97 merged commit 9ee8a60 into dmae97:main Nov 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add unit tests for path helpers in agent/src/path-segments.ts

2 participants