mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-9546] knowledge retrieval question is repeated when new question is asked (#4555)
* [ACS-9546] Fixed repeating displayed question for knowledge retrieval * [ACS-9546] Fixed not displayed border around answer * [ACS-9546] Unit tests
This commit is contained in:
parent
b4530e43b9
commit
2be3b94077
@ -465,6 +465,13 @@ describe('SearchAiInputComponent', () => {
|
|||||||
submittingTrigger();
|
submittingTrigger();
|
||||||
expect(modalAiSpy).toHaveBeenCalledWith(jasmine.any(Function));
|
expect(modalAiSpy).toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call reset on queryControl', () => {
|
||||||
|
spyOn(component.queryControl, 'reset');
|
||||||
|
submittingTrigger();
|
||||||
|
|
||||||
|
expect(component.queryControl.reset).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -163,7 +163,7 @@ export class SearchAiInputComponent implements OnInit {
|
|||||||
this.modalAiService.openUnsavedChangesModal(() => this.search());
|
this.modalAiService.openUnsavedChangesModal(() => this.search());
|
||||||
}
|
}
|
||||||
|
|
||||||
search() {
|
private search(): void {
|
||||||
const error = this.searchAiService.checkSearchAvailability(this.selectedNodesState);
|
const error = this.searchAiService.checkSearchAvailability(this.selectedNodesState);
|
||||||
if (error) {
|
if (error) {
|
||||||
this.notificationService.showError(error);
|
this.notificationService.showError(error);
|
||||||
@ -175,6 +175,7 @@ export class SearchAiInputComponent implements OnInit {
|
|||||||
this.userPreferencesService.set(this.storedNodesKey, JSON.stringify(this.selectedNodesState));
|
this.userPreferencesService.set(this.storedNodesKey, JSON.stringify(this.selectedNodesState));
|
||||||
this.store.dispatch(new SearchByTermAiAction(payload));
|
this.store.dispatch(new SearchByTermAiAction(payload));
|
||||||
this.store.dispatch(new ToggleAISearchInput(this.agentControl.value.id, this.queryControl.value));
|
this.store.dispatch(new ToggleAISearchInput(this.agentControl.value.id, this.queryControl.value));
|
||||||
|
this.queryControl.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
padding: 18px 20px;
|
padding: 18px 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border: 1px solid var(--adf-card-view-border-color);
|
border: 1px solid var(--adf-theme-foreground-divider-color);
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
margin: 16px 0 75px;
|
margin: 16px 0 75px;
|
||||||
|
|
||||||
|
@ -108,6 +108,6 @@ describe('SidenavComponent', () => {
|
|||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
routerEvents$.next(mockNavigationEnd);
|
routerEvents$.next(mockNavigationEnd);
|
||||||
|
|
||||||
expect(navigationHistoryService.setHistory).toHaveBeenCalledWith(mockNavigationEnd, 3);
|
expect(navigationHistoryService.setHistory).toHaveBeenCalledWith(mockNavigationEnd);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -78,7 +78,7 @@ export class SidenavComponent implements OnInit {
|
|||||||
.listenToRouteChanges()
|
.listenToRouteChanges()
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe((event: NavigationEnd) => {
|
.subscribe((event: NavigationEnd) => {
|
||||||
this.navigationHistoryService.setHistory(event, 3);
|
this.navigationHistoryService.setHistory(event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,40 +46,13 @@ describe('NavigationHistoryService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should store route changes in history', () => {
|
it('should store route changes in history', () => {
|
||||||
service.listenToRouteChanges().subscribe((event) => service.setHistory(event, 3));
|
service.listenToRouteChanges().subscribe((event) => service.setHistory(event));
|
||||||
triggerNavigationEnd(1, '/page1');
|
triggerNavigationEnd(1, '/page1');
|
||||||
triggerNavigationEnd(2, '/page2');
|
triggerNavigationEnd(2, '/page2');
|
||||||
|
|
||||||
expect(service.history).toEqual(['/initial', '/page1', '/page2']);
|
expect(service.history).toEqual(['/initial', '/page1', '/page2']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not exceed the max history length', () => {
|
|
||||||
service.listenToRouteChanges().subscribe((event) => service.setHistory(event, 6));
|
|
||||||
|
|
||||||
triggerNavigationEnd(1, '/page1');
|
|
||||||
triggerNavigationEnd(2, '/page2');
|
|
||||||
triggerNavigationEnd(3, '/page3');
|
|
||||||
triggerNavigationEnd(4, '/page4');
|
|
||||||
triggerNavigationEnd(5, '/page5');
|
|
||||||
triggerNavigationEnd(6, '/page6');
|
|
||||||
|
|
||||||
expect(service.history).toEqual(['/page1', '/page2', '/page3', '/page4', '/page5', '/page6']);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should store different route changes in history', () => {
|
|
||||||
service.listenToRouteChanges().subscribe((event) => service.setHistory(event, 4));
|
|
||||||
triggerNavigationEnd(1, '/page1');
|
|
||||||
triggerNavigationEnd(2, '/page2');
|
|
||||||
triggerNavigationEnd(3, '/page1');
|
|
||||||
triggerNavigationEnd(4, '/page2');
|
|
||||||
triggerNavigationEnd(5, '/page4');
|
|
||||||
triggerNavigationEnd(6, '/page2');
|
|
||||||
triggerNavigationEnd(7, '/page1');
|
|
||||||
triggerNavigationEnd(8, '/page2');
|
|
||||||
|
|
||||||
expect(service.history).toEqual(['/page4', '/page2', '/page1', '/page2']);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true for a valid last selection', () => {
|
it('should return true for a valid last selection', () => {
|
||||||
service.history = ['/page1', '/page2', '/page1'];
|
service.history = ['/page1', '/page2', '/page1'];
|
||||||
|
|
||||||
@ -92,13 +65,31 @@ describe('NavigationHistoryService', () => {
|
|||||||
expect(service.shouldReturnLastSelection('/page2')).toBeFalse();
|
expect(service.shouldReturnLastSelection('/page2')).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return true for a valid last selection when before first relevant url and before last url there are multiple urls', () => {
|
||||||
|
service.history = ['/page1', '/page2', '/page3', '/page4', '/page4', '/page3'];
|
||||||
|
|
||||||
|
expect(service.shouldReturnLastSelection('/page4')).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for an invalid last selection when before first relevant url and before last url there are multiple urls', () => {
|
||||||
|
service.history = ['/page1', '/page2', '/page3', '/page4', '/page4', '/page3'];
|
||||||
|
|
||||||
|
expect(service.shouldReturnLastSelection('/page5')).toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false for an invalid last url when before first relevant url and before last url there are multiple urls', () => {
|
||||||
|
service.history = ['/page1', '/page2', '/page3', '/page4', '/page4', '/page5'];
|
||||||
|
|
||||||
|
expect(service.shouldReturnLastSelection('/page4')).toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
it('should initialize history with the current route', () => {
|
it('should initialize history with the current route', () => {
|
||||||
service.listenToRouteChanges().subscribe((event) => service.setHistory(event, 3));
|
service.listenToRouteChanges().subscribe((event) => service.setHistory(event));
|
||||||
expect(service.history).toEqual(['/initial']);
|
expect(service.history).toEqual(['/initial']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should only store NavigationEnd events in history', () => {
|
it('should only store NavigationEnd events in history', () => {
|
||||||
service.listenToRouteChanges().subscribe((event) => service.setHistory(event, 3));
|
service.listenToRouteChanges().subscribe((event) => service.setHistory(event));
|
||||||
routerEvents$.next(new NavigationStart(1, '/page-start'));
|
routerEvents$.next(new NavigationStart(1, '/page-start'));
|
||||||
routerEvents$.next(new NavigationEnd(1, '/page1', '/page1'));
|
routerEvents$.next(new NavigationEnd(1, '/page1', '/page1'));
|
||||||
|
|
||||||
|
@ -41,13 +41,17 @@ export class NavigationHistoryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldReturnLastSelection(url: string): boolean {
|
shouldReturnLastSelection(url: string): boolean {
|
||||||
return this.history.length > 2 && this.history[1].startsWith(url) && this.history[0] === this.history[2];
|
return (
|
||||||
|
this.history.length > 2 &&
|
||||||
|
this.history[this.history.length - 2].startsWith(url) &&
|
||||||
|
[...this.history]
|
||||||
|
.reverse()
|
||||||
|
.slice(1)
|
||||||
|
.find((oldUrl) => !oldUrl.startsWith(url)) === this.history[this.history.length - 1]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setHistory(event: NavigationEnd, maxHistoryLength: number) {
|
setHistory(event: NavigationEnd): void {
|
||||||
this.history.push(event.urlAfterRedirects);
|
this.history.push(event.urlAfterRedirects);
|
||||||
if (maxHistoryLength > 0 && this.history.length > maxHistoryLength) {
|
|
||||||
this.history.shift();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user