Skip to content

Add unit tests for lib/resolve-subagent-path.ts #328

Description

@NiveditJain

lib/resolve-subagent-path.ts exports an async resolveSubagentPath(projectsPath, projectName, sessionId, agentId) that probes three candidate paths in priority order and returns the first one that exists, or null. It uses fs/promises#access. There is no unit test.

  1. Create __tests__/lib/resolve-subagent-path.test.ts — model it on __tests__/lib/paths.test.ts for the tmpdir setup pattern.
  2. Import: import { resolveSubagentPath } from "@/lib/resolve-subagent-path";
  3. Use os.tmpdir() + mkdtemp in a beforeEach to build a fresh fixture tree per test, and rm({ recursive: true, force: true }) in afterEach.
  4. Cover: (a) candidate 1 wins (file at <projectsPath>/<projectName>/agent-<id>.jsonl), (b) candidate 2 wins when 1 is missing, (c) candidate 3 wins when 1 and 2 are missing, (d) returns null when nothing exists, (e) a path-traversal agentId like ../escape is refused (the function uses relative() to detect escape).
  5. Run bun run test:run and confirm all cases pass.

Out of scope: changing resolve-subagent-path.ts itself.

Activity

  1. DarpanBaviskar1 commented on May 28, 2026

    @DarpanBaviskar1

    This issue has been resolved by PR #331 . The unit tests for resolveSubagentPath have been implemented in tests/lib/resolve-subagent-path.test.ts and are passing.

    This issue can now be closed.

  2. Abhi-DevHub commented on Jul 21, 2026

    @Abhi-DevHub

    Unit tests for \lib/resolve-subagent-path.ts\ already exist in _tests_/lib/resolve-subagent-path.test.ts\ (6/6 passing). Already committed in main via #519. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions