refactor(cli): integrate real config loading into async test utils (#23040)

This commit is contained in:
Tommaso Sciortino
2026-03-19 17:05:33 +00:00
committed by GitHub
parent 7de0616229
commit 23264ced9a
103 changed files with 1806 additions and 1541 deletions

View File

@@ -48,7 +48,7 @@ describe('FolderTrustDialog', () => {
});
it('should render the dialog with title and description', async () => {
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} />,
);
await waitUntilReady();
@@ -72,7 +72,7 @@ describe('FolderTrustDialog', () => {
discoveryErrors: [],
securityWarnings: [],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -103,7 +103,7 @@ describe('FolderTrustDialog', () => {
discoveryErrors: [],
securityWarnings: [],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -135,7 +135,7 @@ describe('FolderTrustDialog', () => {
discoveryErrors: [],
securityWarnings: [],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -165,7 +165,7 @@ describe('FolderTrustDialog', () => {
securityWarnings: [],
};
const { lastFrame, unmount } = renderWithProviders(
const { lastFrame, unmount } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -192,7 +192,7 @@ describe('FolderTrustDialog', () => {
// because it's handled in AppContainer.
// But we can re-render with constrainHeight: false.
const { lastFrame: lastFrameExpanded, unmount: unmountExpanded } =
renderWithProviders(
await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -217,9 +217,10 @@ describe('FolderTrustDialog', () => {
it('should display exit message and call process.exit and not call onSelect when escape is pressed', async () => {
const onSelect = vi.fn();
const { lastFrame, stdin, waitUntilReady, unmount } = renderWithProviders(
<FolderTrustDialog onSelect={onSelect} isRestarting={false} />,
);
const { lastFrame, stdin, waitUntilReady, unmount } =
await renderWithProviders(
<FolderTrustDialog onSelect={onSelect} isRestarting={false} />,
);
await waitUntilReady();
await act(async () => {
@@ -245,7 +246,7 @@ describe('FolderTrustDialog', () => {
});
it('should display restart message when isRestarting is true', async () => {
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} isRestarting={true} />,
);
await waitUntilReady();
@@ -259,7 +260,7 @@ describe('FolderTrustDialog', () => {
const relaunchApp = vi
.spyOn(processUtils, 'relaunchApp')
.mockResolvedValue(undefined);
const { waitUntilReady, unmount } = renderWithProviders(
const { waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} isRestarting={true} />,
);
await waitUntilReady();
@@ -274,7 +275,7 @@ describe('FolderTrustDialog', () => {
const relaunchApp = vi
.spyOn(processUtils, 'relaunchApp')
.mockResolvedValue(undefined);
const { waitUntilReady, unmount } = renderWithProviders(
const { waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} isRestarting={true} />,
);
await waitUntilReady();
@@ -288,7 +289,7 @@ describe('FolderTrustDialog', () => {
});
it('should not call process.exit when "r" is pressed and isRestarting is false', async () => {
const { stdin, waitUntilReady, unmount } = renderWithProviders(
const { stdin, waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} isRestarting={false} />,
);
await waitUntilReady();
@@ -307,7 +308,7 @@ describe('FolderTrustDialog', () => {
describe('directory display', () => {
it('should correctly display the folder name for a nested directory', async () => {
mockedCwd.mockReturnValue('/home/user/project');
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} />,
);
await waitUntilReady();
@@ -317,7 +318,7 @@ describe('FolderTrustDialog', () => {
it('should correctly display the parent folder name for a nested directory', async () => {
mockedCwd.mockReturnValue('/home/user/project');
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} />,
);
await waitUntilReady();
@@ -327,7 +328,7 @@ describe('FolderTrustDialog', () => {
it('should correctly display an empty parent folder name for a directory directly under root', async () => {
mockedCwd.mockReturnValue('/project');
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
<FolderTrustDialog onSelect={vi.fn()} />,
);
await waitUntilReady();
@@ -347,7 +348,7 @@ describe('FolderTrustDialog', () => {
discoveryErrors: [],
securityWarnings: [],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -385,7 +386,7 @@ describe('FolderTrustDialog', () => {
discoveryErrors: [],
securityWarnings: ['Dangerous setting detected!'],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -409,7 +410,7 @@ describe('FolderTrustDialog', () => {
discoveryErrors: ['Failed to load custom commands'],
securityWarnings: [],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -433,7 +434,7 @@ describe('FolderTrustDialog', () => {
discoveryErrors: [],
securityWarnings: [],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}
@@ -469,7 +470,7 @@ describe('FolderTrustDialog', () => {
securityWarnings: [`${ansiRed}warning-with-ansi${ansiReset}`],
};
const { lastFrame, unmount, waitUntilReady } = renderWithProviders(
const { lastFrame, unmount, waitUntilReady } = await renderWithProviders(
<FolderTrustDialog
onSelect={vi.fn()}
discoveryResults={discoveryResults}