File size: 2,333 Bytes
9332ccf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { renderWithProviders } from '../../test-utils/render.js';
import { AboutBox } from './AboutBox.js';
import { describe, it, expect, vi } from 'vitest';
// Mock GIT_COMMIT_INFO
vi.mock('../../generated/git-commit.js', () => ({
GIT_COMMIT_INFO: 'mock-commit-hash',
}));
describe('AboutBox', () => {
const defaultProps = {
cliVersion: '1.0.0',
osVersion: 'macOS',
sandboxEnv: 'default',
modelVersion: 'gemini-pro',
selectedAuthType: 'oauth',
gcpProject: '',
ideClient: '',
};
it('renders with required props', async () => {
const { lastFrame, unmount } = await renderWithProviders(
<AboutBox {...defaultProps} />,
);
const output = lastFrame();
expect(output).toContain('About Gemini CLI');
expect(output).toContain('1.0.0');
expect(output).toContain('mock-commit-hash');
expect(output).toContain('gemini-pro');
expect(output).toContain('default');
expect(output).toContain('macOS');
expect(output).toContain('Signed in with Google');
unmount();
});
it.each([
['gcpProject', 'my-project', 'GCP Project'],
['ideClient', 'vscode', 'IDE Client'],
['tier', 'Enterprise', 'Tier'],
])('renders optional prop %s', async (prop, value, label) => {
const props = { ...defaultProps, [prop]: value };
const { lastFrame, unmount } = await renderWithProviders(
<AboutBox {...props} />,
);
const output = lastFrame();
expect(output).toContain(label);
expect(output).toContain(value);
unmount();
});
it('renders Auth Method with email when userEmail is provided', async () => {
const props = { ...defaultProps, userEmail: 'test@example.com' };
const { lastFrame, unmount } = await renderWithProviders(
<AboutBox {...props} />,
);
const output = lastFrame();
expect(output).toContain('Signed in with Google (test@example.com)');
unmount();
});
it('renders Auth Method correctly when not oauth', async () => {
const props = { ...defaultProps, selectedAuthType: 'api-key' };
const { lastFrame, unmount } = await renderWithProviders(
<AboutBox {...props} />,
);
const output = lastFrame();
expect(output).toContain('api-key');
unmount();
});
});
|