2026-02-13 07:04:28 -05:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2026 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, it, expect } from 'vitest';
|
2026-02-13 09:21:48 -05:00
|
|
|
import { deriveItemsFromLegacySettings } from './footerItems.js';
|
|
|
|
|
import { createMockSettings } from '../test-utils/settings.js';
|
2026-02-13 07:04:28 -05:00
|
|
|
|
|
|
|
|
describe('deriveItemsFromLegacySettings', () => {
|
|
|
|
|
it('returns defaults when no legacy settings are customized', () => {
|
|
|
|
|
const settings = createMockSettings({
|
|
|
|
|
ui: { footer: { hideContextPercentage: true } },
|
|
|
|
|
}).merged;
|
|
|
|
|
const items = deriveItemsFromLegacySettings(settings);
|
|
|
|
|
expect(items).toEqual([
|
|
|
|
|
'cwd',
|
|
|
|
|
'git-branch',
|
|
|
|
|
'sandbox-status',
|
|
|
|
|
'model-name',
|
2026-02-16 18:07:54 -05:00
|
|
|
'usage-limit',
|
2026-02-13 07:04:28 -05:00
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('removes cwd when hideCWD is true', () => {
|
|
|
|
|
const settings = createMockSettings({
|
|
|
|
|
ui: { footer: { hideCWD: true, hideContextPercentage: true } },
|
|
|
|
|
}).merged;
|
|
|
|
|
const items = deriveItemsFromLegacySettings(settings);
|
|
|
|
|
expect(items).not.toContain('cwd');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('removes sandbox-status when hideSandboxStatus is true', () => {
|
|
|
|
|
const settings = createMockSettings({
|
|
|
|
|
ui: { footer: { hideSandboxStatus: true, hideContextPercentage: true } },
|
|
|
|
|
}).merged;
|
|
|
|
|
const items = deriveItemsFromLegacySettings(settings);
|
|
|
|
|
expect(items).not.toContain('sandbox-status');
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-16 18:07:54 -05:00
|
|
|
it('removes model-name, context-remaining, and usage-limit when hideModelInfo is true', () => {
|
2026-02-13 07:04:28 -05:00
|
|
|
const settings = createMockSettings({
|
|
|
|
|
ui: { footer: { hideModelInfo: true, hideContextPercentage: true } },
|
|
|
|
|
}).merged;
|
|
|
|
|
const items = deriveItemsFromLegacySettings(settings);
|
|
|
|
|
expect(items).not.toContain('model-name');
|
|
|
|
|
expect(items).not.toContain('context-remaining');
|
2026-02-16 18:07:54 -05:00
|
|
|
expect(items).not.toContain('usage-limit');
|
2026-02-13 07:04:28 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('includes context-remaining when hideContextPercentage is false', () => {
|
|
|
|
|
const settings = createMockSettings({
|
|
|
|
|
ui: { footer: { hideContextPercentage: false } },
|
|
|
|
|
}).merged;
|
|
|
|
|
const items = deriveItemsFromLegacySettings(settings);
|
|
|
|
|
expect(items).toContain('context-remaining');
|
|
|
|
|
// Should be after model-name
|
|
|
|
|
const modelIdx = items.indexOf('model-name');
|
|
|
|
|
const contextIdx = items.indexOf('context-remaining');
|
|
|
|
|
expect(contextIdx).toBe(modelIdx + 1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('includes memory-usage when showMemoryUsage is true', () => {
|
|
|
|
|
const settings = createMockSettings({
|
|
|
|
|
ui: { showMemoryUsage: true, footer: { hideContextPercentage: true } },
|
|
|
|
|
}).merged;
|
|
|
|
|
const items = deriveItemsFromLegacySettings(settings);
|
|
|
|
|
expect(items).toContain('memory-usage');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('handles combination of settings', () => {
|
|
|
|
|
const settings = createMockSettings({
|
|
|
|
|
ui: {
|
|
|
|
|
showMemoryUsage: true,
|
|
|
|
|
footer: {
|
|
|
|
|
hideCWD: true,
|
|
|
|
|
hideModelInfo: true,
|
|
|
|
|
hideContextPercentage: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}).merged;
|
|
|
|
|
const items = deriveItemsFromLegacySettings(settings);
|
|
|
|
|
expect(items).toEqual([
|
|
|
|
|
'git-branch',
|
|
|
|
|
'sandbox-status',
|
|
|
|
|
'context-remaining',
|
|
|
|
|
'memory-usage',
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
});
|