test(core): fix env var leakage in compatibility tests

Clears environment variables like TERMINAL_EMULATOR, JETBRAINS_IDE, TMUX, STY, TERM, and TERM_PROGRAM before running compatibility tests to prevent local developer environments from causing false positives.

refactor(core): standardize warning prefixes

Replaces hardcoded warning emojis with the standard 'Warning:' prefix for consistency with existing warnings.
This commit is contained in:
Spencer
2026-03-12 20:34:26 +00:00
parent a29db295ec
commit bd530829a2
2 changed files with 18 additions and 5 deletions
@@ -94,6 +94,8 @@ describe('compatibility', () => {
},
{ env: {}, expected: false, desc: 'no env vars set' },
])('should return $expected when $desc', ({ env, expected }) => {
vi.stubEnv('TERMINAL_EMULATOR', '');
vi.stubEnv('JETBRAINS_IDE', '');
for (const [key, value] of Object.entries(env)) {
vi.stubEnv(key, value);
}
@@ -140,6 +142,7 @@ describe('compatibility', () => {
it('should return false when TERM=xterm-256color', () => {
vi.stubEnv('TERM', 'xterm-256color');
vi.stubEnv('COLORTERM', '');
expect(isLowColorTmux()).toBe(false);
});
});
@@ -230,6 +233,8 @@ describe('compatibility', () => {
process.stdout.getColorDepth = vi.fn().mockReturnValue(depth);
if (term !== undefined) {
vi.stubEnv('TERM', term);
} else {
vi.stubEnv('TERM', '');
}
expect(supports256Colors()).toBe(expected);
});
@@ -278,6 +283,14 @@ describe('compatibility', () => {
describe('getCompatibilityWarnings', () => {
beforeEach(() => {
// Clear out potential local environment variables that might trigger warnings
vi.stubEnv('TERMINAL_EMULATOR', '');
vi.stubEnv('JETBRAINS_IDE', '');
vi.stubEnv('TMUX', '');
vi.stubEnv('STY', '');
vi.stubEnv('TERM', 'xterm-256color'); // Prevent dumb terminal warning
vi.stubEnv('TERM_PROGRAM', '');
// Default to supporting true color to keep existing tests simple
vi.stubEnv('COLORTERM', 'truecolor');
process.stdout.getColorDepth = vi.fn().mockReturnValue(24);
+5 -5
View File
@@ -160,7 +160,7 @@ export function getCompatibilityWarnings(options?: {
warnings.push({
id: 'jetbrains-terminal',
message:
'⚠️ JetBrains terminal detected — alternate buffer mode may cause scroll wheel issues and rendering artifacts. If you experience problems, disable it in /settings → "Use Alternate Screen Buffer".',
'Warning: JetBrains terminal detected — alternate buffer mode may cause scroll wheel issues and rendering artifacts. If you experience problems, disable it in /settings → "Use Alternate Screen Buffer".',
priority: WarningPriority.High,
});
}
@@ -169,7 +169,7 @@ export function getCompatibilityWarnings(options?: {
warnings.push({
id: 'tmux-alternate-buffer',
message:
'⚠️ tmux detected — alternate buffer mode may cause unexpected scrollback loss and flickering. If you experience issues, disable it in /settings → "Use Alternate Screen Buffer".\n Tip: Use Ctrl-b [ to access tmux copy mode for scrolling history.',
'Warning: tmux detected — alternate buffer mode may cause unexpected scrollback loss and flickering. If you experience issues, disable it in /settings → "Use Alternate Screen Buffer".\n Tip: Use Ctrl-b [ to access tmux copy mode for scrolling history.',
priority: WarningPriority.High,
});
}
@@ -178,7 +178,7 @@ export function getCompatibilityWarnings(options?: {
warnings.push({
id: 'low-color-tmux',
message:
'⚠️ Limited color support detected (TERM=screen). Some visual elements may not render correctly. For better color support in tmux, add to ~/.tmux.conf:\n set -g default-terminal "tmux-256color"\n set -ga terminal-overrides ",*256col*:Tc"',
'Warning: Limited color support detected (TERM=screen). Some visual elements may not render correctly. For better color support in tmux, add to ~/.tmux.conf:\n set -g default-terminal "tmux-256color"\n set -ga terminal-overrides ",*256col*:Tc"',
priority: WarningPriority.High,
});
}
@@ -187,7 +187,7 @@ export function getCompatibilityWarnings(options?: {
warnings.push({
id: 'gnu-screen',
message:
'⚠️ GNU screen detected. Some keyboard shortcuts and visual features may behave unexpectedly. For the best experience, consider using tmux or running Gemini CLI directly in your terminal.',
'Warning: GNU screen detected. Some keyboard shortcuts and visual features may behave unexpectedly. For the best experience, consider using tmux or running Gemini CLI directly in your terminal.',
priority: WarningPriority.Low,
});
}
@@ -196,7 +196,7 @@ export function getCompatibilityWarnings(options?: {
warnings.push({
id: 'dumb-terminal',
message:
'⚠️ Basic terminal detected (TERM=dumb). Visual rendering will be limited. For the best experience, use a terminal emulator with truecolor support.',
'Warning: Basic terminal detected (TERM=dumb). Visual rendering will be limited. For the best experience, use a terminal emulator with truecolor support.',
priority: WarningPriority.High,
});
}