test(cli): fix cross-platform footer test alignment and path normalization

This commit is contained in:
Jack Wotherspoon
2026-02-26 09:01:34 -05:00
committed by Keith Guerin
parent 0292a20d41
commit 32e01f723a
2 changed files with 25 additions and 14 deletions

View File

@@ -11,10 +11,9 @@ import { createMockSettings } from '../../test-utils/settings.js';
import path from 'node:path';
// Normalize paths to POSIX slashes for stable cross-platform snapshots.
// We replace the Windows drive letter with spaces to preserve the rendered string length.
const normalizeFrame = (frame: string | undefined) => {
if (!frame) return frame;
return frame.replace(/\\/g, '/').replace(/[A-Za-z]:\//g, ' /');
return frame.replace(/\\/g, '/');
};
const mockSessionStats = {
@@ -73,6 +72,11 @@ const defaultProps = {
};
describe('<Footer />', () => {
beforeEach(() => {
const root = path.parse(process.cwd()).root;
vi.stubEnv('GEMINI_CLI_HOME', path.join(root, 'Users', 'test'));
});
it('renders the component', async () => {
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
<Footer />,

View File

@@ -1,38 +1,45 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`<Footer /> > displays "Limit reached" message when remaining is 0 1`] = `
" Path /docs /model /stats
/Users/test/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro limit reached"
" Path /docs /model /stats
~/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro limit reached
"
`;
exports[`<Footer /> > displays the usage indicator when usage is low 1`] = `
" Path /docs /model /stats
/Users/test/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro daily 15%"
" Path /docs /model /stats
~/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro daily 15%
"
`;
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders complete footer in narrow terminal (baseline narrow) > complete-footer-narrow 1`] = `
" Path /docs /model Context
/Users/.../directories/to/make/it/long no sandbox gemini-pro 100%"
~/.../more/directories/to/make/it/long no sandbox gemini-pro 86%
"
`;
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders complete footer with all sections visible (baseline) > complete-footer-wide 1`] = `
" Path /docs /model Context
/Users/test/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro 100% left"
" Path /docs /model Context
~/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro 86% left
"
`;
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders footer with CWD and model info hidden to test alignment (only sandbox visible) > footer-only-sandbox 1`] = `
" /docs
no sandbox"
no sandbox
"
`;
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders footer with all optional sections hidden (minimal footer) > footer-minimal 1`] = `""`;
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders footer with only model info hidden (partial filtering) > footer-no-model 1`] = `
" Path /docs
/Users/test/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox"
" Path /docs
~/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox
"
`;
exports[`<Footer /> > hides the usage indicator when usage is not near limit 1`] = `
" Path /docs /model /stats
/Users/test/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro daily 85%"
" Path /docs /model /stats
~/project/foo/bar/and/some/more/directories/to/make/it/long no sandbox gemini-pro daily 85%
"
`;