Avoid triggering refreshStatic unless there really is a banner to display. (#14328)

This commit is contained in:
Jacob Richman
2025-12-03 09:08:32 -08:00
committed by GitHub
parent 1c12da1fad
commit 08067acc71
2 changed files with 58 additions and 7 deletions

View File

@@ -73,6 +73,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
disableMouseEvents: vi.fn(),
};
});
import ansiEscapes from 'ansi-escapes';
import type { LoadedSettings } from '../config/settings.js';
import type { InitializationResult } from '../core/initializer.js';
import { useQuotaAndFallback } from './hooks/useQuotaAndFallback.js';
@@ -1915,4 +1916,35 @@ describe('AppContainer State Management', () => {
unmount();
});
});
describe('Regression Tests', () => {
it('does not refresh static on startup if banner text is empty', async () => {
// Mock banner text to be empty strings
vi.spyOn(mockConfig, 'getBannerTextNoCapacityIssues').mockResolvedValue(
'',
);
vi.spyOn(mockConfig, 'getBannerTextCapacityIssues').mockResolvedValue('');
// Clear previous calls
mocks.mockStdout.write.mockClear();
const { unmount } = renderAppContainer();
// Allow async effects to run
await waitFor(() => expect(capturedUIState).toBeTruthy());
// Wait for fetchBannerTexts to complete
await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 100));
});
// Check that clearTerminal was NOT written to stdout
const clearTerminalCalls = mocks.mockStdout.write.mock.calls.filter(
(call: unknown[]) => call[0] === ansiEscapes.clearTerminal,
);
expect(clearTerminalCalls).toHaveLength(0);
unmount();
});
});
});