mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-11033] ai answer references id mapping workaround (#5064)
* [ACS-11033] ai answer references id mapping workaround * [ACS-11033] remove redundant type
This commit is contained in:
+15
-2
@@ -541,13 +541,14 @@ describe('SearchAiResultsComponent', () => {
|
||||
}
|
||||
} as ResultSetPaging).pipe(delay(50));
|
||||
|
||||
const setupReferencesTest = (objectIds: string[] = [], searchResult: Observable<ResultSetPaging>[] = []) => {
|
||||
const setupReferencesTest = (objectIds: string[] = [], searchResult: Observable<ResultSetPaging>[] = [], hasNodeId = false) => {
|
||||
spyOn(contentApiService, 'search').and.returnValues(...searchResult);
|
||||
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
|
||||
|
||||
const answer = getAiAnswerEntry();
|
||||
answer.entry.objectReferences = objectIds.map((id) => ({
|
||||
objectId: id,
|
||||
objectId: `sourceId__${id}`,
|
||||
nodeId: hasNodeId ? `plain-${id}` : undefined,
|
||||
references: []
|
||||
}));
|
||||
|
||||
@@ -624,6 +625,18 @@ describe('SearchAiResultsComponent', () => {
|
||||
expect(unitTestingUtils.getByDataAutomationId(`aca-search-ai-results-${secondNodeId}-document`)).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should use nodeId when available when fetching references', fakeAsync(() => {
|
||||
setupReferencesTest([nodeId], [toSearchResult([node1])], true);
|
||||
expect(contentApiService.search).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
query: {
|
||||
query: `ID:"plain-${nodeId}"`,
|
||||
language: 'afts'
|
||||
}
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
describe('Reload References', () => {
|
||||
const getReloadButton = (): DebugElement =>
|
||||
unitTestingUtils.getByDataAutomationId('aca-search-ai-response-container-body-references-container-retry-references-loading-button');
|
||||
|
||||
+1
-1
@@ -293,7 +293,7 @@ export class SearchAiResultsComponent extends PageComponent implements OnInit {
|
||||
private fetchReferences(answer?: AiAnswer): Observable<Node[]> {
|
||||
this._hasReferencesLoadingError = false;
|
||||
|
||||
const objectIds = answer?.objectReferences?.map((reference) => reference.objectId);
|
||||
const objectIds = answer?.objectReferences?.map((reference) => reference.nodeId ?? reference.objectId.split('__')[1]);
|
||||
|
||||
if (!objectIds?.length) {
|
||||
return of([]);
|
||||
|
||||
Reference in New Issue
Block a user