Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✅ test(user): expect the generated avatar fallback instead of initials (#21508)

Arvin Xu89de6f1ff2c6
diff --git a/src/features/User/__tests__/UserAvatar.test.tsx b/src/features/User/__tests__/UserAvatar.test.tsx
index 80b40094024..2faf19fd787 100644
--- a/src/features/User/__tests__/UserAvatar.test.tsx
+++ b/src/features/User/__tests__/UserAvatar.test.tsx
@@ -36,8 +36,11 @@ describe('UserAvatar', () => {
});
render(<UserAvatar />);
- // When user has no avatar url, <Avatar /> falls back to initials rendering (not an <img />)
- expect(screen.getByText('TE')).toBeInTheDocument();
+ // With no avatar url, <Avatar /> draws a fallback generated from the name: an <svg>
+ // labelled with the username, not an <img />
+ const fallback = screen.getByRole('img', { name: mockUsername });
+ expect(fallback.tagName.toLowerCase()).toBe('svg');
+ expect(screen.queryByAltText(mockUsername)).not.toBeInTheDocument();
});
it('should show LobeChat and default avatar when the user is not logged in', () => {