mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
Answers endpoint fix (#4107)
This commit is contained in:
committed by
Aleksander Sklorz
parent
7817e21e35
commit
361c99a1f3
@@ -83,6 +83,7 @@ describe('SearchAiResultsComponent', () => {
|
|||||||
modalAiService = TestBed.inject(ModalAiService);
|
modalAiService = TestBed.inject(ModalAiService);
|
||||||
searchAiService = TestBed.inject(SearchAiService);
|
searchAiService = TestBed.inject(SearchAiService);
|
||||||
userPreferencesService = TestBed.inject(UserPreferencesService);
|
userPreferencesService = TestBed.inject(UserPreferencesService);
|
||||||
|
spyOn(searchAiService, 'ask').and.returnValue(of(questionMock));
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
});
|
});
|
||||||
@@ -138,7 +139,7 @@ describe('SearchAiResultsComponent', () => {
|
|||||||
|
|
||||||
it('should get query answer and not display an error when getAnswer throws one error and one successful response', fakeAsync(() => {
|
it('should get query answer and not display an error when getAnswer throws one error and one successful response', fakeAsync(() => {
|
||||||
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
|
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
|
||||||
spyOn(searchAiService, 'getAnswer').and.returnValues(throwError('error'), of(getAiAnswerEntry(true)));
|
spyOn(searchAiService, 'getAnswer').and.returnValues(throwError('error'), of(getAiAnswerEntry()));
|
||||||
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
||||||
|
|
||||||
tick(3000);
|
tick(3000);
|
||||||
@@ -149,7 +150,7 @@ describe('SearchAiResultsComponent', () => {
|
|||||||
|
|
||||||
it('should display and answer and not display an error when getAnswer throws nine errors and one successful response', fakeAsync(() => {
|
it('should display and answer and not display an error when getAnswer throws nine errors and one successful response', fakeAsync(() => {
|
||||||
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
|
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
|
||||||
spyOn(searchAiService, 'getAnswer').and.returnValues(...Array(9).fill(throwError('error')), of(getAiAnswerEntry(true)));
|
spyOn(searchAiService, 'getAnswer').and.returnValues(...Array(9).fill(throwError('error')), of(getAiAnswerEntry()));
|
||||||
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
||||||
|
|
||||||
tick(50000);
|
tick(50000);
|
||||||
@@ -184,7 +185,7 @@ describe('SearchAiResultsComponent', () => {
|
|||||||
|
|
||||||
it('should not display error and display and answer if received AiAnswerPaging without answer nine times and with answer one time', fakeAsync(() => {
|
it('should not display error and display and answer if received AiAnswerPaging without answer nine times and with answer one time', fakeAsync(() => {
|
||||||
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
|
spyOn(userPreferencesService, 'get').and.returnValue(knowledgeRetrievalNodes);
|
||||||
spyOn(searchAiService, 'getAnswer').and.returnValues(...Array(9).fill(of(getAiAnswerEntry(true))), of(getAiAnswerEntry(true)));
|
spyOn(searchAiService, 'getAnswer').and.returnValues(...Array(9).fill(of(getAiAnswerEntry(true))), of(getAiAnswerEntry()));
|
||||||
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
||||||
|
|
||||||
tick(30000);
|
tick(30000);
|
||||||
@@ -214,11 +215,9 @@ describe('SearchAiResultsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not display skeleton when loading is false', fakeAsync(() => {
|
it('should not display skeleton when loading is false', fakeAsync(() => {
|
||||||
|
spyOn(searchAiService, 'getAnswer').and.returnValue(of(getAiAnswerEntry()));
|
||||||
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
mockQueryParams.next({ query: 'test', agentId: 'agentId1' });
|
||||||
|
|
||||||
spyOn(searchAiService, 'ask').and.returnValue(of(questionMock));
|
|
||||||
spyOn(searchAiService, 'getAnswer').and.returnValue(of(getAiAnswerEntry(false)));
|
|
||||||
|
|
||||||
component.performAiSearch();
|
component.performAiSearch();
|
||||||
tick(30000);
|
tick(30000);
|
||||||
|
|
||||||
@@ -235,8 +234,7 @@ describe('SearchAiResultsComponent', () => {
|
|||||||
it('should open Unsaved Changes Modal and run callback successfully', () => {
|
it('should open Unsaved Changes Modal and run callback successfully', () => {
|
||||||
const modalAiSpy = spyOn(modalAiService, 'openUnsavedChangesModal').and.callThrough();
|
const modalAiSpy = spyOn(modalAiService, 'openUnsavedChangesModal').and.callThrough();
|
||||||
|
|
||||||
spyOn(searchAiService, 'ask').and.returnValue(of(questionMock));
|
spyOn(searchAiService, 'getAnswer').and.returnValue(of(getAiAnswerEntry()));
|
||||||
spyOn(searchAiService, 'getAnswer').and.returnValue(of(getAiAnswerEntry(true)));
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user