mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-03 01:40:59 -07:00
Migrate core render util to use xterm.js as part of the rendering loop. (#19044)
This commit is contained in:
@@ -71,22 +71,27 @@ describe('MultiFolderTrustDialog', () => {
|
||||
));
|
||||
});
|
||||
|
||||
it('renders the dialog with the list of folders', () => {
|
||||
it('renders the dialog with the list of folders', async () => {
|
||||
const folders = ['/path/to/folder1', '/path/to/folder2'];
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog {...defaultProps} folders={folders} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
expect(lastFrame()).toContain(
|
||||
'Do you trust the following folders being added to this workspace?',
|
||||
);
|
||||
expect(lastFrame()).toContain('- /path/to/folder1');
|
||||
expect(lastFrame()).toContain('- /path/to/folder2');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('calls onComplete and finishAddingDirectories with an error on escape', async () => {
|
||||
const folders = ['/path/to/folder1'];
|
||||
render(<MultiFolderTrustDialog {...defaultProps} folders={folders} />);
|
||||
const { waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog {...defaultProps} folders={folders} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const keypressCallback = mockedUseKeypress.mock.calls[0][0];
|
||||
await act(async () => {
|
||||
@@ -100,6 +105,7 @@ describe('MultiFolderTrustDialog', () => {
|
||||
insertable: false,
|
||||
});
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
expect(mockFinishAddingDirectories).toHaveBeenCalledWith(
|
||||
mockConfig,
|
||||
@@ -110,16 +116,21 @@ describe('MultiFolderTrustDialog', () => {
|
||||
],
|
||||
);
|
||||
expect(mockOnComplete).toHaveBeenCalled();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('calls finishAddingDirectories with an error and does not add directories when "No" is chosen', async () => {
|
||||
const folders = ['/path/to/folder1'];
|
||||
render(<MultiFolderTrustDialog {...defaultProps} folders={folders} />);
|
||||
const { waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog {...defaultProps} folders={folders} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const { onSelect } = mockedRadioButtonSelect.mock.calls[0][0];
|
||||
await act(async () => {
|
||||
onSelect(MultiFolderTrustChoice.NO);
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
expect(mockFinishAddingDirectories).toHaveBeenCalledWith(
|
||||
mockConfig,
|
||||
@@ -132,22 +143,25 @@ describe('MultiFolderTrustDialog', () => {
|
||||
expect(mockOnComplete).toHaveBeenCalled();
|
||||
expect(mockAddDirectory).not.toHaveBeenCalled();
|
||||
expect(mockSetValue).not.toHaveBeenCalled();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('adds directories to workspace context when "Yes" is chosen', async () => {
|
||||
const folders = ['/path/to/folder1', '/path/to/folder2'];
|
||||
render(
|
||||
const { waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog
|
||||
{...defaultProps}
|
||||
folders={folders}
|
||||
trustedDirs={['/already/trusted']}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const { onSelect } = mockedRadioButtonSelect.mock.calls[0][0];
|
||||
await act(async () => {
|
||||
onSelect(MultiFolderTrustChoice.YES);
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
expect(mockAddDirectory).toHaveBeenCalledWith(
|
||||
path.resolve('/path/to/folder1'),
|
||||
@@ -163,16 +177,21 @@ describe('MultiFolderTrustDialog', () => {
|
||||
[],
|
||||
);
|
||||
expect(mockOnComplete).toHaveBeenCalled();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('adds directories to workspace context and remembers them as trusted when "Yes, and remember" is chosen', async () => {
|
||||
const folders = ['/path/to/folder1'];
|
||||
render(<MultiFolderTrustDialog {...defaultProps} folders={folders} />);
|
||||
const { waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog {...defaultProps} folders={folders} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const { onSelect } = mockedRadioButtonSelect.mock.calls[0][0];
|
||||
await act(async () => {
|
||||
onSelect(MultiFolderTrustChoice.YES_AND_REMEMBER);
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
expect(mockAddDirectory).toHaveBeenCalledWith(
|
||||
path.resolve('/path/to/folder1'),
|
||||
@@ -188,37 +207,43 @@ describe('MultiFolderTrustDialog', () => {
|
||||
[],
|
||||
);
|
||||
expect(mockOnComplete).toHaveBeenCalled();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('shows submitting message after a choice is made', async () => {
|
||||
const folders = ['/path/to/folder1'];
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog {...defaultProps} folders={folders} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const { onSelect } = mockedRadioButtonSelect.mock.calls[0][0];
|
||||
|
||||
await act(async () => {
|
||||
onSelect(MultiFolderTrustChoice.NO);
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
expect(lastFrame()).toContain('Applying trust settings...');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('shows an error message and completes when config is missing', async () => {
|
||||
const folders = ['/path/to/folder1'];
|
||||
render(
|
||||
const { waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog
|
||||
{...defaultProps}
|
||||
folders={folders}
|
||||
config={null as unknown as Config}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const { onSelect } = mockedRadioButtonSelect.mock.calls[0][0];
|
||||
await act(async () => {
|
||||
onSelect(MultiFolderTrustChoice.YES);
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
expect(mockAddItem).toHaveBeenCalledWith({
|
||||
type: MessageType.ERROR,
|
||||
@@ -226,6 +251,7 @@ describe('MultiFolderTrustDialog', () => {
|
||||
});
|
||||
expect(mockOnComplete).toHaveBeenCalled();
|
||||
expect(mockFinishAddingDirectories).not.toHaveBeenCalled();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('collects and reports errors when some directories fail to be added', async () => {
|
||||
@@ -237,18 +263,20 @@ describe('MultiFolderTrustDialog', () => {
|
||||
});
|
||||
|
||||
const folders = ['/path/to/good', '/path/to/error'];
|
||||
render(
|
||||
const { waitUntilReady, unmount } = render(
|
||||
<MultiFolderTrustDialog
|
||||
{...defaultProps}
|
||||
folders={folders}
|
||||
errors={['initial error']}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const { onSelect } = mockedRadioButtonSelect.mock.calls[0][0];
|
||||
await act(async () => {
|
||||
onSelect(MultiFolderTrustChoice.YES);
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
expect(mockAddDirectory).toHaveBeenCalledWith(
|
||||
path.resolve('/path/to/good'),
|
||||
@@ -263,5 +291,6 @@ describe('MultiFolderTrustDialog', () => {
|
||||
['initial error', "Error adding '/path/to/error': Test error"],
|
||||
);
|
||||
expect(mockOnComplete).toHaveBeenCalled();
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user