mirror of
https://github.com/langgenius/dify.git
synced 2026-06-17 23:21:12 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: fatelei <fatelei@gmail.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import { vi } from 'vitest'
|
|
import { usePathname } from '@/next/navigation'
|
|
import HeaderWrapper from '../header-wrapper'
|
|
|
|
vi.mock('@/next/navigation', () => ({
|
|
usePathname: vi.fn(),
|
|
}))
|
|
|
|
describe('HeaderWrapper', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
localStorage.clear()
|
|
vi.mocked(usePathname).mockReturnValue('/test')
|
|
})
|
|
|
|
it('should render children correctly', () => {
|
|
render(
|
|
<HeaderWrapper>
|
|
<div data-testid="child">Test Child</div>
|
|
</HeaderWrapper>,
|
|
)
|
|
expect(screen.getByTestId('child')).toBeInTheDocument()
|
|
expect(screen.getByText('Test Child')).toBeInTheDocument()
|
|
})
|
|
|
|
it('should keep children mounted on workflow routes', () => {
|
|
vi.mocked(usePathname).mockReturnValue('/some/path/workflow')
|
|
render(
|
|
<HeaderWrapper>
|
|
<div>Workflow Content</div>
|
|
</HeaderWrapper>,
|
|
)
|
|
|
|
expect(screen.getByText('Workflow Content')).toBeInTheDocument()
|
|
})
|
|
|
|
it('should keep children mounted on pipeline routes', () => {
|
|
vi.mocked(usePathname).mockReturnValue('/some/path/pipeline')
|
|
|
|
render(
|
|
<HeaderWrapper>
|
|
<div>Pipeline Content</div>
|
|
</HeaderWrapper>,
|
|
)
|
|
|
|
expect(screen.getByText('Pipeline Content')).toBeInTheDocument()
|
|
})
|
|
|
|
it('should keep children mounted on non-canvas routes', () => {
|
|
vi.mocked(usePathname).mockReturnValue('/apps')
|
|
|
|
render(
|
|
<HeaderWrapper>
|
|
<div>App Content</div>
|
|
</HeaderWrapper>,
|
|
)
|
|
|
|
expect(screen.getByText('App Content')).toBeInTheDocument()
|
|
})
|
|
})
|