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

@@ -139,7 +139,7 @@ Implement a comprehensive authentication system with multiple providers.
vi.restoreAllMocks();
});
const renderDialog = (options?: { useAlternateBuffer?: boolean }) => {
const renderDialog = async (options?: { useAlternateBuffer?: boolean }) => {
const useAlternateBuffer = options?.useAlternateBuffer ?? true;
return renderWithProviders(
<ExitPlanModeDialog
@@ -176,7 +176,9 @@ Implement a comprehensive authentication system with multiple providers.
'useAlternateBuffer: $useAlternateBuffer',
({ useAlternateBuffer }) => {
it('renders correctly with plan content', async () => {
const { lastFrame } = renderDialog({ useAlternateBuffer });
const { lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
// Advance timers to pass the debounce period
await act(async () => {
@@ -199,7 +201,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('calls onApprove with AUTO_EDIT when first option is selected', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -217,7 +221,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('calls onApprove with DEFAULT when second option is selected', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -236,7 +242,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('calls onFeedback when feedback is typed and submitted', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -267,7 +275,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('calls onCancel when Esc is pressed', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -293,7 +303,9 @@ Implement a comprehensive authentication system with multiple providers.
error: 'File not found',
});
const { lastFrame } = renderDialog({ useAlternateBuffer });
const { lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -309,7 +321,9 @@ Implement a comprehensive authentication system with multiple providers.
it('displays error state when plan file is empty', async () => {
vi.mocked(validatePlanContent).mockResolvedValue('Plan file is empty.');
const { lastFrame } = renderDialog({ useAlternateBuffer });
const { lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -328,7 +342,9 @@ Implement a comprehensive authentication system with multiple providers.
returnDisplay: 'Read file',
});
const { lastFrame } = renderDialog({ useAlternateBuffer });
const { lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -344,7 +360,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('allows number key quick selection', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -363,7 +381,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('clears feedback text when Ctrl+C is pressed while editing', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -420,7 +440,7 @@ Implement a comprehensive authentication system with multiple providers.
return <>{children}</>;
};
const { stdin, lastFrame } = renderWithProviders(
const { stdin, lastFrame } = await renderWithProviders(
<BubbleListener>
<ExitPlanModeDialog
planPath={mockPlanFullPath}
@@ -491,7 +511,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('does not submit empty feedback when Enter is pressed', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -518,7 +540,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('allows arrow navigation while typing feedback to change selection', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();
@@ -550,7 +574,9 @@ Implement a comprehensive authentication system with multiple providers.
});
it('automatically submits feedback when Ctrl+X is used to edit the plan', async () => {
const { stdin, lastFrame } = renderDialog({ useAlternateBuffer });
const { stdin, lastFrame } = await act(async () =>
renderDialog({ useAlternateBuffer }),
);
await act(async () => {
vi.runAllTimers();