mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ADF-5582] Fix avatar rendering logic in adf-node-comments (#10995)
* [ADF-5582] Update NodeCommentsService to take userId as an argument in getUserImage * [ADF-5582] Add unit tests for avatar caching and retrieval in NodeCommentsService * Refactor NodeCommentsService unit tests to avoid accessing private members * [ADF-5582] Remove picture Id from getUserImage * [ADF-5582] Add comment to getAvatarCache and fix sonarcloud issues * Update node-comments.service.spec.ts * Trigger sonar * [ADF-5582] Add method to return avatar url in people api * [ADF-5582] Fix sonar cloud issue * [ADF-5582] Add comment to getUserImage and fix request address for getAvatarImageUrl
This commit is contained in:
@@ -38,7 +38,6 @@ describe('NodeCommentsService', () => {
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(NodeCommentsService);
|
||||
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
@@ -81,5 +80,17 @@ describe('NodeCommentsService', () => {
|
||||
responseText: JSON.stringify(fakeContentComments)
|
||||
});
|
||||
});
|
||||
|
||||
it('should return avatar image URL for given userId', () => {
|
||||
const userId = 'fake-user-id';
|
||||
const expectedUrl = 'https://fake-avatar-url.com/avatar.png';
|
||||
|
||||
spyOn(service.peopleApi, 'getAvatarImageUrl').and.returnValue(expectedUrl);
|
||||
|
||||
const result = service.getUserImage(userId);
|
||||
|
||||
expect(service.peopleApi.getAvatarImageUrl).toHaveBeenCalledWith(userId);
|
||||
expect(result).toBe(expectedUrl);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
*/
|
||||
|
||||
import { CommentModel, CommentsService, User } from '@alfresco/adf-core';
|
||||
import { CommentEntry, CommentsApi, Comment } from '@alfresco/js-api';
|
||||
import { CommentEntry, CommentsApi, Comment, PeopleApi } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ContentService } from '../../common/services/content.service';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -33,7 +32,13 @@ export class NodeCommentsService implements CommentsService {
|
||||
return this._commentsApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private contentService: ContentService) {}
|
||||
private _peopleApi: PeopleApi;
|
||||
get peopleApi(): PeopleApi {
|
||||
this._peopleApi = this._peopleApi ?? new PeopleApi(this.apiService.getInstance());
|
||||
return this._peopleApi;
|
||||
}
|
||||
|
||||
constructor(private readonly apiService: AlfrescoApiService) {}
|
||||
|
||||
/**
|
||||
* Gets all comments that have been added to a task.
|
||||
@@ -81,7 +86,13 @@ export class NodeCommentsService implements CommentsService {
|
||||
});
|
||||
}
|
||||
|
||||
getUserImage(avatarId: string): string {
|
||||
return this.contentService.getContentUrl(avatarId);
|
||||
/**
|
||||
* Gets the avatar image URL for a given user ID.
|
||||
*
|
||||
* @param userId ID of the user
|
||||
* @returns The URL of the user's avatar image
|
||||
*/
|
||||
getUserImage(userId: string): string {
|
||||
return this.peopleApi.getAvatarImageUrl(userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user