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
@@ -72,53 +72,46 @@ useSessionStatsMock.mockReturnValue({
describe('Gradient Crash Regression Tests', () => {
it('<Header /> should not crash when theme.ui.gradient is empty', async () => {
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
const { lastFrame, unmount } = await renderWithProviders(
<Header version="1.0.0" nightly={false} />,
{
width: 120,
},
);
await waitUntilReady();
expect(lastFrame()).toBeDefined();
unmount();
});
it('<ModelDialog /> should not crash when theme.ui.gradient is empty', async () => {
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
const { lastFrame, unmount } = await renderWithProviders(
<ModelDialog onClose={async () => {}} />,
{
width: 120,
},
);
await waitUntilReady();
expect(lastFrame()).toBeDefined();
unmount();
});
it('<Banner /> should not crash when theme.ui.gradient is empty', async () => {
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
const { lastFrame, unmount } = await renderWithProviders(
<Banner bannerText="Test Banner" isWarning={false} width={80} />,
{
width: 120,
},
);
await waitUntilReady();
expect(lastFrame()).toBeDefined();
unmount();
});
it('<Footer /> should not crash when theme.ui.gradient has only one color (or empty) and nightly is true', async () => {
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
<Footer />,
{
width: 120,
uiState: {
nightly: true, // Enable nightly to trigger Gradient usage logic
sessionStats: mockSessionStats,
},
const { lastFrame, unmount } = await renderWithProviders(<Footer />, {
width: 120,
uiState: {
nightly: true, // Enable nightly to trigger Gradient usage logic
sessionStats: mockSessionStats,
},
);
await waitUntilReady();
});
// If it crashes, this line won't be reached or lastFrame() will throw
expect(lastFrame()).toBeDefined();
// It should fall back to rendering text without gradient
@@ -127,7 +120,7 @@ describe('Gradient Crash Regression Tests', () => {
});
it('<StatsDisplay /> should not crash when theme.ui.gradient is empty', async () => {
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
const { lastFrame, unmount } = await renderWithProviders(
<StatsDisplay duration="1s" title="My Stats" />,
{
width: 120,
@@ -136,7 +129,6 @@ describe('Gradient Crash Regression Tests', () => {
},
},
);
await waitUntilReady();
expect(lastFrame()).toBeDefined();
// Ensure title is rendered
expect(lastFrame()).toContain('My Stats');