Skip to content

test: make auto-run-command and attachments tests OS-agnostic#46

Merged
chr1syy merged 1 commit into
RunMaestro:mainfrom
jSydorowicz21:fix/windows-path-test-failures
Jun 7, 2026
Merged

test: make auto-run-command and attachments tests OS-agnostic#46
chr1syy merged 1 commit into
RunMaestro:mainfrom
jSydorowicz21:fix/windows-path-test-failures

Conversation

@jSydorowicz21

@jSydorowicz21 jSydorowicz21 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

@

Summary

Fixes 4 test failures that occur on Windows due to POSIX-only path assumptions in the test suite. No production code changes - tests only.

  • attachments.test.ts: normalize the expected DEFAULT_FILES_SUBDIR substring to the platform separator (path.sep) before the containment check.
  • auto-run-command.test.ts: build mock folders and fixtures with path.join / os.tmpdir() instead of hardcoded /agents/... literals, so absolute/relative/traversal cases resolve consistently on every OS.

Merge order

Merge this first. The other two open PRs (fix/typed-bridge-errors, chore/logger-consolidation) still show these same 4 pre-existing failures on Windows; landing this branch makes the suite fully green for all three.

Test plan

  • npm test -> 211 pass / 0 fail on Windows 11
  • Build clean (tsc)
  • Boundary and path-traversal test cases preserved (not weakened)
    @

Summary by CodeRabbit

  • Tests
    • Enhanced test reliability across different operating systems by standardizing path handling in file attachment and auto-run command tests.

Four tests in the suite failed on Windows but passed on Linux/macOS,
encoding platform assumptions in the test data and assertions:

- src/__tests__/auto-run-command.test.ts:77, 104, 131 — three tests
  mocked autoRunFolderPath as '/agents/auto-run-docs' and asserted
  the result of path.join(folder, doc). On Linux that yields
  '/agents/auto-run-docs/plan.md'; on Windows, path.isAbsolute('/...')
  is true so the resolved path is 'C:\\\\agents\\\\auto-run-docs\\\\...',
  and path.join without resolve produces '\\\\agents\\\\...' (no
  drive). Production calls path.resolve first, so the test's
  expected value drifted from the actual on Windows.

- src/__tests__/attachments.test.ts:80 — checked
  savedPath.includes(DEFAULT_FILES_SUBDIR) where the constant is the
  forward-slash literal '.maestro/discord-files'. path.join on
  Windows produces backslashes, so the substring never matches.

Fixes:

- Replace the mocked folder with a constant built from path.join,
  giving a relative path that path.isAbsolute returns false for on
  every platform. The absolute-path test inputs are built with
  path.resolve against the same relative folder so they round-trip
  identically.

- Compute expected docs values via resolveContainedDocPath, the same
  OS-agnostic helper production uses, so the assertion is exact
  regardless of how path.resolve normalizes the CWD prefix.

- The /etc/passwd test now uses path.resolve(os.tmpdir(), 'evil.txt')
  for a portable 'guaranteed outside the folder' absolute path.

- For the DEFAULT_FILES_SUBDIR assertion, normalize the constant to
  path.sep before the .includes() check.

Verified on Windows: 211 pass, 0 fail (was 207/4 on main). Production
code untouched.
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

PR changed again? Review this PR in Change Stack to compare snapshots and stay oriented.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8243e1a4-ce83-4346-be13-35791054244e

📥 Commits

Reviewing files that changed from the base of the PR and between 86aa703 and 486a10b.

📒 Files selected for processing (2)
  • src/__tests__/attachments.test.ts
  • src/__tests__/auto-run-command.test.ts

📝 Walkthrough

Walkthrough

This PR removes platform-specific path handling from two test files. The attachment test now normalizes path separators before assertions. The auto-run command tests replace hardcoded absolute paths with a mock folder constant and use production path-resolution helpers, ensuring consistent behavior across Windows and Unix-like systems.

Changes

Cross-Platform Test Path Handling

Layer / File(s) Summary
Attachment download path normalization
src/__tests__/attachments.test.ts
Assertion for downloaded[0].savedPath normalizes DEFAULT_FILES_SUBDIR to the platform's path separator before substring matching, removing Windows-specific failures.
Auto-run mock folder path constant
src/__tests__/auto-run-command.test.ts
Introduces MOCK_AUTO_RUN_FOLDER relative path constant with notes on Windows absolute-path pitfalls, replacing hardcoded /agents/auto-run-docs throughout mocks.
Auto-run test cases with OS-agnostic paths
src/__tests__/auto-run-command.test.ts
Test setups and assertions updated to use the mock folder constant and resolveContainedDocPath helper; absolute paths now constructed via path.resolve or os.tmpdir() for portability across bare filenames, relative subpaths, absolute path containment, and error scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Across Windows and Unix we hop with delight,
Paths separated just right, no more Windows vs. Unix fight!
Mock folders guide the way, helpers resolve the day,
Tests portable and bright, now they'll pass every night! 🌙

🚥 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 directly and accurately describes the main change: making two test files (auto-run-command and attachments) OS-agnostic to fix Windows path failures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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 and usage tips.

@chr1syy chr1syy merged commit e83cd4d into RunMaestro:main Jun 7, 2026
3 checks passed
chr1syy added a commit that referenced this pull request Jun 7, 2026
Bundles four merged PRs since v0.2.0:

- #46 OS-agnostic auto-run + attachments tests (Windows CI fix)
- #47 typed bridge errors + `Retry-After` header on 429
- #48 leveled logger consolidation + `LOG_LEVEL` env var
- #49 wallclock ISO timestamps on console output (macOS launchd gap)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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