dify/web/app/components/header/app-back/__tests__/index.spec.tsx
Coding On Star 6da802eb2a
refactor(custom): reorganize web app brand module and raise coverage threshold (#33531)
Co-authored-by: CodingOnStar <hanxujiang@dify.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-03-16 18:17:21 +08:00

37 lines
1.1 KiB
TypeScript

import type { App } from '@/types/app'
import { fireEvent, render, screen } from '@testing-library/react'
import AppBack from '../index'
describe('AppBack', () => {
const mockApp = {
id: 'test-app',
name: 'Test App',
} as App
it('should render apps label', () => {
render(<AppBack curApp={mockApp} />)
expect(screen.getByText('common.menus.apps')).toBeInTheDocument()
})
it('should keep apps label visible while hovering', () => {
render(<AppBack curApp={mockApp} />)
const label = screen.getByText('common.menus.apps')
fireEvent.mouseEnter(label)
expect(label).toBeInTheDocument()
fireEvent.mouseLeave(label)
expect(label).toBeInTheDocument()
})
it('should render with different apps', () => {
const app1 = { id: 'app-1' } as App
const app2 = { id: 'app-2' } as App
const { rerender } = render(<AppBack curApp={app1} />)
expect(screen.getByText('common.menus.apps')).toBeInTheDocument()
rerender(<AppBack curApp={app2} />)
expect(screen.getByText('common.menus.apps')).toBeInTheDocument()
})
})