mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
- Fix file.clearRecent sending IPC to main process instead of clearing openTabs - Wire show-batch-converter, show-document-compare, open-header-footer-dialog IPC channels - Add print preview event listeners (mc:print-preview, mc:print-preview-styled) in App.tsx - Fix sidebar hidden bridge buttons toggling sidebar closed after scroll - Update sidebar menu labels to match actual sections (Files, Outline, Git) - Fix ipc.print to be an object with show/doPrint methods (was bare function) - Update callers: ExportPdfDialog, pdf-export, PrintPreview - Add 7 regression tests for all fixes - Clean 2 obsolete snapshots - Build Linux packages (deb, AppImage, snap) — 549 tests passing
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
import { render, act, screen, fireEvent } from '@testing-library/react';
|
|
import App from '@/App';
|
|
import { useCommandStore } from '@/stores/command-store';
|
|
import { useAppStore } from '@/stores/app-store';
|
|
import { useFileStore } from '@/stores/file-store';
|
|
import { useSettingsStore } from '@/stores/settings-store';
|
|
import { useEditorStore } from '@/stores/editor-store';
|
|
|
|
vi.mock('@/lib/ipc', () => ({
|
|
ipc: {
|
|
file: {
|
|
pickFolder: vi.fn(),
|
|
pickFile: vi.fn(),
|
|
read: vi.fn(),
|
|
write: vi.fn(),
|
|
list: vi.fn(),
|
|
},
|
|
app: { getVersion: vi.fn().mockResolvedValue({ ok: true, data: '5.0.1' }) },
|
|
menu: { on: vi.fn(() => () => {}) },
|
|
updater: { check: vi.fn(), install: vi.fn(), getState: vi.fn(), onStatus: vi.fn(() => () => {}) },
|
|
crash: { read: vi.fn(), openDir: vi.fn(), delete: vi.fn() },
|
|
},
|
|
}));
|
|
|
|
vi.mock('@/hooks/use-welcome-trigger', () => ({
|
|
useWelcomeTrigger: () => {},
|
|
}));
|
|
|
|
vi.mock('@/hooks/useAutoUpdateCheck', () => ({
|
|
useAutoUpdateCheck: () => {},
|
|
}));
|
|
|
|
describe('App — print preview event listeners', () => {
|
|
beforeEach(() => {
|
|
useCommandStore.setState({ handlers: {} } as any);
|
|
useAppStore.setState({ modal: { kind: null } } as any);
|
|
useFileStore.setState({ tree: null, rootPath: null, expanded: new Set(), openTabs: [], activeTabId: null });
|
|
useSettingsStore.getState().resetToDefaults?.();
|
|
useEditorStore.setState({ buffers: new Map(), activeId: null });
|
|
localStorage.clear();
|
|
});
|
|
|
|
it('opens PrintPreview on mc:print event', () => {
|
|
render(<App />);
|
|
act(() => {
|
|
window.dispatchEvent(new CustomEvent('mc:print'));
|
|
});
|
|
expect(screen.getByText(/print preview/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it('opens PrintPreview on mc:print-preview event', () => {
|
|
render(<App />);
|
|
act(() => {
|
|
window.dispatchEvent(new CustomEvent('mc:print-preview'));
|
|
});
|
|
expect(screen.getByText(/print preview/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it('opens PrintPreview on mc:print-preview-styled event', () => {
|
|
render(<App />);
|
|
act(() => {
|
|
window.dispatchEvent(new CustomEvent('mc:print-preview-styled'));
|
|
});
|
|
expect(screen.getByText(/print preview/i)).toBeInTheDocument();
|
|
});
|
|
});
|