- Updated sidebar component to merge user data from Keycloak and Workspace, including avatar URLs. - Refactored nav-user component to utilize new avatar resolution logic and display user information more effectively. - Introduced a new utility function to resolve user avatar URLs, prioritizing Workspace avatars. - Implemented backend changes to support synchronization of user profile data, including avatar URLs from Workspace. - Added database migration to include new fields for Workspace profile synchronization in user_tenants. - Created a new client for fetching user profiles from Workspace. - Updated dashboard components to reflect changes in user data structure and avatar handling. - Removed avatar upload functionality from the profile update process, relying on Workspace for avatar management. - Added tests for avatar resolution logic to ensure correct prioritization of avatar sources.
25 lines
953 B
TypeScript
25 lines
953 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { resolveUserAvatarUrl } from './utils';
|
|
|
|
describe('resolveUserAvatarUrl', () => {
|
|
it('prioriza avatar de Workspace cuando es URL absoluta', () => {
|
|
const value = resolveUserAvatarUrl('https://hub.example.com/media/avatar.png', '/uploads/legacy.png');
|
|
expect(value).toBe('https://hub.example.com/media/avatar.png');
|
|
});
|
|
|
|
it('acepta avatar de Workspace relativo cuando no hay VITE_HUB_URL', () => {
|
|
const value = resolveUserAvatarUrl('/media/avatar.png', '/uploads/legacy.png');
|
|
expect(value).toBe('/media/avatar.png');
|
|
});
|
|
|
|
it('usa avatar legado cuando Workspace no existe', () => {
|
|
const value = resolveUserAvatarUrl(null, '/uploads/legacy.png');
|
|
expect(value).toBe('http://localhost:8000/uploads/legacy.png');
|
|
});
|
|
|
|
it('retorna vacio para fallback visual cuando no hay ninguna imagen', () => {
|
|
const value = resolveUserAvatarUrl(null, null);
|
|
expect(value).toBe('');
|
|
});
|
|
});
|