Skip to content

[Repo Assist] test: add 3 unit tests for findFiles name-priority, depth-priority, and empty-names#113

Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/improve-findfiles-tests-2026-03-29-db392e52f913bc2a
Draft

[Repo Assist] test: add 3 unit tests for findFiles name-priority, depth-priority, and empty-names#113
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/improve-findfiles-tests-2026-03-29-db392e52f913bc2a

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated draft PR from Repo Assist, an AI assistant.

Summary

Adds three targeted unit tests to test/unit.test.js that document and pin the exact selection behaviour of findFiles() when multiple config-file candidates compete. These cases are relied on by getStandard() to apply the correct PHPCS config-file priority.

New tests

Test What it pins
returns first matching name when multiple config files exist in same directory .phpcs.xml beats phpcs.xml when both are present — matching PHPCS priority rules. The names array order is the tiebreaker.
prefers file in deeper directory over ancestor when names overlap When the same filename exists at both the workspace root and a sub-directory, the deeper one wins. Complements the existing returns file in the deepest matching directory when multiple exist test with an identical-name scenario.
returns null for empty names array Defensive edge case: an empty candidates list never throws and always returns null.

Why these tests matter

The existing test suite verified array-of-names handling only when a single file existed; there was no test confirming which candidate wins when multiple files are present. Without a pinning test, a refactor could accidentally reverse the priority order, silently breaking PHPCS config detection for any project that has both .phpcs.xml and phpcs.xml.

Test Status

All 10 unit tests pass (7 existing + 3 new):

node --test test/unit.test.js
✔ findFiles (10 tests, 10 passing)

Syntax check: node --check extension.js — no errors

⚠️ Integration tests: require VS Code GUI environment — not applicable to this pure-utility change.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…nd empty-names

Documents the exact selection behaviour of findFiles when multiple
config-file candidates are present, which is relied on by getStandard()
to honour PHPCS config-file priority (.phpcs.xml beats phpcs.xml).

New tests:
- 'returns first matching name when multiple config files exist in
  same directory': verifies that .phpcs.xml is preferred over phpcs.xml
  when both are present, matching PHPCS priority rules.
- 'prefers file in deeper directory over ancestor when names overlap':
  explicit counterpart to the existing depth test using the same name
  in root and sub-dir, making the deepest-first behaviour unambiguous.
- 'returns null for empty names array': defensive edge case; ensures
  an empty candidates list never throws and always returns null.

All 10 tests pass (node --test test/unit.test.js).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants