Skip to content

Add test coverage for refactored filepath candidate functions#156

Merged
tninja merged 3 commits intokang_featfrom
copilot/sub-pr-155
Feb 5, 2026
Merged

Add test coverage for refactored filepath candidate functions#156
tninja merged 3 commits intokang_featfrom
copilot/sub-pr-155

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 4, 2026

PR #155 removed three tests during refactoring but the underlying behaviors still needed verification. This PR restores test coverage adapted to the new implementation.

Tests Added

Helper function coverage:

  • ai-code--normalize-path - path normalization for existing/non-existing files
  • ai-code--candidate-path - relative (@-prefixed) paths for in-repo files, absolute paths for out-of-repo files
  • ai-code--visible-window-files - file retrieval without git repo filtering (new behavior)
  • ai-code--recent-buffer-paths - recent buffer collection with candidate formatting
  • ai-code--current-frame-dired-paths - dired directory extraction

Integration behavior coverage:

  • Visible files prioritized over buffer files in candidate list
  • Dired directories included and prioritized in candidates
  • Recent buffer paths include both files and directories

Example Test Structure

(ert-deftest ai-code-test-candidate-path-out-of-repo ()
  "Test that ai-code--candidate-path returns absolute path for out-of-repo files."
  (ai-code-with-test-repo
   (let ((out-file (expand-file-name "outside.el" temporary-file-directory)))
     (unwind-protect
         (progn
           (with-temp-file out-file (insert "content"))
           (let ((result (ai-code--candidate-path out-file (file-truename git-root))))
             ;; Should return absolute path (truename)
             (should (string= result (file-truename out-file)))))
       (when (file-exists-p out-file) (delete-file out-file))))))

Total: 9 test cases added covering all refactored functions and their integration behaviors.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 4, 2026 16:00
Co-authored-by: tninja <714625+tninja@users.noreply.github.com>
Co-authored-by: tninja <714625+tninja@users.noreply.github.com>
Copilot AI changed the title [WIP] Work in progress to enhance candidate filepath list Add test coverage for refactored filepath candidate functions Feb 4, 2026
Copilot AI requested a review from tninja February 4, 2026 16:03
@tninja tninja marked this pull request as ready for review February 5, 2026 02:26
@tninja tninja merged commit c593dbe into kang_feat Feb 5, 2026
tninja added a commit that referenced this pull request Feb 5, 2026
* visible files logic support out of repo file

* Normalize file paths and improve relative path handling

* Refactor buffer file list to helper functions for clarity

* Add recent buffer paths to git root candidate paths list

* Include Dired directories when collecting recent file paths

* Update ai-code-prompt-mode.el

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* reorder menu

* Add test coverage for refactored filepath candidate functions (#156)

* Initial plan

* Add tests for refactored helper functions and behaviors

Co-authored-by: tninja <714625+tninja@users.noreply.github.com>

* Fix trailing whitespace in test

Co-authored-by: tninja <714625+tninja@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tninja <714625+tninja@users.noreply.github.com>

* Update ai-code-prompt-mode.el

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tninja <714625+tninja@users.noreply.github.com>
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.

2 participants