mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 13:57:38 +00:00
* feat(webui): add simplified mobile-friendly layout for file and share lists * refactor(webui): switch mobile file list layout to 1-column grid * feat(webui): show foldertree by default in child sidebar and add close button * feat(webui): add collapsible section headers and fix folder card full-width on mobile * feat(webui): improve mobile breadcrumb bar with middle truncation and dual ellipsis * fix(webui): unify breadcrumb DOM structure across desktop and mobile * fix(webui): remove unused breadcrumbs variable in BreadcrumbNav * fix(webui): complete and confirm file uploads on mobile and handle errors properly * fix(webui): remove active scale animation on mobile FAB to stabilize dropdown menu anchor * refactor(webui): use PresignedUrl type from dtos for uploadFiles and eliminate any cast * fix(webui): scope folder card max width to desktop with responsive md:max-w-[340px]
112 lines
3.3 KiB
TypeScript
112 lines
3.3 KiB
TypeScript
// @vitest-environment happy-dom
|
|
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
|
import React from 'react'
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { DualSidebar, DualSidebarItem } from './dual-sidebar'
|
|
import { useDualSidebarStore } from '@/ui/stores/dual-sidebar'
|
|
|
|
vi.mock('@tanstack/react-router', () => ({
|
|
useRouterState: () => '/projects/proj-1',
|
|
}))
|
|
|
|
vi.mock('./user-menu', () => ({
|
|
UserMenu: () => <div data-testid="user-menu">User</div>,
|
|
}))
|
|
|
|
describe('DualSidebar component', () => {
|
|
beforeEach(() => {
|
|
useDualSidebarStore.setState({
|
|
isMobileMenuOpen: false,
|
|
activeItem: null,
|
|
activeItemId: null,
|
|
})
|
|
})
|
|
|
|
afterEach(() => {
|
|
cleanup()
|
|
})
|
|
|
|
it('renders Level 1 icons and UserMenu', () => {
|
|
render(
|
|
<DualSidebar>
|
|
<DualSidebarItem icon={<span>HomeIcon</span>} label="Home" />
|
|
<DualSidebarItem icon={<span>NotifIcon</span>} label="Notifications">
|
|
<div>Notification List</div>
|
|
</DualSidebarItem>
|
|
</DualSidebar>,
|
|
)
|
|
|
|
expect(screen.getByLabelText('Home')).toBeDefined()
|
|
expect(screen.getByLabelText('Notifications')).toBeDefined()
|
|
expect(screen.getByTestId('user-menu')).toBeDefined()
|
|
})
|
|
|
|
it('displays defaultMobileContent when mobile menu is open and no active item is selected', () => {
|
|
useDualSidebarStore.setState({ isMobileMenuOpen: true })
|
|
|
|
render(
|
|
<DualSidebar
|
|
defaultMobileContent={{
|
|
label: 'Project Folders',
|
|
children: <div>Folder Tree Content</div>,
|
|
}}
|
|
>
|
|
<DualSidebarItem icon={<span>HomeIcon</span>} label="Home" />
|
|
<DualSidebarItem icon={<span>NotifIcon</span>} label="Notifications">
|
|
<div>Notification List</div>
|
|
</DualSidebarItem>
|
|
</DualSidebar>,
|
|
)
|
|
|
|
expect(screen.getByText('Project Folders')).toBeDefined()
|
|
expect(screen.getByText('Folder Tree Content')).toBeDefined()
|
|
})
|
|
|
|
it('switches to child item content when a Level 1 icon is clicked', () => {
|
|
useDualSidebarStore.setState({ isMobileMenuOpen: true })
|
|
|
|
render(
|
|
<DualSidebar
|
|
defaultMobileContent={{
|
|
label: 'Project Folders',
|
|
children: <div>Folder Tree Content</div>,
|
|
}}
|
|
>
|
|
<DualSidebarItem icon={<span>HomeIcon</span>} label="Home" />
|
|
<DualSidebarItem icon={<span>NotifIcon</span>} label="Notifications">
|
|
<div>Notification List</div>
|
|
</DualSidebarItem>
|
|
</DualSidebar>,
|
|
)
|
|
|
|
const notifBtn = screen.getByLabelText('Notifications')
|
|
act(() => {
|
|
fireEvent.click(notifBtn)
|
|
})
|
|
|
|
expect(screen.getByText('Notification List')).toBeDefined()
|
|
})
|
|
|
|
it('closes mobile menu when close (X) button is clicked', () => {
|
|
useDualSidebarStore.setState({ isMobileMenuOpen: true })
|
|
|
|
render(
|
|
<DualSidebar
|
|
defaultMobileContent={{
|
|
label: 'Project Folders',
|
|
children: <div>Folder Tree Content</div>,
|
|
}}
|
|
>
|
|
<DualSidebarItem icon={<span>HomeIcon</span>} label="Home" />
|
|
</DualSidebar>,
|
|
)
|
|
|
|
const closeButton = screen.getByRole('button', { name: /Close navigation menu/i })
|
|
act(() => {
|
|
fireEvent.click(closeButton)
|
|
})
|
|
|
|
expect(useDualSidebarStore.getState().isMobileMenuOpen).toBe(false)
|
|
})
|
|
})
|