|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2026 Google LLC |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +import { describe, it, expect } from 'vitest'; |
| 8 | +import { deriveItemsFromLegacySettings } from './footerItems.js'; |
| 9 | +import { createMockSettings } from '../test-utils/settings.js'; |
| 10 | + |
| 11 | +describe('deriveItemsFromLegacySettings', () => { |
| 12 | + it('returns defaults when no legacy settings are customized', () => { |
| 13 | + const settings = createMockSettings({ |
| 14 | + ui: { footer: { hideContextPercentage: true } }, |
| 15 | + }).merged; |
| 16 | + const items = deriveItemsFromLegacySettings(settings); |
| 17 | + expect(items).toEqual([ |
| 18 | + 'workspace', |
| 19 | + 'git-branch', |
| 20 | + 'sandbox', |
| 21 | + 'model-name', |
| 22 | + 'quota', |
| 23 | + ]); |
| 24 | + }); |
| 25 | + |
| 26 | + it('removes workspace when hideCWD is true', () => { |
| 27 | + const settings = createMockSettings({ |
| 28 | + ui: { footer: { hideCWD: true, hideContextPercentage: true } }, |
| 29 | + }).merged; |
| 30 | + const items = deriveItemsFromLegacySettings(settings); |
| 31 | + expect(items).not.toContain('workspace'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('removes sandbox when hideSandboxStatus is true', () => { |
| 35 | + const settings = createMockSettings({ |
| 36 | + ui: { footer: { hideSandboxStatus: true, hideContextPercentage: true } }, |
| 37 | + }).merged; |
| 38 | + const items = deriveItemsFromLegacySettings(settings); |
| 39 | + expect(items).not.toContain('sandbox'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('removes model-name, context-used, and quota when hideModelInfo is true', () => { |
| 43 | + const settings = createMockSettings({ |
| 44 | + ui: { footer: { hideModelInfo: true, hideContextPercentage: true } }, |
| 45 | + }).merged; |
| 46 | + const items = deriveItemsFromLegacySettings(settings); |
| 47 | + expect(items).not.toContain('model-name'); |
| 48 | + expect(items).not.toContain('context-used'); |
| 49 | + expect(items).not.toContain('quota'); |
| 50 | + }); |
| 51 | + |
| 52 | + it('includes context-used when hideContextPercentage is false', () => { |
| 53 | + const settings = createMockSettings({ |
| 54 | + ui: { footer: { hideContextPercentage: false } }, |
| 55 | + }).merged; |
| 56 | + const items = deriveItemsFromLegacySettings(settings); |
| 57 | + expect(items).toContain('context-used'); |
| 58 | + // Should be after model-name |
| 59 | + const modelIdx = items.indexOf('model-name'); |
| 60 | + const contextIdx = items.indexOf('context-used'); |
| 61 | + expect(contextIdx).toBe(modelIdx + 1); |
| 62 | + }); |
| 63 | + |
| 64 | + it('includes memory-usage when showMemoryUsage is true', () => { |
| 65 | + const settings = createMockSettings({ |
| 66 | + ui: { showMemoryUsage: true, footer: { hideContextPercentage: true } }, |
| 67 | + }).merged; |
| 68 | + const items = deriveItemsFromLegacySettings(settings); |
| 69 | + expect(items).toContain('memory-usage'); |
| 70 | + }); |
| 71 | + |
| 72 | + it('handles combination of settings', () => { |
| 73 | + const settings = createMockSettings({ |
| 74 | + ui: { |
| 75 | + showMemoryUsage: true, |
| 76 | + footer: { |
| 77 | + hideCWD: true, |
| 78 | + hideModelInfo: true, |
| 79 | + hideContextPercentage: false, |
| 80 | + }, |
| 81 | + }, |
| 82 | + }).merged; |
| 83 | + const items = deriveItemsFromLegacySettings(settings); |
| 84 | + expect(items).toEqual([ |
| 85 | + 'git-branch', |
| 86 | + 'sandbox', |
| 87 | + 'context-used', |
| 88 | + 'memory-usage', |
| 89 | + ]); |
| 90 | + }); |
| 91 | +}); |
0 commit comments