fix(tests): resolve 5 cross-file test isolation failures

- model-fallback hook: mock selectFallbackProvider and add _resetForTesting()
  to test-setup.ts to clear module-level state between files
- fallback-retry-handler: add afterAll(mock.restore) and use mockReturnValueOnce
  to prevent connected-providers mock leaking to subsequent test files
- opencode-config-dir: use win32.join for Windows APPDATA path construction
  so tests pass on macOS (path.join uses POSIX semantics regardless of
  process.platform override)
- system-loaded-version: use resolveSymlink from file-utils instead of
  realpathSync to handle macOS /var -> /private/var symlink consistently

All 4456 tests pass (0 failures) on full bun test suite.
This commit is contained in:
YeonGyu-Kim
2026-03-26 09:30:34 +09:00
parent 90919bf359
commit 7895361f42
8 changed files with 60 additions and 21 deletions
@@ -1,9 +1,10 @@
import { afterEach, describe, expect, it } from "bun:test"
import { mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs"
import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { dirname, join } from "node:path"
import { PACKAGE_NAME } from "../constants"
import { resolveSymlink } from "../../../shared/file-utils"
const systemLoadedVersionModulePath = "./system-loaded-version?system-loaded-version-test"
@@ -125,7 +126,7 @@ describe("system loaded version", () => {
const loadedVersion = getLoadedPluginVersion()
//#then
expect(loadedVersion.cacheDir).toBe(realpathSync(symlinkConfigDir))
expect(loadedVersion.cacheDir).toBe(resolveSymlink(symlinkConfigDir))
expect(loadedVersion.expectedVersion).toBe("4.5.6")
expect(loadedVersion.loadedVersion).toBe("4.5.6")
})
@@ -1,7 +1,7 @@
import { existsSync, readFileSync, realpathSync } from "node:fs"
import { existsSync, readFileSync } from "node:fs"
import { homedir } from "node:os"
import { join } from "node:path"
import { resolveSymlink } from "../../../shared/file-utils"
import { getLatestVersion } from "../../../hooks/auto-update-checker/checker"
import { extractChannel } from "../../../hooks/auto-update-checker"
import { PACKAGE_NAME } from "../constants"
@@ -38,12 +38,7 @@ function resolveOpenCodeCacheDir(): string {
function resolveExistingDir(dirPath: string): string {
if (!existsSync(dirPath)) return dirPath
try {
return realpathSync(dirPath)
} catch {
return dirPath
}
return resolveSymlink(dirPath)
}
function readPackageJson(filePath: string): PackageJsonShape | null {