[ACS-9564] Fix rendering of Knowledge Retrieval answer after change in answer structure

This commit is contained in:
Aleksander Sklorz
2025-04-24 10:44:16 +02:00
parent 5a168fa0c2
commit 3acb1f3b5a
2 changed files with 15 additions and 3 deletions

View File

@@ -46,7 +46,14 @@ import { searchAiMarkedOptions } from './search-ai-marked-options';
const questionMock: QuestionModel = { question: 'test', questionId: 'testId', restrictionQuery: { nodesIds: [] } };
const getAiAnswerEntry = (noAnswer?: boolean): AiAnswerEntry => {
return { entry: { answer: noAnswer ? '' : 'Some answer', questionId: 'some id', references: [] } };
return {
entry: {
answer: noAnswer ? '' : 'Some answer',
question: 'some question',
objectReferences: [],
complete: true
}
};
};
describe('SearchAiResultsComponent', () => {
@@ -512,7 +519,12 @@ describe('SearchAiResultsComponent', () => {
spyOn(userPreferencesService, 'set');
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
const answer = getAiAnswerEntry();
answer.entry.references = [{ referenceId: nodeId, referenceText: 'some text' }];
answer.entry.objectReferences = [
{
objectId: nodeId,
references: []
}
];
spyOn(searchAiService, 'getAnswer').and.returnValues(throwError('error'), of(answer));
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });

View File

@@ -198,7 +198,7 @@ export class SearchAiResultsComponent extends PageComponent implements OnInit {
}
this.queryAnswer = response.entry;
this._displayedAnswer = this.preprocessMarkdownFormat(response.entry.answer);
return forkJoin(this.queryAnswer.references.map((reference) => this.nodesApiService.getNode(reference.referenceId)));
return forkJoin(this.queryAnswer.objectReferences.map((reference) => this.nodesApiService.getNode(reference.objectId)));
}),
retryWhen((errors: Observable<Error>) => this.aiSearchRetryWhen(errors)),
finalize(() => (this._loading = false)),