All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
- 实现评论系统,包括评论输入、列表展示和集成指南 - 添加反应功能组件(ReactionBar、ReactionButton、ReactionPicker) - 实现离线编辑支持,包括同步状态管理和冲突解决 - 添加主题定制功能,支持多种配色方案和主题预览 - 新增多视图布局选项(时间线、分组、砌体视图) - 实现个人资料编辑器,支持头像、简介和自定义字段编辑 - 添加统计页面,展示存储使用情况和上传趋势 - 新增相册管理功能,支持相册创建、编辑和照片管理 - 实现响应式设计和加载骨架屏组件 - 扩展国际化支持,新增孟加拉语、波斯语、印尼语、日语、葡萄牙语等语言 - 添加错误边界组件和离线指示器 - 更新配置文件、路由和依赖项 - 新增完整的文档、测试用例和集成指南
80 lines
2.1 KiB
TypeScript
80 lines
2.1 KiB
TypeScript
/**
|
|
* PhotoDetailModal Integration Test
|
|
* Feature: personal-user-enhancements
|
|
* Tests: Comments integration in photo detail view
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
import '@testing-library/jest-dom';
|
|
import PhotoDetailModal from '../PhotoDetailModal';
|
|
import { ImageItem } from '@/pages/gallery/typings';
|
|
|
|
// Mock dependencies
|
|
jest.mock('@/hooks/useComments', () => ({
|
|
__esModule: true,
|
|
default: () => ({
|
|
comments: [],
|
|
loading: false,
|
|
createLoading: false,
|
|
updateLoading: false,
|
|
deleteLoading: false,
|
|
addComment: jest.fn(),
|
|
updateComment: jest.fn(),
|
|
deleteComment: jest.fn(),
|
|
}),
|
|
}));
|
|
|
|
jest.mock('@/utils/userUtils', () => ({
|
|
getAuthization: () => 'mock-token',
|
|
}));
|
|
|
|
describe('PhotoDetailModal - Comments Integration', () => {
|
|
const mockPhoto: ImageItem = {
|
|
instanceId: 'photo-123',
|
|
imageName: 'test-photo.jpg',
|
|
size: 1024000,
|
|
createTime: '2024-01-15T10:30:00Z',
|
|
};
|
|
|
|
const defaultProps = {
|
|
visible: true,
|
|
photo: mockPhoto,
|
|
onClose: jest.fn(),
|
|
};
|
|
|
|
it('should render Comments component when modal is visible', async () => {
|
|
render(<PhotoDetailModal {...defaultProps} />);
|
|
|
|
await waitFor(() => {
|
|
// Check if Comments section is rendered
|
|
expect(screen.getByText('评论')).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
it('should display photo information', async () => {
|
|
render(<PhotoDetailModal {...defaultProps} />);
|
|
|
|
await waitFor(() => {
|
|
expect(screen.getByText('test-photo.jpg')).toBeInTheDocument();
|
|
expect(screen.getByText('0.98 MB')).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
it('should not render when photo is null', () => {
|
|
render(<PhotoDetailModal {...defaultProps} photo={null} />);
|
|
|
|
// Modal should not render
|
|
expect(screen.queryByText('评论')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('should pass correct entityType and entityId to Comments', async () => {
|
|
const { container } = render(<PhotoDetailModal {...defaultProps} />);
|
|
|
|
await waitFor(() => {
|
|
// Verify the modal is rendered
|
|
expect(container.querySelector('.ant-modal')).toBeInTheDocument();
|
|
});
|
|
});
|
|
});
|