[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:
Grzegorz Jaśkowski
2026-02-27 16:11:46 +01:00
committed by GitHub
parent 8fdf843ce7
commit acb832da6e
2 changed files with 16 additions and 3 deletions
@@ -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');
@@ -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([]);