Skip to content

fix: make logging spec path assertions cross-platform (Windows CI) - #3368

Merged
jeanfbrito merged 1 commit into
masterfrom
fix/logging-spec-windows-path
Jun 22, 2026
Merged

fix: make logging spec path assertions cross-platform (Windows CI)#3368
jeanfbrito merged 1 commit into
masterfrom
fix/logging-spec-windows-path

Conversation

@jeanfbrito

@jeanfbrito jeanfbrito commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

src/logging/main/index.main.spec.ts (added in #3365) fails on Windows CI while passing on Linux/macOS:

● logging/index › error jsonl hook › truncates the error log file when it exceeds the size limit
  Expected: "/logs/errors.jsonl"  Received: "\logs\errors.jsonl"
Tests: 2 failed (Windows only)

The spec hardcoded POSIX path literals (/logs/errors.jsonl) in assertions. The source builds paths with path.join(app.getPath('logs'), …), which emits \ separators on Windows — so the exact-string match failed. Violates the repo's cross-platform test requirement (CLAUDE.md).

Fix

Test-only. Derive expected paths with path.join from a shared LOGS_DIR constant so the test and source use the same primitive:

  • MAIN_LOG_PATH = path.join('/logs', 'main.log'), ERRORS_JSONL_PATH = path.join('/logs', 'errors.jsonl').
  • Fixed 4 hardcoded literals: two chmodSync asserts, the writeFileSync truncation assert, and an existsSync mock comparison (the last would have silently skipped the truncation branch on Windows, masking the assertion).
  • Source src/logging/index.ts unchanged — it was already correct.

Platform-correct by construction: both sides now produce \logs\errors.jsonl on Windows and /logs/errors.jsonl on POSIX.

Verify

npx jest src/logging/main/index.main.spec.ts → 35 pass. Lint clean.

Summary by CodeRabbit

  • Tests
    • Improved test infrastructure by standardizing logging path constants across test assertions and mocks.

The error-jsonl-hook tests hardcoded POSIX path literals
('/logs/errors.jsonl', '/logs/main.log') in assertions. The source
builds these paths with path.join(app.getPath('logs'), ...), which
emits backslash separators on Windows, so the literal-string matches
failed on Windows CI while passing on Linux/macOS.

Construct expected paths with path.join from a shared LOGS_DIR constant
so the separator matches the platform under test.
@jeanfbrito
jeanfbrito merged commit 41b0d7e into master Jun 22, 2026
8 of 9 checks passed
@jeanfbrito
jeanfbrito deleted the fix/logging-spec-windows-path branch June 22, 2026 17:44
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59086632-1548-4812-8e28-b4a6bc9ac95a

📥 Commits

Reviewing files that changed from the base of the PR and between 5db3a50 and b6cdb07.

📒 Files selected for processing (1)
  • src/logging/main/index.main.spec.ts

Walkthrough

The test file src/logging/main/index.main.spec.ts is updated to define shared path constants (LOGS_DIR, MAIN_LOG_PATH, ERRORS_JSONL_PATH) via path.join, then replace all hardcoded '/logs/...' strings in Electron app.getPath mocks, chmod assertions, and fs.existsSync/fs.writeFileSync expectations with those constants.

Changes

Log path constant refactor in test suite

Layer / File(s) Summary
Shared log path constants definition
src/logging/main/index.main.spec.ts
Introduces LOGS_DIR, MAIN_LOG_PATH, and ERRORS_JSONL_PATH computed with path.join at lines 10–21 for use throughout the test suite.
Mock and assertion sites updated to use constants
src/logging/main/index.main.spec.ts
Replaces hardcoded '/logs', '/logs/main.log', and '/logs/errors.jsonl' strings in app.getPath mock setups, chmod assertions, fs.existsSync predicate, and fs.writeFileSync expectation with the new constants.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

type: bug

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

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.

1 participant