mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-8769] Removed mocked avatars and replaced with loading them from backend (#4207)
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 96 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB |
+10
-4
@@ -81,7 +81,6 @@ describe('AgentsButtonComponent', () => {
|
|||||||
notificationService = TestBed.inject(NotificationService);
|
notificationService = TestBed.inject(NotificationService);
|
||||||
spyOn(notificationService, 'showError');
|
spyOn(notificationService, 'showError');
|
||||||
message = 'Some message';
|
message = 'Some message';
|
||||||
component.avatarsMocked = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const getMenuTrigger = (): MatMenuPanel => fixture.debugElement.query(By.directive(MatMenuTrigger)).injector.get(MatMenuTrigger).menu;
|
const getMenuTrigger = (): MatMenuPanel => fixture.debugElement.query(By.directive(MatMenuTrigger)).injector.get(MatMenuTrigger).menu;
|
||||||
@@ -226,7 +225,6 @@ describe('AgentsButtonComponent', () => {
|
|||||||
|
|
||||||
describe('loaded config', () => {
|
describe('loaded config', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.avatarsMocked = false;
|
|
||||||
config$.next({
|
config$.next({
|
||||||
entry: {
|
entry: {
|
||||||
knowledgeRetrievalUrl
|
knowledgeRetrievalUrl
|
||||||
@@ -337,7 +335,6 @@ describe('AgentsButtonComponent', () => {
|
|||||||
let loader: HarnessLoader;
|
let loader: HarnessLoader;
|
||||||
|
|
||||||
const prepareData = (agents: Agent[]): void => {
|
const prepareData = (agents: Agent[]): void => {
|
||||||
component.avatarsMocked = false;
|
|
||||||
config$.next({
|
config$.next({
|
||||||
entry: {
|
entry: {
|
||||||
knowledgeRetrievalUrl
|
knowledgeRetrievalUrl
|
||||||
@@ -431,9 +428,18 @@ describe('AgentsButtonComponent', () => {
|
|||||||
expect(getAvatar('1').initials).toBe('HA');
|
expect(getAvatar('1').initials).toBe('HA');
|
||||||
expect(getAvatar('2').initials).toBe('PA');
|
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', () => {
|
it('should assign correct initials to each avatar for each agent with single section name', () => {
|
||||||
agentsMock = [
|
agentsMock = [
|
||||||
{
|
{
|
||||||
|
|||||||
-6
@@ -36,7 +36,6 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
|||||||
import { Agent } from '@alfresco/js-api';
|
import { Agent } from '@alfresco/js-api';
|
||||||
import { AgentService, SearchAiService } from '@alfresco/adf-content-services';
|
import { AgentService, SearchAiService } from '@alfresco/adf-content-services';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { getAgentsWithMockedAvatars } from '../search-ai-utils';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@@ -58,8 +57,6 @@ export class AgentsButtonComponent implements OnInit, OnDestroy {
|
|||||||
private _initialsByAgentId: { [key: string]: string } = {};
|
private _initialsByAgentId: { [key: string]: string } = {};
|
||||||
private _hxInsightUrl: string;
|
private _hxInsightUrl: string;
|
||||||
|
|
||||||
avatarsMocked = true;
|
|
||||||
|
|
||||||
get agents(): Agent[] {
|
get agents(): Agent[] {
|
||||||
return this._agents;
|
return this._agents;
|
||||||
}
|
}
|
||||||
@@ -103,9 +100,6 @@ export class AgentsButtonComponent implements OnInit, OnDestroy {
|
|||||||
this._hxInsightUrl = result.config.entry.knowledgeRetrievalUrl;
|
this._hxInsightUrl = result.config.entry.knowledgeRetrievalUrl;
|
||||||
this._agents = result.agents;
|
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();
|
this.cd.detectChanges();
|
||||||
|
|
||||||
if (this.agents.length) {
|
if (this.agents.length) {
|
||||||
|
|||||||
+43
-17
@@ -47,21 +47,6 @@ import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dial
|
|||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { ModalAiService } from '../../../../services/modal-ai.service';
|
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', () => {
|
describe('SearchAiInputComponent', () => {
|
||||||
let component: SearchAiInputComponent;
|
let component: SearchAiInputComponent;
|
||||||
let fixture: ComponentFixture<SearchAiInputComponent>;
|
let fixture: ComponentFixture<SearchAiInputComponent>;
|
||||||
@@ -71,6 +56,7 @@ describe('SearchAiInputComponent', () => {
|
|||||||
let agents$: Subject<Agent[]>;
|
let agents$: Subject<Agent[]>;
|
||||||
let dialog: MatDialog;
|
let dialog: MatDialog;
|
||||||
let activatedRoute: ActivatedRoute;
|
let activatedRoute: ActivatedRoute;
|
||||||
|
let agentList: Agent[];
|
||||||
|
|
||||||
const prepareBeforeTest = (): void => {
|
const prepareBeforeTest = (): void => {
|
||||||
selectionState = {
|
selectionState = {
|
||||||
@@ -81,7 +67,6 @@ describe('SearchAiInputComponent', () => {
|
|||||||
};
|
};
|
||||||
store.overrideSelector(getAppSelection, selectionState);
|
store.overrideSelector(getAppSelection, selectionState);
|
||||||
component.agentId = '2';
|
component.agentId = '2';
|
||||||
component.avatarsMocked = false;
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
};
|
};
|
||||||
@@ -109,6 +94,20 @@ describe('SearchAiInputComponent', () => {
|
|||||||
loader = TestbedHarnessEnvironment.loader(fixture);
|
loader = TestbedHarnessEnvironment.loader(fixture);
|
||||||
agents$ = new Subject<Agent[]>();
|
agents$ = new Subject<Agent[]>();
|
||||||
dialog = TestBed.inject(MatDialog);
|
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$);
|
spyOn(TestBed.inject(AgentService), 'getAgents').and.returnValue(agents$);
|
||||||
prepareBeforeTest();
|
prepareBeforeTest();
|
||||||
});
|
});
|
||||||
@@ -170,11 +169,15 @@ describe('SearchAiInputComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have selected correct agent', async () => {
|
it('should have selected correct agent', async () => {
|
||||||
|
agentList[0].avatarUrl = 'some-url-1';
|
||||||
|
agentList[1].avatarUrl = 'some-url-2';
|
||||||
|
|
||||||
agents$.next(agentList);
|
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;
|
const avatar = selectElement.query(By.directive(AvatarComponent))?.componentInstance;
|
||||||
expect(avatar.initials).toBe('PA');
|
expect(avatar.initials).toBe('PA');
|
||||||
expect(avatar.size).toBe('26px');
|
expect(avatar.size).toBe('26px');
|
||||||
|
expect(avatar.src).toBe('some-url-2');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Agents options', () => {
|
describe('Agents options', () => {
|
||||||
@@ -210,6 +213,15 @@ describe('SearchAiInputComponent', () => {
|
|||||||
expect(getAvatarForAgent('2').initials).toBe('PA');
|
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', () => {
|
it('should assign correct initials to each avatar for each agent with single section name', () => {
|
||||||
const newAgentList = [
|
const newAgentList = [
|
||||||
{ ...agentList[0], name: 'Adam' },
|
{ ...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', () => {
|
describe('Query input', () => {
|
||||||
let queryInput: DebugElement;
|
let queryInput: DebugElement;
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -48,7 +48,6 @@ import {
|
|||||||
} from '@angular/material/tooltip';
|
} from '@angular/material/tooltip';
|
||||||
import { ModalAiService } from '../../../../services/modal-ai.service';
|
import { ModalAiService } from '../../../../services/modal-ai.service';
|
||||||
import { Agent } from '@alfresco/js-api';
|
import { Agent } from '@alfresco/js-api';
|
||||||
import { getAgentsWithMockedAvatars } from '../search-ai-utils';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
const MatTooltipOptions: MatTooltipDefaultOptions = {
|
const MatTooltipOptions: MatTooltipDefaultOptions = {
|
||||||
@@ -102,8 +101,6 @@ export class SearchAiInputComponent implements OnInit, OnDestroy {
|
|||||||
private _queryControl = new FormControl('');
|
private _queryControl = new FormControl('');
|
||||||
private _initialsByAgentId: { [key: string]: string } = {};
|
private _initialsByAgentId: { [key: string]: string } = {};
|
||||||
|
|
||||||
avatarsMocked = true;
|
|
||||||
|
|
||||||
get agentControl(): FormControl<Agent> {
|
get agentControl(): FormControl<Agent> {
|
||||||
return this._agentControl;
|
return this._agentControl;
|
||||||
}
|
}
|
||||||
@@ -156,8 +153,7 @@ export class SearchAiInputComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(agents) => {
|
(agents) => {
|
||||||
// TODO remove mocked avatar images after backend is done (https://hyland.atlassian.net/browse/ACS-8769)
|
this._agents = agents;
|
||||||
this._agents = getAgentsWithMockedAvatars(agents, this.avatarsMocked);
|
|
||||||
|
|
||||||
this.agentControl.setValue(this._agents.find((agent) => agent.id === this.agentId));
|
this.agentControl.setValue(this._agents.find((agent) => agent.id === this.agentId));
|
||||||
this._initialsByAgentId = this.agents.reduce((initials, agent) => {
|
this._initialsByAgentId = this.agents.reduce((initials, agent) => {
|
||||||
|
|||||||
-35
@@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user