Skip to content

fix(tests): isolate session-store specs from shared on-disk file#239

Merged
luokerenx4 merged 1 commit into
masterfrom
claude/charming-feynman-ofQTv
Jun 1, 2026
Merged

fix(tests): isolate session-store specs from shared on-disk file#239
luokerenx4 merged 1 commit into
masterfrom
claude/charming-feynman-ofQTv

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

  • session-store.spec.ts and auth.spec.ts both read/write the real data/config/sessions.json and share session-store.ts's module-level cache. Under Vitest's default parallel file execution they race — session-store's beforeEach deletes the file while auth's createSession() / revokeAllSessions() write it. Result: intermittent failures like revokeAllSessions wipes everything (expects 3, gets 4) or persists across cache reset returning null, only on multi-core / loaded machines. It also clobbered the operator's real login sessions.
  • Added a lazily-read OPENALICE_SESSIONS_FILE seam to session-store.ts (same spirit as the existing _reset / _unlinkFile test seams; unset in production → zero behavior change) and pointed each spec at its own mkdtemp file. The two files no longer share state and never touch the real sessions.json.

Test plan

  • npx tsc --noEmit clean
  • the two previously-colliding specs run 3× in a row, all green
  • pnpm test passes (90 files / 1701 tests)
  • real data/config/sessions.json left untouched after the run (confirms tests no longer write it)

Boundary touch

Touches src/services/auth/ (auth/session store) and its tests — no change to runtime auth behavior; the new env var is a test-only seam that production never sets.

🤖 Generated with Claude Code


Generated by Claude Code

session-store.spec.ts and auth.spec.ts both read/write the real
data/config/sessions.json and share the module-level cache. Under
Vitest's default parallel file execution they race: session-store's
beforeEach deletes the file while auth's createSession()/revokeAllSessions()
write it, so e.g. "revokeAllSessions wipes everything" (expects 3) or
"persists across cache reset" can intermittently fail on multi-core /
loaded machines. It also clobbered the operator's real login sessions.

Add a lazily-read OPENALICE_SESSIONS_FILE seam to session-store.ts
(same spirit as the existing _reset/_unlinkFile test seams; unset in
production) and point each spec at its own mkdtemp file. The two files
no longer share state and never touch the real sessions.json.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openalice-demo Ready Ready Preview, Comment Jun 1, 2026 3:47am

Request Review

@luokerenx4 luokerenx4 merged commit fa44d8a into master Jun 1, 2026
3 checks passed
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