Skip to content

test(directory-layout): move sanitizer tests next to src/readme-html-sanitizer.ts - #983

Merged
kitsuyui merged 1 commit into
mainfrom
fix/audit-directory-layout-audit-003
Sep 14, 2026
Merged

kitsuyui merged 1 commit into
mainfrom
fix/audit-directory-layout-audit-003

Conversation

@kitsuyui

Copy link
Copy Markdown
Member

Why

scripts/ is this repo's home for operational/support scripts, but its only unit test file, scripts/check-readme-sync.test.ts, also directly exercised src/readme-html-sanitizer.ts (the runtime module that sanitizes the rendered README HTML), not just the readme-sync script it is named after. package.json's test:unit was pinned to that single file, so the sanitizer's tests had no tree-visible location of their own. A contributor changing src/readme-html-sanitizer.ts could not infer from the directory layout where its test lived, widening the search on every sanitizer change.

What changed

  • Moved the sanitizer test cases out of scripts/check-readme-sync.test.ts into a new src/readme-html-sanitizer.test.ts, co-located with the module they test.
  • The new file imports sanitizeReadmeHtmlTree from ./readme-html-sanitizer and the upstream repo constants directly from ./upstream-readme-source, instead of going through the scripts/check-readme-sync.ts re-export.
  • scripts/check-readme-sync.test.ts now only covers checkReadmeSync (the readme-sync script itself).
  • Updated test:unit in package.json to run both test files explicitly.

No behavior changes: the same 17 test cases still run, unchanged.

Verification

  • bun test scripts/check-readme-sync.test.ts src/readme-html-sanitizer.test.ts -- 17 pass, 0 fail.
  • biome check . -- passes (only a pre-existing, unrelated config deprecation notice).

Finding: audit-directory-layout-audit-003.

scripts/check-readme-sync.test.ts is the only unit test file and it
exercised src/readme-html-sanitizer.ts alongside the readme-sync
script it is named after. Contributors changing the sanitizer had no
tree-visible signal that its test lived under scripts/ instead of
next to the module, widening the search when a src/ change needed a
matching test.

Split the sanitizer test cases into src/readme-html-sanitizer.test.ts,
importing directly from src/upstream-readme-source.ts instead of
through the scripts/ re-export, and keep
scripts/check-readme-sync.test.ts scoped to the readme-sync script.
Update test:unit to run both files explicitly.
@github-actions

Copy link
Copy Markdown

Code Metrics Report

main (6219157) #983 (5cb1eed) +/-
Coverage 91.2% 91.2% 0.0%
Code to Test Ratio 1:0.9 1:0.3 -0.6
Test Execution Time 13s 18s +5s
Details
  |                     | main (6219157) | #983 (5cb1eed) | +/-  |
  |---------------------|----------------|----------------|------|
  | Coverage            |          91.2% |          91.2% | 0.0% |
  |   Files             |              3 |              3 |    0 |
  |   Lines             |            114 |            114 |    0 |
  |   Covered           |            104 |            104 |    0 |
- | Code to Test Ratio  |          1:0.9 |          1:0.3 | -0.6 |
  |   Code              |            306 |            793 | +487 |
  |   Test              |            288 |            288 |    0 |
- | Test Execution Time |            13s |            18s |  +5s |

Reported by octocov

@kitsuyui
kitsuyui merged commit 35926e2 into main Sep 14, 2026
5 checks passed
@kitsuyui
kitsuyui deleted the fix/audit-directory-layout-audit-003 branch September 14, 2026 16:59
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.

1 participant