diff --git a/projects/aca-content/assets/images/agent-avatar-blue.png b/projects/aca-content/assets/images/agent-avatar-blue.png deleted file mode 100644 index cfb695ab3f..0000000000 Binary files a/projects/aca-content/assets/images/agent-avatar-blue.png and /dev/null differ diff --git a/projects/aca-content/assets/images/agent-avatar-gold.png b/projects/aca-content/assets/images/agent-avatar-gold.png deleted file mode 100644 index 0298736e09..0000000000 Binary files a/projects/aca-content/assets/images/agent-avatar-gold.png and /dev/null differ diff --git a/projects/aca-content/assets/images/agent-avatar-pink.png b/projects/aca-content/assets/images/agent-avatar-pink.png deleted file mode 100644 index 9070620536..0000000000 Binary files a/projects/aca-content/assets/images/agent-avatar-pink.png and /dev/null differ diff --git a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.spec.ts b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.spec.ts index 49b6701404..9f954563bc 100644 --- a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.spec.ts +++ b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.spec.ts @@ -81,7 +81,6 @@ describe('AgentsButtonComponent', () => { notificationService = TestBed.inject(NotificationService); spyOn(notificationService, 'showError'); message = 'Some message'; - component.avatarsMocked = false; }); const getMenuTrigger = (): MatMenuPanel => fixture.debugElement.query(By.directive(MatMenuTrigger)).injector.get(MatMenuTrigger).menu; @@ -226,7 +225,6 @@ describe('AgentsButtonComponent', () => { describe('loaded config', () => { beforeEach(() => { - component.avatarsMocked = false; config$.next({ entry: { knowledgeRetrievalUrl @@ -337,7 +335,6 @@ describe('AgentsButtonComponent', () => { let loader: HarnessLoader; const prepareData = (agents: Agent[]): void => { - component.avatarsMocked = false; config$.next({ entry: { knowledgeRetrievalUrl @@ -431,9 +428,18 @@ describe('AgentsButtonComponent', () => { expect(getAvatar('1').initials).toBe('HA'); expect(getAvatar('2').initials).toBe('PA'); }); + + it('should assign correct src to each avatar', () => { + agentsMock[0].avatarUrl = 'some-url-1'; + agentsMock[1].avatarUrl = 'some-url-2'; + + fixture.detectChanges(); + expect(getAvatar('1').src).toBe('some-url-1'); + expect(getAvatar('2').src).toBe('some-url-2'); + }); }); - describe('Agents multi words name', () => { + describe('Agents single word name', () => { it('should assign correct initials to each avatar for each agent with single section name', () => { agentsMock = [ { diff --git a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.ts b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.ts index 4d36d8a04e..e216e561a3 100644 --- a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.ts +++ b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/agents-button/agents-button.component.ts @@ -36,7 +36,6 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { Agent } from '@alfresco/js-api'; import { AgentService, SearchAiService } from '@alfresco/adf-content-services'; import { MatTooltipModule } from '@angular/material/tooltip'; -import { getAgentsWithMockedAvatars } from '../search-ai-utils'; @Component({ standalone: true, @@ -58,8 +57,6 @@ export class AgentsButtonComponent implements OnInit, OnDestroy { private _initialsByAgentId: { [key: string]: string } = {}; private _hxInsightUrl: string; - avatarsMocked = true; - get agents(): Agent[] { return this._agents; } @@ -103,9 +100,6 @@ export class AgentsButtonComponent implements OnInit, OnDestroy { this._hxInsightUrl = result.config.entry.knowledgeRetrievalUrl; this._agents = result.agents; - // TODO remove mocked avatar images after backend is done (https://hyland.atlassian.net/browse/ACS-8769) - this._agents = getAgentsWithMockedAvatars(result.agents, this.avatarsMocked); - this.cd.detectChanges(); if (this.agents.length) { diff --git a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.spec.ts b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.spec.ts index 8a6ece244f..80aab55963 100644 --- a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.spec.ts +++ b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.spec.ts @@ -47,21 +47,6 @@ import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dial import { ActivatedRoute } from '@angular/router'; import { ModalAiService } from '../../../../services/modal-ai.service'; -const agentList: Agent[] = [ - { - id: '1', - name: 'HR Agent', - description: 'Test 1', - avatarUrl: undefined - }, - { - id: '2', - name: 'Policy Agent', - description: 'Test 2', - avatarUrl: undefined - } -]; - describe('SearchAiInputComponent', () => { let component: SearchAiInputComponent; let fixture: ComponentFixture; @@ -71,6 +56,7 @@ describe('SearchAiInputComponent', () => { let agents$: Subject; let dialog: MatDialog; let activatedRoute: ActivatedRoute; + let agentList: Agent[]; const prepareBeforeTest = (): void => { selectionState = { @@ -81,7 +67,6 @@ describe('SearchAiInputComponent', () => { }; store.overrideSelector(getAppSelection, selectionState); component.agentId = '2'; - component.avatarsMocked = false; component.ngOnInit(); fixture.detectChanges(); }; @@ -109,6 +94,20 @@ describe('SearchAiInputComponent', () => { loader = TestbedHarnessEnvironment.loader(fixture); agents$ = new Subject(); dialog = TestBed.inject(MatDialog); + agentList = [ + { + id: '1', + name: 'HR Agent', + description: 'Test 1', + avatarUrl: undefined + }, + { + id: '2', + name: 'Policy Agent', + description: 'Test 2', + avatarUrl: undefined + } + ]; spyOn(TestBed.inject(AgentService), 'getAgents').and.returnValue(agents$); prepareBeforeTest(); }); @@ -170,11 +169,15 @@ describe('SearchAiInputComponent', () => { }); it('should have selected correct agent', async () => { + agentList[0].avatarUrl = 'some-url-1'; + agentList[1].avatarUrl = 'some-url-2'; + agents$.next(agentList); - expect(await (await loader.getHarness(MatSelectHarness)).getValueText()).toBe('PAPolicy Agent'); + expect(await (await loader.getHarness(MatSelectHarness)).getValueText()).toBe('Policy Agent'); const avatar = selectElement.query(By.directive(AvatarComponent))?.componentInstance; expect(avatar.initials).toBe('PA'); expect(avatar.size).toBe('26px'); + expect(avatar.src).toBe('some-url-2'); }); describe('Agents options', () => { @@ -210,6 +213,15 @@ describe('SearchAiInputComponent', () => { expect(getAvatarForAgent('2').initials).toBe('PA'); }); + it('should have correct initials for avatars for each of agent', () => { + agentList[0].avatarUrl = 'some-url-1'; + agentList[1].avatarUrl = 'some-url-2'; + + fixture.detectChanges(); + expect(getAvatarForAgent('1').src).toBe('some-url-1'); + expect(getAvatarForAgent('2').src).toBe('some-url-2'); + }); + it('should assign correct initials to each avatar for each agent with single section name', () => { const newAgentList = [ { ...agentList[0], name: 'Adam' }, @@ -224,6 +236,20 @@ describe('SearchAiInputComponent', () => { }); }); + describe('Agents popup', () => { + it('should have selected correct agent', () => { + agentList[0].avatarUrl = 'some-url-1'; + agentList[1].avatarUrl = 'some-url-2'; + agents$.next(agentList); + + fixture.detectChanges(); + fixture.debugElement.query(By.css('.aca-search-ai-input-agent-container')).nativeElement.dispatchEvent(new MouseEvent('mouseenter')); + expect(fixture.debugElement.query(By.css('.aca-search-ai-input-agent-popup-hover-card-container-title adf-avatar')).componentInstance.src).toBe( + 'some-url-2' + ); + }); + }); + describe('Query input', () => { let queryInput: DebugElement; diff --git a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.ts b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.ts index 125ac0ef92..7516ea5011 100644 --- a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.ts +++ b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-input/search-ai-input.component.ts @@ -48,7 +48,6 @@ import { } from '@angular/material/tooltip'; import { ModalAiService } from '../../../../services/modal-ai.service'; import { Agent } from '@alfresco/js-api'; -import { getAgentsWithMockedAvatars } from '../search-ai-utils'; import { ActivatedRoute } from '@angular/router'; const MatTooltipOptions: MatTooltipDefaultOptions = { @@ -102,8 +101,6 @@ export class SearchAiInputComponent implements OnInit, OnDestroy { private _queryControl = new FormControl(''); private _initialsByAgentId: { [key: string]: string } = {}; - avatarsMocked = true; - get agentControl(): FormControl { return this._agentControl; } @@ -156,8 +153,7 @@ export class SearchAiInputComponent implements OnInit, OnDestroy { .pipe(takeUntil(this.onDestroy$)) .subscribe( (agents) => { - // TODO remove mocked avatar images after backend is done (https://hyland.atlassian.net/browse/ACS-8769) - this._agents = getAgentsWithMockedAvatars(agents, this.avatarsMocked); + this._agents = agents; this.agentControl.setValue(this._agents.find((agent) => agent.id === this.agentId)); this._initialsByAgentId = this.agents.reduce((initials, agent) => { diff --git a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-utils.ts b/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-utils.ts deleted file mode 100644 index 7a2118769e..0000000000 --- a/projects/aca-content/src/lib/components/knowledge-retrieval/search-ai/search-ai-utils.ts +++ /dev/null @@ -1,35 +0,0 @@ -/*! - * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Alfresco Example Content Application - * - * This file is part of the Alfresco Example Content Application. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * The Alfresco Example Content Application is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The Alfresco Example Content Application is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * from Hyland Software. If not, see . - */ - -import { Agent } from '@alfresco/js-api/typings'; - -export const getAgentsWithMockedAvatars = (agents: Agent[], mocked: boolean) => { - if (mocked) { - const images = ['assets/images/agent-avatar-blue.png', 'assets/images/agent-avatar-gold.png', 'assets/images/agent-avatar-pink.png']; - return agents.map((agent, index) => { - return { ...agent, avatarUrl: images[index > 2 ? 2 : index] }; - }); - } - return agents; -};