mirror of
https://github.com/langgenius/dify.git
synced 2026-06-07 16:32:01 +08:00
fix(web): app icon in webapp (#36206)
This commit is contained in:
parent
63946d829e
commit
ff02636a4b
@ -26,9 +26,8 @@ describe('AppIcon', () => {
|
||||
super()
|
||||
}
|
||||
|
||||
// Mock basic functionality
|
||||
connectedCallback() {
|
||||
this.innerHTML = '🤖'
|
||||
this.innerHTML = this.getAttribute('id') || '🤖'
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -51,6 +50,15 @@ describe('AppIcon', () => {
|
||||
expect(emojiElement?.getAttribute('id')).toBe('smile')
|
||||
})
|
||||
|
||||
it('updates the rendered emoji when icon changes', () => {
|
||||
const { rerender } = render(<AppIcon icon="smile" />)
|
||||
expect(document.querySelector('em-emoji')).toHaveTextContent('smile')
|
||||
|
||||
rerender(<AppIcon icon="robot" />)
|
||||
|
||||
expect(document.querySelector('em-emoji')).toHaveTextContent('robot')
|
||||
})
|
||||
|
||||
it('renders image when iconType is image and imageUrl is provided', () => {
|
||||
render(<AppIcon iconType="image" imageUrl="test-image.jpg" />)
|
||||
const imgElement = screen.getByAltText('app icon')
|
||||
|
||||
@ -104,7 +104,8 @@ const AppIcon: FC<AppIconProps> = ({
|
||||
showEditIcon = false,
|
||||
}) => {
|
||||
const isValidImageIcon = iconType === 'image' && imageUrl
|
||||
const Icon = (icon && icon !== '') ? <em-emoji id={icon} /> : <em-emoji id="🤖" />
|
||||
const emojiIcon = (icon && icon !== '') ? icon : '🤖'
|
||||
const Icon = <em-emoji key={emojiIcon} id={emojiIcon} />
|
||||
const wrapperRef = useRef<HTMLSpanElement>(null)
|
||||
const isHovering = useHover(wrapperRef)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user