✅(frontend) add unit test for mobile rendering in docheaderinfo
ensures numchild count is displayed correctly on mobile interface Signed-off-by: Cyril <c.gromoff@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ and this project adheres to
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- ✨(frontend) enable ODT export for documents #1524
|
- ✨(frontend) enable ODT export for documents #1524
|
||||||
|
- ✨(frontend) improve mobile UX by showing subdocs count #1540
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
@@ -27,7 +28,6 @@ and this project adheres to
|
|||||||
- ✨(frontend) create skeleton component for DocEditor #1491
|
- ✨(frontend) create skeleton component for DocEditor #1491
|
||||||
- ✨(frontend) add an EmojiPicker in the document tree and title #1381
|
- ✨(frontend) add an EmojiPicker in the document tree and title #1381
|
||||||
- ✨(frontend) ajustable left panel #1456
|
- ✨(frontend) ajustable left panel #1456
|
||||||
- ✨(frontend) improve mobile UX by showing subdocs count #1540
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import React from 'react';
|
||||||
|
import { describe, expect, test, vi } from 'vitest';
|
||||||
|
|
||||||
|
import { AppWrapper } from '@/tests/utils';
|
||||||
|
|
||||||
|
// Force mobile layout so the children count is rendered
|
||||||
|
vi.mock('@/stores', () => ({
|
||||||
|
useResponsiveStore: () => ({ isDesktop: false }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Provide stable mocks for hooks used by the component
|
||||||
|
vi.mock('../../doc-management', async () => {
|
||||||
|
const actual = await vi.importActual<any>('../../doc-management');
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
useTrans: () => ({ transRole: vi.fn((r) => String(r)) }),
|
||||||
|
useIsCollaborativeEditable: () => ({ isEditable: true }),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.mock('@/core', () => ({
|
||||||
|
useConfig: () => ({ data: {} }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@/hook', () => ({
|
||||||
|
useDate: () => ({
|
||||||
|
relativeDate: () => 'yesterday',
|
||||||
|
calculateDaysLeft: () => 5,
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { DocHeaderInfo } from '../components/DocHeaderInfo';
|
||||||
|
|
||||||
|
describe('DocHeaderInfo', () => {
|
||||||
|
test('renders the number of sub-documents when numchild is provided (mobile layout)', () => {
|
||||||
|
const doc = {
|
||||||
|
numchild: 3,
|
||||||
|
updated_at: new Date().toISOString(),
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
render(<DocHeaderInfo doc={doc} />, { wrapper: AppWrapper });
|
||||||
|
|
||||||
|
expect(screen.getByText(/Contains 3 sub-documents/i)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user