mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
feat: enhance WelcomeDialog, export dialogs, GitStatusPanel, add CommandPalette, FindReplaceBar, and new converter dialogs
- WelcomeDialog: add quick start, feature showcase, keyboard shortcuts, recent files, version display - ExportDocxDialog/ExportHtmlDialog/ExportPdfDialog: add header/footer, paper size, margin controls - GitStatusPanel: full staging/unstaging, discard, commit workflow - CommandPalette: fuzzy command search with keyboard navigation - FindReplaceBar: find/replace with regex, case, whole-word options - New dialogs: BatchMediaConverterDialog, HeaderFooterDialog, PdfEditorDialog, UniversalConverterDialog - Tests: comprehensive coverage for all new/updated components
This commit is contained in:
@@ -12,8 +12,30 @@ vi.mock('@/lib/ipc', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('@/lib/toast', () => ({
|
||||
toast: {
|
||||
success: vi.fn(),
|
||||
error: vi.fn(),
|
||||
info: vi.fn(),
|
||||
warning: vi.fn(),
|
||||
promise: vi.fn(),
|
||||
dismiss: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
import { ipc } from '@/lib/ipc';
|
||||
|
||||
const mockGitStage = vi.fn();
|
||||
const mockGitCommit = vi.fn();
|
||||
|
||||
Object.defineProperty(window, 'electronAPI', {
|
||||
value: {
|
||||
gitStage: mockGitStage,
|
||||
gitCommit: mockGitCommit,
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
|
||||
describe('GitStatusPanel', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
@@ -54,7 +76,6 @@ describe('GitStatusPanel', () => {
|
||||
});
|
||||
useFileStore.setState({ rootPath: '/project' } as any);
|
||||
render(<GitStatusPanel />);
|
||||
// The helper text appears in a <p> element distinct from the error heading
|
||||
expect(
|
||||
await screen.findByText('Not a git repository, or git not installed.')
|
||||
).toBeInTheDocument();
|
||||
@@ -72,4 +93,65 @@ describe('GitStatusPanel', () => {
|
||||
await userEvent.click(row);
|
||||
expect(openFile).toHaveBeenCalledWith('/project/a.md');
|
||||
});
|
||||
|
||||
it('shows stage and commit UI when files are changed', async () => {
|
||||
(ipc.file.gitStatus as any).mockResolvedValueOnce({
|
||||
ok: true,
|
||||
data: [{ filePath: '/project/a.md', status: 'modified' }],
|
||||
});
|
||||
useFileStore.setState({ rootPath: '/project' } as any);
|
||||
render(<GitStatusPanel />);
|
||||
expect(await screen.findByText('Select All')).toBeInTheDocument();
|
||||
expect(screen.getByText('Stage Selected')).toBeInTheDocument();
|
||||
expect(screen.getByText('Stage All')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('git-commit-input')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('git-commit-button')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('selects and deselects files via checkboxes and select all', async () => {
|
||||
(ipc.file.gitStatus as any).mockResolvedValue({
|
||||
ok: true,
|
||||
data: [
|
||||
{ filePath: '/project/a.md', status: 'modified' },
|
||||
{ filePath: '/project/b.md', status: 'added' },
|
||||
],
|
||||
});
|
||||
useFileStore.setState({ rootPath: '/project' } as any);
|
||||
render(<GitStatusPanel />);
|
||||
const selectAllBtn = await screen.findByText('Select All');
|
||||
await userEvent.click(selectAllBtn);
|
||||
expect(screen.getByText('Deselect All')).toBeInTheDocument();
|
||||
await userEvent.click(screen.getByText('Deselect All'));
|
||||
expect(screen.getByText('Select All')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('stages selected files', async () => {
|
||||
mockGitStage.mockResolvedValueOnce(undefined);
|
||||
(ipc.file.gitStatus as any).mockResolvedValue({
|
||||
ok: true,
|
||||
data: [{ filePath: '/project/a.md', status: 'modified' }],
|
||||
});
|
||||
useFileStore.setState({ rootPath: '/project' } as any);
|
||||
render(<GitStatusPanel />);
|
||||
const checkbox = await screen.findByTestId('git-status-checkbox');
|
||||
await userEvent.click(checkbox);
|
||||
const stageBtn = screen.getByTestId('git-stage-selected');
|
||||
await userEvent.click(stageBtn);
|
||||
expect(mockGitStage).toHaveBeenCalledWith(['/project/a.md']);
|
||||
});
|
||||
|
||||
it('commits with message', async () => {
|
||||
mockGitCommit.mockResolvedValueOnce(undefined);
|
||||
(ipc.file.gitStatus as any).mockResolvedValue({
|
||||
ok: true,
|
||||
data: [{ filePath: '/project/a.md', status: 'modified' }],
|
||||
});
|
||||
useFileStore.setState({ rootPath: '/project' } as any);
|
||||
render(<GitStatusPanel />);
|
||||
const input = await screen.findByTestId('git-commit-input');
|
||||
await userEvent.type(input, 'fix typo');
|
||||
const commitBtn = screen.getByTestId('git-commit-button');
|
||||
await userEvent.click(commitBtn);
|
||||
expect(mockGitCommit).toHaveBeenCalledWith('fix typo');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user