mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-02 01:11:24 -07:00
feat(cli): implement atomic writes and safety checks for trusted folders (#18406)
This commit is contained in:
@@ -67,7 +67,7 @@ describe('ConsentPrompt', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('calls onConfirm with true when "Yes" is selected', () => {
|
||||
it('calls onConfirm with true when "Yes" is selected', async () => {
|
||||
const prompt = 'Are you sure?';
|
||||
const { unmount } = render(
|
||||
<ConsentPrompt
|
||||
@@ -78,7 +78,7 @@ describe('ConsentPrompt', () => {
|
||||
);
|
||||
|
||||
const onSelect = MockedRadioButtonSelect.mock.calls[0][0].onSelect;
|
||||
act(() => {
|
||||
await act(async () => {
|
||||
onSelect(true);
|
||||
});
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('ConsentPrompt', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('calls onConfirm with false when "No" is selected', () => {
|
||||
it('calls onConfirm with false when "No" is selected', async () => {
|
||||
const prompt = 'Are you sure?';
|
||||
const { unmount } = render(
|
||||
<ConsentPrompt
|
||||
@@ -97,7 +97,7 @@ describe('ConsentPrompt', () => {
|
||||
);
|
||||
|
||||
const onSelect = MockedRadioButtonSelect.mock.calls[0][0].onSelect;
|
||||
act(() => {
|
||||
await act(async () => {
|
||||
onSelect(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -46,22 +46,26 @@ describe('LogoutConfirmationDialog', () => {
|
||||
expect(mockCall.isFocused).toBe(true);
|
||||
});
|
||||
|
||||
it('should call onSelect with LOGIN when Login is selected', () => {
|
||||
it('should call onSelect with LOGIN when Login is selected', async () => {
|
||||
const onSelect = vi.fn();
|
||||
renderWithProviders(<LogoutConfirmationDialog onSelect={onSelect} />);
|
||||
|
||||
const mockCall = vi.mocked(RadioButtonSelect).mock.calls[0][0];
|
||||
mockCall.onSelect(LogoutChoice.LOGIN);
|
||||
await act(async () => {
|
||||
mockCall.onSelect(LogoutChoice.LOGIN);
|
||||
});
|
||||
|
||||
expect(onSelect).toHaveBeenCalledWith(LogoutChoice.LOGIN);
|
||||
});
|
||||
|
||||
it('should call onSelect with EXIT when Exit is selected', () => {
|
||||
it('should call onSelect with EXIT when Exit is selected', async () => {
|
||||
const onSelect = vi.fn();
|
||||
renderWithProviders(<LogoutConfirmationDialog onSelect={onSelect} />);
|
||||
|
||||
const mockCall = vi.mocked(RadioButtonSelect).mock.calls[0][0];
|
||||
mockCall.onSelect(LogoutChoice.EXIT);
|
||||
await act(async () => {
|
||||
mockCall.onSelect(LogoutChoice.EXIT);
|
||||
});
|
||||
|
||||
expect(onSelect).toHaveBeenCalledWith(LogoutChoice.EXIT);
|
||||
});
|
||||
|
||||
@@ -125,7 +125,10 @@ export const MultiFolderTrustDialog: React.FC<MultiFolderTrustDialogProps> = ({
|
||||
try {
|
||||
const expandedPath = path.resolve(expandHomeDir(dir));
|
||||
if (choice === MultiFolderTrustChoice.YES_AND_REMEMBER) {
|
||||
trustedFolders.setValue(expandedPath, TrustLevel.TRUST_FOLDER);
|
||||
await trustedFolders.setValue(
|
||||
expandedPath,
|
||||
TrustLevel.TRUST_FOLDER,
|
||||
);
|
||||
}
|
||||
workspaceContext.addDirectory(expandedPath);
|
||||
added.push(dir);
|
||||
|
||||
@@ -69,13 +69,14 @@ export function PermissionsModifyTrustDialog({
|
||||
return true;
|
||||
}
|
||||
if (needsRestart && key.name === 'r') {
|
||||
const success = commitTrustLevelChange();
|
||||
if (success) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
relaunchApp();
|
||||
} else {
|
||||
onExit();
|
||||
}
|
||||
void (async () => {
|
||||
const success = await commitTrustLevelChange();
|
||||
if (success) {
|
||||
void relaunchApp();
|
||||
} else {
|
||||
onExit();
|
||||
}
|
||||
})();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user