Skip to content

fix: cross-platform path separators in progressManager tests#79

Merged
acrosman merged 2 commits intofix-build-processfrom
copilot/fix-progress-manager-tests
Apr 24, 2026
Merged

fix: cross-platform path separators in progressManager tests#79
acrosman merged 2 commits intofix-build-processfrom
copilot/fix-progress-manager-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

Tests in progressManager.test.js hardcoded Unix-style paths in assertions, causing failures on Windows where path.join produces backslash-separated paths.

Changes

  • progressManager.test.js: Import Node's path module and replace all hardcoded path string literals in assertions with path.join(...) calls, so expected values match the OS-native separator at runtime.
// Before — fails on Windows
expect(mockWriteFile).toHaveBeenCalledWith(
  '/mock/userData/player1.json.tmp', ...

// After — works on any OS
expect(mockWriteFile).toHaveBeenCalledWith(
  path.join('/mock/userData', 'player1.json.tmp'), ...

Affected assertions: writeFile, rename, unlink, and the log.info stringContaining check.

Original prompt

When running ProcressManager tests are run on Windows they fail:

Summary of all failing tests
FAIL app/progress/progressManager.test.js
  ● saveProgress › writes to .tmp path then renames to final path

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: "/mock/userData/player1.json.tmp", Any<String>, "utf8"
    Received: "\\mock\\userData\\player1.json.tmp", "{
      \"playerId\": \"player1\",
      \"games\": {},
      \"lastUpdated\": \"2026-04-23T23:19:59.525Z\"
    }", "utf8"

    Number of calls: 1

      92 |     await saveProgress('player1', { playerId: 'player1', games: {} });
      93 |
    > 94 |     expect(mockWriteFile).toHaveBeenCalledWith(
         |                           ^
      95 |       '/mock/userData/player1.json.tmp',
      96 |       expect.any(String),
      97 |       'utf8',

      at Object.<anonymous> (app/progress/progressManager.test.js:94:27)

  ● saveProgress › logs an info message including the saved file path

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: StringContaining "/mock/userData/player1.json"
    Received: "Progress saved for player \"player1\": \\mock\\userData\\player1.json"

    Number of calls: 1

      116 |     await saveProgress('player1', { playerId: 'player1', games: {} });
      117 |
    > 118 |     expect(mockLogInfo).toHaveBeenCalledWith(
          |                         ^
      119 |       expect.stringContaining('/mock/userData/player1.json'),
      120 |     );
      121 |   });

      at Object.<anonymous> (app/progress/progressManager.test.js:118:25)

  ● resetProgress › calls unlink on the player file

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: "/mock/userData/player1.json"
    Received: "\\mock\\userData\\player1.json"

    Number of calls: 1

      128 |     await resetProgress('player1');
      129 |
    > 130 |     expect(mockUnlink).toHaveBeenCalledWith('/mock/userData/player1.json');
          |                        ^
      131 |   });
      132 |
      133 |   test('resolves silently when file is missing (ENOENT)', async () => {

      at Object.<anonymous> (app/progress/progressManager.test.js:130:24)

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md

Created from VS Code.

Copilot AI changed the title [WIP] Fix progress manager tests for Windows compatibility fix: cross-platform path separators in progressManager tests Apr 23, 2026
Copilot AI requested a review from acrosman April 23, 2026 23:27
@acrosman acrosman changed the base branch from main to fix-build-process April 24, 2026 00:32
@acrosman acrosman marked this pull request as ready for review April 24, 2026 00:32
@acrosman acrosman merged commit a4b44e8 into fix-build-process Apr 24, 2026
6 checks passed
@acrosman acrosman deleted the copilot/fix-progress-manager-tests branch April 24, 2026 00:34
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