#2551
test: isolate detect-agent tests from ambient agent env; accept ASCII bar in notion test
Summary
Fixes 4 test failures that show up depending on where the suite is run. No production code changes.
src/detect-agent.test.ts: the tests stubbed only the Cursor env vars, so when the suite runs inside another AI agent (Claude Code setsAI_AGENT/CLAUDECODE, Codex setsCODEX_*, etc.)@vercel/detect-agentpicks up that agent instead. 3 tests failed, e.g.expected 'claude-code_..._agent' to be 'cursor-cli'. Now every env var@vercel/detect-agentreads is cleared inbeforeEach.src/add.test.ts(notion test):@clack/promptsfalls back to an ASCII|bar instead of│when Unicode isn't detected (e.g.TERM=linux). The test only stripped│, so it failed. It now accepts either.
Testing
pnpm vitest run: 978/978 pass (it was 974/978 inside an agent session withTERM=linux)pnpm type-checkand Prettier pass
Activity
2Muguett-DBYreviewed20d ago
I hit the same Notion assertion while testing #2518 on Windows, so I checked this at
77f9997with Node 24.22.1.With
AI_AGENT=claude-code,CLAUDECODE=1andTERM=linux, the parent versions of these two test files reproduce all four failures: three agent-detection assertions and the ASCII|prefix. Restoring this patch makes all four pass; running both complete files then passes all 69 tests.I also checked the installed
@vercel/detect-agentimplementation: all 18 environment variables it reads are covered by the reset list. This resolves the Windows test failure I ran into. My validation here is limited to these two test files.