mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
Migrate core render util to use xterm.js as part of the rendering loop. (#19044)
This commit is contained in:
@@ -149,13 +149,13 @@ describe('SessionBrowser component', () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('shows empty state when no sessions exist', () => {
|
||||
it('shows empty state when no sessions exist', async () => {
|
||||
const config = createMockConfig();
|
||||
const onResumeSession = vi.fn();
|
||||
const onDeleteSession = vi.fn().mockResolvedValue(undefined);
|
||||
const onExit = vi.fn();
|
||||
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady } = render(
|
||||
<TestSessionBrowser
|
||||
config={config}
|
||||
onResumeSession={onResumeSession}
|
||||
@@ -164,11 +164,12 @@ describe('SessionBrowser component', () => {
|
||||
testSessions={[]}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders a list of sessions and marks current session as disabled', () => {
|
||||
it('renders a list of sessions and marks current session as disabled', async () => {
|
||||
const session1 = createSession({
|
||||
id: 'abc123',
|
||||
file: 'abc123',
|
||||
@@ -192,7 +193,7 @@ describe('SessionBrowser component', () => {
|
||||
const onDeleteSession = vi.fn().mockResolvedValue(undefined);
|
||||
const onExit = vi.fn();
|
||||
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady } = render(
|
||||
<TestSessionBrowser
|
||||
config={config}
|
||||
onResumeSession={onResumeSession}
|
||||
@@ -201,11 +202,13 @@ describe('SessionBrowser component', () => {
|
||||
testSessions={[session1, session2]}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('enters search mode, filters sessions, and renders match snippets', async () => {
|
||||
// ... same searchSession setup ...
|
||||
const searchSession = createSession({
|
||||
id: 'search1',
|
||||
file: 'search1',
|
||||
@@ -243,7 +246,7 @@ describe('SessionBrowser component', () => {
|
||||
const onDeleteSession = vi.fn().mockResolvedValue(undefined);
|
||||
const onExit = vi.fn();
|
||||
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady } = render(
|
||||
<TestSessionBrowser
|
||||
config={config}
|
||||
onResumeSession={onResumeSession}
|
||||
@@ -252,11 +255,13 @@ describe('SessionBrowser component', () => {
|
||||
testSessions={[searchSession, otherSession]}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
expect(lastFrame()).toContain('Chat Sessions (2 total');
|
||||
|
||||
// Enter search mode.
|
||||
triggerKey({ sequence: '/', name: '/' });
|
||||
await waitUntilReady();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(lastFrame()).toContain('Search:');
|
||||
@@ -272,6 +277,7 @@ describe('SessionBrowser component', () => {
|
||||
cmd: false,
|
||||
});
|
||||
}
|
||||
await waitUntilReady();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(lastFrame()).toContain('Chat Sessions (1 total, filtered');
|
||||
@@ -279,7 +285,7 @@ describe('SessionBrowser component', () => {
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('handles keyboard navigation and resumes the selected session', () => {
|
||||
it('handles keyboard navigation and resumes the selected session', async () => {
|
||||
const session1 = createSession({
|
||||
id: 'one',
|
||||
file: 'one',
|
||||
@@ -300,7 +306,7 @@ describe('SessionBrowser component', () => {
|
||||
const onDeleteSession = vi.fn().mockResolvedValue(undefined);
|
||||
const onExit = vi.fn();
|
||||
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady } = render(
|
||||
<TestSessionBrowser
|
||||
config={config}
|
||||
onResumeSession={onResumeSession}
|
||||
@@ -309,21 +315,24 @@ describe('SessionBrowser component', () => {
|
||||
testSessions={[session1, session2]}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
expect(lastFrame()).toContain('Chat Sessions (2 total');
|
||||
|
||||
// Move selection down.
|
||||
triggerKey({ name: 'down', sequence: '[B' });
|
||||
await waitUntilReady();
|
||||
|
||||
// Press Enter.
|
||||
triggerKey({ name: 'return', sequence: '\r' });
|
||||
await waitUntilReady();
|
||||
|
||||
expect(onResumeSession).toHaveBeenCalledTimes(1);
|
||||
const [resumedSession] = onResumeSession.mock.calls[0];
|
||||
expect(resumedSession).toEqual(session2);
|
||||
});
|
||||
|
||||
it('does not allow resuming or deleting the current session', () => {
|
||||
it('does not allow resuming or deleting the current session', async () => {
|
||||
const currentSession = createSession({
|
||||
id: 'current',
|
||||
file: 'current',
|
||||
@@ -346,7 +355,7 @@ describe('SessionBrowser component', () => {
|
||||
const onDeleteSession = vi.fn().mockResolvedValue(undefined);
|
||||
const onExit = vi.fn();
|
||||
|
||||
render(
|
||||
const { waitUntilReady } = render(
|
||||
<TestSessionBrowser
|
||||
config={config}
|
||||
onResumeSession={onResumeSession}
|
||||
@@ -355,23 +364,26 @@ describe('SessionBrowser component', () => {
|
||||
testSessions={[currentSession, otherSession]}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
// Active selection is at 0 (current session).
|
||||
triggerKey({ name: 'return', sequence: '\r' });
|
||||
await waitUntilReady();
|
||||
expect(onResumeSession).not.toHaveBeenCalled();
|
||||
|
||||
// Attempt delete.
|
||||
triggerKey({ sequence: 'x', name: 'x' });
|
||||
await waitUntilReady();
|
||||
expect(onDeleteSession).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('shows an error state when loading sessions fails', () => {
|
||||
it('shows an error state when loading sessions fails', async () => {
|
||||
const config = createMockConfig();
|
||||
const onResumeSession = vi.fn();
|
||||
const onDeleteSession = vi.fn().mockResolvedValue(undefined);
|
||||
const onExit = vi.fn();
|
||||
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady } = render(
|
||||
<TestSessionBrowser
|
||||
config={config}
|
||||
onResumeSession={onResumeSession}
|
||||
@@ -380,6 +392,7 @@ describe('SessionBrowser component', () => {
|
||||
testError="storage failure"
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user