import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { GitStatusPanel } from '@/components/sidebar/GitStatusPanel';
import { useFileStore } from '@/stores/file-store';
vi.mock('@/lib/ipc', () => ({
ipc: {
file: {
gitStatus: vi.fn(),
},
},
}));
import { ipc } from '@/lib/ipc';
describe('GitStatusPanel', () => {
beforeEach(() => {
localStorage.clear();
vi.clearAllMocks();
});
it('shows "No folder open" when rootPath is null', () => {
useFileStore.setState({ rootPath: null } as any);
render(
element distinct from the error heading
expect(
await screen.findByText('Not a git repository, or git not installed.')
).toBeInTheDocument();
});
it('opens file on click', async () => {
const openFile = vi.fn();
(ipc.file.gitStatus as any).mockResolvedValueOnce({
ok: true,
data: [{ filePath: '/project/a.md', status: 'modified' }],
});
useFileStore.setState({ rootPath: '/project', openFile } as any);
render(