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
@@ -93,7 +93,7 @@ describe('usePermissionsModifyTrust', () => {
});
describe('when targetDirectory is the current workspace', () => {
it('should initialize with the correct trust level', () => {
it('should initialize with the correct trust level', async () => {
mockedLoadTrustedFolders.mockReturnValue({
user: { config: { '/test/dir': TrustLevel.TRUST_FOLDER } },
} as unknown as LoadedTrustedFolders);
@@ -102,14 +102,14 @@ describe('usePermissionsModifyTrust', () => {
source: 'file',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
expect(result.current.currentTrustLevel).toBe(TrustLevel.TRUST_FOLDER);
});
it('should detect inherited trust from parent', () => {
it('should detect inherited trust from parent', async () => {
mockedLoadTrustedFolders.mockReturnValue({
user: { config: {} },
setValue: vi.fn(),
@@ -119,7 +119,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'file',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -127,7 +127,7 @@ describe('usePermissionsModifyTrust', () => {
expect(result.current.isInheritedTrustFromIde).toBe(false);
});
it('should detect inherited trust from IDE', () => {
it('should detect inherited trust from IDE', async () => {
mockedLoadTrustedFolders.mockReturnValue({
user: { config: {} }, // No explicit trust
} as unknown as LoadedTrustedFolders);
@@ -136,7 +136,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'ide',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -155,7 +155,7 @@ describe('usePermissionsModifyTrust', () => {
.mockReturnValueOnce({ isTrusted: false, source: 'file' })
.mockReturnValueOnce({ isTrusted: true, source: 'file' });
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -179,7 +179,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'file',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -206,7 +206,7 @@ describe('usePermissionsModifyTrust', () => {
.mockReturnValueOnce({ isTrusted: false, source: 'file' })
.mockReturnValueOnce({ isTrusted: true, source: 'file' });
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -236,7 +236,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'file',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -263,7 +263,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'ide',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -284,7 +284,7 @@ describe('usePermissionsModifyTrust', () => {
describe('when targetDirectory is not the current workspace', () => {
const otherDirectory = '/other/dir';
it('should not detect inherited trust', () => {
it('should not detect inherited trust', async () => {
mockedLoadTrustedFolders.mockReturnValue({
user: { config: {} },
} as unknown as LoadedTrustedFolders);
@@ -293,7 +293,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'file',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, otherDirectory),
);
@@ -312,7 +312,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'file',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, otherDirectory),
);
@@ -338,7 +338,7 @@ describe('usePermissionsModifyTrust', () => {
source: 'file',
});
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, otherDirectory),
);
@@ -366,7 +366,7 @@ describe('usePermissionsModifyTrust', () => {
const emitFeedbackSpy = vi.spyOn(coreEvents, 'emitFeedback');
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);
@@ -396,7 +396,7 @@ describe('usePermissionsModifyTrust', () => {
const emitFeedbackSpy = vi.spyOn(coreEvents, 'emitFeedback');
const { result } = renderHook(() =>
const { result } = await renderHook(() =>
usePermissionsModifyTrust(mockOnExit, mockAddItem, mockedCwd()),
);