- apps/web: test updates (Vitest/setup), playbackAnalyticsService, TrackGrid, serviceErrorHandler - veza-common: logging, metrics, traits, validation, random - veza-stream-server: audio pipeline, codecs, cache, monitoring, routes - apps/web/dist_verification: refresh build assets (content-hashed filenames) Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import { render, screen, fireEvent } from '@testing-library/react';
|
|
import { describe, it, expect, vi } from 'vitest';
|
|
import { ImageCropper } from './ImageCropper';
|
|
|
|
// Mock react-easy-crop (lazy loaded in the component)
|
|
// The component uses a mock Cropper internally that renders "Cropper Mock"
|
|
|
|
describe('ImageCropper Component', () => {
|
|
const mockOnCancel = vi.fn();
|
|
const mockOnCropComplete = vi.fn();
|
|
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('renders cropper with image', async () => {
|
|
render(
|
|
<ImageCropper
|
|
imageSrc="test.jpg"
|
|
aspectRatio={1}
|
|
onCancel={mockOnCancel}
|
|
onCropComplete={mockOnCropComplete}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByText('Edit Image')).toBeInTheDocument();
|
|
});
|
|
|
|
it('calls onCancel when cancel button is clicked', () => {
|
|
render(
|
|
<ImageCropper
|
|
imageSrc="test.jpg"
|
|
aspectRatio={1}
|
|
onCancel={mockOnCancel}
|
|
onCropComplete={mockOnCropComplete}
|
|
/>,
|
|
);
|
|
|
|
const cancelButton = screen.getByText('Cancel');
|
|
fireEvent.click(cancelButton);
|
|
|
|
expect(mockOnCancel).toHaveBeenCalled();
|
|
});
|
|
|
|
it('calls onCropComplete when save button is clicked', () => {
|
|
render(
|
|
<ImageCropper
|
|
imageSrc="test.jpg"
|
|
aspectRatio={1}
|
|
onCancel={mockOnCancel}
|
|
onCropComplete={mockOnCropComplete}
|
|
/>,
|
|
);
|
|
|
|
// Click save button (Apply Crop) - it calls onCropComplete with current croppedAreaPixels
|
|
const saveButton = screen.getByText('Apply Crop');
|
|
fireEvent.click(saveButton);
|
|
|
|
expect(mockOnCropComplete).toHaveBeenCalled();
|
|
});
|
|
|
|
it('renders with circular crop when circularCrop is true', () => {
|
|
render(
|
|
<ImageCropper
|
|
imageSrc="test.jpg"
|
|
aspectRatio={1}
|
|
onCancel={mockOnCancel}
|
|
onCropComplete={mockOnCropComplete}
|
|
circularCrop={true}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByText('Edit Image')).toBeInTheDocument();
|
|
});
|
|
});
|