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

@@ -47,13 +47,13 @@ describe('useFocus', () => {
stdin.removeAllListeners();
});
const renderFocusHook = () => {
const renderFocusHook = async () => {
let hookResult: ReturnType<typeof useFocus>;
function TestComponent() {
hookResult = useFocus();
return null;
}
const { unmount } = renderWithProviders(<TestComponent />);
const { unmount } = await renderWithProviders(<TestComponent />);
return {
result: {
get current() {
@@ -64,15 +64,15 @@ describe('useFocus', () => {
};
};
it('should initialize with focus and enable focus reporting', () => {
const { result } = renderFocusHook();
it('should initialize with focus and enable focus reporting', async () => {
const { result } = await renderFocusHook();
expect(result.current.isFocused).toBe(true);
expect(stdout.write).toHaveBeenCalledWith('\x1b[?1004h');
});
it('should set isFocused to false when a focus-out event is received', () => {
const { result } = renderFocusHook();
it('should set isFocused to false when a focus-out event is received', async () => {
const { result } = await renderFocusHook();
// Initial state is focused
expect(result.current.isFocused).toBe(true);
@@ -86,8 +86,8 @@ describe('useFocus', () => {
expect(result.current.isFocused).toBe(false);
});
it('should set isFocused to true when a focus-in event is received', () => {
const { result } = renderFocusHook();
it('should set isFocused to true when a focus-in event is received', async () => {
const { result } = await renderFocusHook();
// Simulate focus-out to set initial state to false
act(() => {
@@ -104,8 +104,8 @@ describe('useFocus', () => {
expect(result.current.isFocused).toBe(true);
});
it('should clean up and disable focus reporting on unmount', () => {
const { unmount } = renderFocusHook();
it('should clean up and disable focus reporting on unmount', async () => {
const { unmount } = await renderFocusHook();
// At this point we should have listeners from both KeypressProvider and useFocus
const listenerCountAfterMount = stdin.listenerCount('data');
@@ -119,8 +119,8 @@ describe('useFocus', () => {
expect(stdin.listenerCount('data')).toBeLessThan(listenerCountAfterMount);
});
it('should handle multiple focus events correctly', () => {
const { result } = renderFocusHook();
it('should handle multiple focus events correctly', async () => {
const { result } = await renderFocusHook();
act(() => {
stdin.emit('data', '\x1b[O');
@@ -143,8 +143,8 @@ describe('useFocus', () => {
expect(result.current.isFocused).toBe(true);
});
it('restores focus on keypress after focus is lost', () => {
const { result } = renderFocusHook();
it('restores focus on keypress after focus is lost', async () => {
const { result } = await renderFocusHook();
// Simulate focus-out event
act(() => {
@@ -159,8 +159,8 @@ describe('useFocus', () => {
expect(result.current.isFocused).toBe(true);
});
it('tracks whether any focus event has been received', () => {
const { result } = renderFocusHook();
it('tracks whether any focus event has been received', async () => {
const { result } = await renderFocusHook();
expect(result.current.hasReceivedFocusEvent).toBe(false);