mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 22:02:59 -07:00
feat(cli): Add permissions command to modify trust settings (#8792)
This commit is contained in:
@@ -56,7 +56,7 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should not open dialog when folder is already trusted', () => {
|
||||
isWorkspaceTrustedSpy.mockReturnValue(true);
|
||||
isWorkspaceTrustedSpy.mockReturnValue({ isTrusted: true, source: 'file' });
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
@@ -65,7 +65,7 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should not open dialog when folder is already untrusted', () => {
|
||||
isWorkspaceTrustedSpy.mockReturnValue(false);
|
||||
isWorkspaceTrustedSpy.mockReturnValue({ isTrusted: false, source: 'file' });
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
@@ -74,7 +74,10 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should open dialog when folder trust is undefined', () => {
|
||||
isWorkspaceTrustedSpy.mockReturnValue(undefined);
|
||||
isWorkspaceTrustedSpy.mockReturnValue({
|
||||
isTrusted: undefined,
|
||||
source: undefined,
|
||||
});
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
@@ -83,14 +86,14 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should handle TRUST_FOLDER choice', () => {
|
||||
isWorkspaceTrustedSpy
|
||||
.mockReturnValueOnce(undefined)
|
||||
.mockReturnValueOnce(true);
|
||||
isWorkspaceTrustedSpy.mockReturnValue({
|
||||
isTrusted: undefined,
|
||||
source: undefined,
|
||||
});
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
|
||||
isWorkspaceTrustedSpy.mockReturnValue(true);
|
||||
act(() => {
|
||||
result.current.handleFolderTrustSelect(FolderTrustChoice.TRUST_FOLDER);
|
||||
});
|
||||
@@ -105,9 +108,10 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should handle TRUST_PARENT choice', () => {
|
||||
isWorkspaceTrustedSpy
|
||||
.mockReturnValueOnce(undefined)
|
||||
.mockReturnValueOnce(true);
|
||||
isWorkspaceTrustedSpy.mockReturnValue({
|
||||
isTrusted: undefined,
|
||||
source: undefined,
|
||||
});
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
@@ -125,9 +129,10 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should handle DO_NOT_TRUST choice and trigger restart', () => {
|
||||
isWorkspaceTrustedSpy
|
||||
.mockReturnValueOnce(undefined)
|
||||
.mockReturnValueOnce(false);
|
||||
isWorkspaceTrustedSpy.mockReturnValue({
|
||||
isTrusted: undefined,
|
||||
source: undefined,
|
||||
});
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
@@ -146,7 +151,10 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should do nothing for default choice', () => {
|
||||
isWorkspaceTrustedSpy.mockReturnValue(undefined);
|
||||
isWorkspaceTrustedSpy.mockReturnValue({
|
||||
isTrusted: undefined,
|
||||
source: undefined,
|
||||
});
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
@@ -164,7 +172,7 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should set isRestarting to true when trust status changes from false to true', () => {
|
||||
isWorkspaceTrustedSpy.mockReturnValueOnce(false).mockReturnValueOnce(true); // Initially untrusted, then trusted
|
||||
isWorkspaceTrustedSpy.mockReturnValue({ isTrusted: false, source: 'file' }); // Initially untrusted
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
@@ -178,9 +186,10 @@ describe('useFolderTrust', () => {
|
||||
});
|
||||
|
||||
it('should not set isRestarting to true when trust status does not change', () => {
|
||||
isWorkspaceTrustedSpy
|
||||
.mockReturnValueOnce(undefined)
|
||||
.mockReturnValueOnce(true); // Initially undefined, then trust
|
||||
isWorkspaceTrustedSpy.mockReturnValue({
|
||||
isTrusted: undefined,
|
||||
source: undefined,
|
||||
});
|
||||
const { result } = renderHook(() =>
|
||||
useFolderTrust(mockSettings, onTrustChange),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user