diff --git a/web/app/components/base/app-icon/__tests__/index.spec.tsx b/web/app/components/base/app-icon/__tests__/index.spec.tsx index 4bbea1e0ae..54c1b8c361 100644 --- a/web/app/components/base/app-icon/__tests__/index.spec.tsx +++ b/web/app/components/base/app-icon/__tests__/index.spec.tsx @@ -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() + expect(document.querySelector('em-emoji')).toHaveTextContent('smile') + + rerender() + + expect(document.querySelector('em-emoji')).toHaveTextContent('robot') + }) + it('renders image when iconType is image and imageUrl is provided', () => { render() const imgElement = screen.getByAltText('app icon') diff --git a/web/app/components/base/app-icon/index.tsx b/web/app/components/base/app-icon/index.tsx index 5c15179446..b08ac5e981 100644 --- a/web/app/components/base/app-icon/index.tsx +++ b/web/app/components/base/app-icon/index.tsx @@ -104,7 +104,8 @@ const AppIcon: FC = ({ showEditIcon = false, }) => { const isValidImageIcon = iconType === 'image' && imageUrl - const Icon = (icon && icon !== '') ? : + const emojiIcon = (icon && icon !== '') ? icon : '🤖' + const Icon = const wrapperRef = useRef(null) const isHovering = useHover(wrapperRef)