Skip to content

fix(test): normalise fs mock paths so they match on Windows - #1262

Open
anhtahaylove wants to merge 1 commit into
rohitg00:mainfrom
anhtahaylove:fix/windows-test-path-normalisation
Open

fix(test): normalise fs mock paths so they match on Windows#1262
anhtahaylove wants to merge 1 commit into
rohitg00:mainfrom
anhtahaylove:fix/windows-test-path-normalisation

Conversation

@anhtahaylove

@anhtahaylove anhtahaylove commented Aug 27, 2026

Copy link
Copy Markdown

test/compress-file.test.ts and test/obsidian-export.test.ts fail on Windows — 13 tests between them — because their in-memory node:fs/promises mocks are keyed on the raw path string while the functions under test resolve the path first.

Cause

resolve("/tmp/notes.md")   // Linux:   /tmp/notes.md
                           // Windows: C:\tmp\notes.md

compress-file calls resolve(data.filePath) before its first lstat. The mock's fileStore has /tmp/notes.md, the lookup asks for C:\tmp\notes.md, lstat throws ENOENT, and the function returns file not found — for a fixture the test wrote two lines earlier. obsidian-export has the same mismatch through join().

That is why the failures read like unrelated assertion noise (expected 'file not found' to contain 'symlink', expected undefined to be defined) rather than a path problem.

Fix

A small key() normaliser applied where paths enter the mock maps, plus three assertions that compare a returned path or error message against a POSIX literal. No production code changes.

Verification

Windows, clean checkout of main:

compress-file    before: 5 failed | 2 passed (7)     after: 7 passed (7)
obsidian-export  before: 8 failed | 8 passed (16)    after: 16 passed (16)

full suite       before: 30 failed | 1682 passed     after: 17 failed | 1695 passed

Linux is unaffected: key() is an identity transform on paths that are already POSIX.

The remaining 17 are separate Windows issues (process spawning, file locking, cli-lifecycle-safety fixtures) — happy to look at those in follow-ups if useful.

Summary by CodeRabbit

  • Tests
    • Improved cross-platform test coverage for file compression and export workflows.
    • Added consistent path handling across Windows and POSIX-style environments.
    • Strengthened verification of backup paths, generated files and directories, and export-related error messages.
    • Reduced false failures caused by differences in path separators and drive-letter formatting.

Both suites key their in-memory fs mocks on the raw path string, but the
functions under test call resolve()/join() first. On Windows that turns
"/tmp/notes.md" into "C:\tmp\notes.md", so every lookup misses: lstat
threw ENOENT and compress-file reported "file not found" for fixtures
the test had just written.

Normalises keys on the way into the mocks and on the three assertions
that compare a returned path or error message against a POSIX literal.

13 of the 30 Windows baseline failures come from this; suite goes from
30 failed to 17.

Signed-off-by: anhtahaylove <everest.kill1@gmail.com>
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@anhtahaylove is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bf3ee8a-4a68-43e5-ac1e-38504c0d39d2

📥 Commits

Reviewing files that changed from the base of the PR and between e04ba88 and 4d08878.

📒 Files selected for processing (2)
  • test/compress-file.test.ts
  • test/obsidian-export.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Test path normalization

Layer / File(s) Summary
Compress-file path handling
test/compress-file.test.ts
The test filesystem mocks and backup-path assertions normalize backslashes and drive prefixes before lookup and comparison.
Obsidian export path handling
test/obsidian-export.test.ts
The test filesystem mocks and vault path assertion normalize Windows paths before recording or comparing them.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 4d088

This is a localized test-only change that normalizes mocked filesystem paths for Windows and reports the affected tests passing; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: rohitg00

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: normalizing filesystem mock paths in tests to fix Windows failures.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@anhtahaylove

Copy link
Copy Markdown
Author

Context for this one: #1264 audits the whole Windows test picture — 30 failures, what causes each group, and which PR covers it.

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