test(cli): refactor tests for async render utilities (#23252)

This commit is contained in:
Tommaso Sciortino
2026-03-20 20:08:29 +00:00
committed by GitHub
parent 86a3a913b5
commit 6c78eb7a39
198 changed files with 3592 additions and 4802 deletions
@@ -81,9 +81,7 @@ describe('<StatsDisplay />', () => {
it('renders only the Performance section in its zero state', async () => {
const zeroMetrics = createTestMetrics();
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(zeroMetrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(zeroMetrics);
const output = lastFrame();
expect(output).toContain('Performance');
@@ -123,8 +121,7 @@ describe('<StatsDisplay />', () => {
},
});
const { lastFrame, waitUntilReady } = await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
const output = lastFrame();
expect(output).toContain('gemini-2.5-pro');
@@ -179,8 +176,7 @@ describe('<StatsDisplay />', () => {
},
});
const { lastFrame, waitUntilReady } = await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
const output = lastFrame();
expect(output).toContain('Performance');
@@ -221,9 +217,7 @@ describe('<StatsDisplay />', () => {
},
});
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
const output = lastFrame();
expect(output).toContain('Interaction Summary');
@@ -251,9 +245,7 @@ describe('<StatsDisplay />', () => {
},
});
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
const output = lastFrame();
expect(output).toMatchSnapshot();
@@ -277,9 +269,7 @@ describe('<StatsDisplay />', () => {
byName: {},
},
});
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
expect(lastFrame()).toMatchSnapshot();
});
@@ -299,9 +289,7 @@ describe('<StatsDisplay />', () => {
byName: {},
},
});
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
expect(lastFrame()).toMatchSnapshot();
});
@@ -321,9 +309,7 @@ describe('<StatsDisplay />', () => {
byName: {},
},
});
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
expect(lastFrame()).toMatchSnapshot();
});
});
@@ -350,9 +336,7 @@ describe('<StatsDisplay />', () => {
},
});
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
const output = lastFrame();
expect(output).toContain('Code Changes:');
@@ -378,9 +362,7 @@ describe('<StatsDisplay />', () => {
},
});
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(metrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(metrics);
const output = lastFrame();
expect(output).not.toContain('Code Changes:');
@@ -392,9 +374,7 @@ describe('<StatsDisplay />', () => {
const zeroMetrics = createTestMetrics();
it('renders the default title when no title prop is provided', async () => {
const { lastFrame, waitUntilReady } =
await renderWithMockedStats(zeroMetrics);
await waitUntilReady();
const { lastFrame } = await renderWithMockedStats(zeroMetrics);
const output = lastFrame();
expect(output).toContain('Session Stats');
expect(output).not.toContain('Agent powering down');
@@ -415,11 +395,10 @@ describe('<StatsDisplay />', () => {
startNewPrompt: vi.fn(),
});
const { lastFrame, waitUntilReady } = await renderWithProviders(
const { lastFrame } = await renderWithProviders(
<StatsDisplay duration="1s" title="Agent powering down. Goodbye!" />,
{ width: 100 },
);
await waitUntilReady();
const output = lastFrame();
expect(output).toContain('Agent powering down. Goodbye!');
expect(output).not.toContain('Session Stats');
@@ -477,11 +456,10 @@ describe('<StatsDisplay />', () => {
startNewPrompt: vi.fn(),
});
const { lastFrame, waitUntilReady } = await renderWithProviders(
const { lastFrame } = await renderWithProviders(
<StatsDisplay duration="1s" quotas={quotas} />,
{ width: 100 },
);
await waitUntilReady();
const output = lastFrame();
expect(output).toContain('Model usage');
@@ -525,7 +503,7 @@ describe('<StatsDisplay />', () => {
startNewPrompt: vi.fn(),
});
const { lastFrame, waitUntilReady } = await renderWithProviders(
const { lastFrame } = await renderWithProviders(
<StatsDisplay
duration="1s"
quotas={quotas}
@@ -537,7 +515,6 @@ describe('<StatsDisplay />', () => {
/>,
{ width: 100 },
);
await waitUntilReady();
const output = lastFrame();
// (1 - 710/1100) * 100 = 35.5%
@@ -581,11 +558,10 @@ describe('<StatsDisplay />', () => {
startNewPrompt: vi.fn(),
});
const { lastFrame, waitUntilReady } = await renderWithProviders(
const { lastFrame } = await renderWithProviders(
<StatsDisplay duration="1s" quotas={quotas} />,
{ width: 100 },
);
await waitUntilReady();
const output = lastFrame();
expect(output).toContain('gemini-2.5-flash');
@@ -614,7 +590,7 @@ describe('<StatsDisplay />', () => {
startNewPrompt: vi.fn(),
});
const { lastFrame, waitUntilReady } = await renderWithProviders(
const { lastFrame } = await renderWithProviders(
<StatsDisplay
duration="1s"
selectedAuthType="oauth"
@@ -623,7 +599,6 @@ describe('<StatsDisplay />', () => {
/>,
{ width: 100 },
);
await waitUntilReady();
const output = lastFrame();
expect(output).toContain('Auth Method:');
@@ -647,11 +622,10 @@ describe('<StatsDisplay />', () => {
startNewPrompt: vi.fn(),
});
const { lastFrame, waitUntilReady } = await renderWithProviders(
const { lastFrame } = await renderWithProviders(
<StatsDisplay duration="1s" selectedAuthType="Google API Key" />,
{ width: 100 },
);
await waitUntilReady();
const output = lastFrame();
expect(output).toContain('Auth Method:');