Fix tests to wrap all calls changing the UI with act. (#12268)

This commit is contained in:
Jacob Richman
2025-10-30 11:50:26 -07:00
committed by GitHub
parent cc081337b7
commit 54fa26ef0e
69 changed files with 2002 additions and 1291 deletions
@@ -7,7 +7,8 @@
import type { MockedFunction } from 'vitest';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { act } from 'react';
import { render } from 'ink-testing-library';
import { render } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js';
import { useGitBranchName } from './useGitBranchName.js';
import { fs, vol } from 'memfs';
import * as fsPromises from 'node:fs/promises';
@@ -161,7 +162,7 @@ describe('useGitBranchName', () => {
expect(result.current).toBe('main');
// Wait for watcher to be set up
await vi.waitFor(() => {
await waitFor(() => {
expect(watchSpy).toHaveBeenCalled();
});
@@ -171,7 +172,7 @@ describe('useGitBranchName', () => {
rerender();
});
await vi.waitFor(() => {
await waitFor(() => {
expect(result.current).toBe('develop');
});
});
@@ -236,7 +237,7 @@ describe('useGitBranchName', () => {
});
// Wait for watcher to be set up BEFORE unmounting
await vi.waitFor(() => {
await waitFor(() => {
expect(watchMock).toHaveBeenCalledWith(
GIT_LOGS_HEAD_PATH,
expect.any(Function),