diff --git a/CHANGELOG.md b/CHANGELOG.md index ddb0c215..a4300198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to ### Added - ✨(frontend) enable ODT export for documents #1524 +- ✨(frontend) improve mobile UX by showing subdocs count #1540 ### Fixed @@ -27,7 +28,6 @@ and this project adheres to - ✨(frontend) create skeleton component for DocEditor #1491 - ✨(frontend) add an EmojiPicker in the document tree and title #1381 - ✨(frontend) ajustable left panel #1456 -- ✨(frontend) improve mobile UX by showing subdocs count #1540 ### Changed diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/__tests__/DocHeaderInfo.spec.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/__tests__/DocHeaderInfo.spec.tsx new file mode 100644 index 00000000..93f1a499 --- /dev/null +++ b/src/frontend/apps/impress/src/features/docs/doc-header/__tests__/DocHeaderInfo.spec.tsx @@ -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('../../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(, { wrapper: AppWrapper }); + + expect(screen.getByText(/Contains 3 sub-documents/i)).toBeInTheDocument(); + }); +});