summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/FolderTrustDialog.test.tsx
diff options
context:
space:
mode:
authorshrutip90 <[email protected]>2025-08-08 11:02:27 -0700
committerGitHub <[email protected]>2025-08-08 18:02:27 +0000
commit34b5dc7f289dc9af0a87d3a795e681d2415da3c9 (patch)
tree9f4b52a13c26a27ccd0eed28715362ee2ded0b65 /packages/cli/src/ui/components/FolderTrustDialog.test.tsx
parent3af4913ef3f00de71744de551a568aa713a3beec (diff)
Add FolderTrustDialog that shows on launch and enables folderTrust setting (#5815)
Diffstat (limited to 'packages/cli/src/ui/components/FolderTrustDialog.test.tsx')
-rw-r--r--packages/cli/src/ui/components/FolderTrustDialog.test.tsx29
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/cli/src/ui/components/FolderTrustDialog.test.tsx b/packages/cli/src/ui/components/FolderTrustDialog.test.tsx
new file mode 100644
index 00000000..01394d0f
--- /dev/null
+++ b/packages/cli/src/ui/components/FolderTrustDialog.test.tsx
@@ -0,0 +1,29 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { render } from 'ink-testing-library';
+import { vi } from 'vitest';
+import { FolderTrustDialog, FolderTrustChoice } from './FolderTrustDialog.js';
+
+describe('FolderTrustDialog', () => {
+ it('should render the dialog with title and description', () => {
+ const { lastFrame } = render(<FolderTrustDialog onSelect={vi.fn()} />);
+
+ expect(lastFrame()).toContain('Do you trust this folder?');
+ expect(lastFrame()).toContain(
+ 'Trusting a folder allows Gemini to execute commands it suggests.',
+ );
+ });
+
+ it('should call onSelect with DO_NOT_TRUST when escape is pressed', () => {
+ const onSelect = vi.fn();
+ const { stdin } = render(<FolderTrustDialog onSelect={onSelect} />);
+
+ stdin.write('\u001B'); // Simulate escape key
+
+ expect(onSelect).toHaveBeenCalledWith(FolderTrustChoice.DO_NOT_TRUST);
+ });
+});