mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2465] Sometimes, navigating using the breadcrumb opens another folder instead of the clicked one - after search performed on the Content Node Selector (#3054)
* [ADF-2465] Sometimes, navigating using the breadcrumb opens another folder instead of the clicked one - after search performed on the Content Node Selector fixed bug added tests made sure that deleting search input field clears all search related data * [ADF-2465] change tests not to use setTimeouts
This commit is contained in:
committed by
Eugenio Romano
parent
6dc758889f
commit
3a68382be0
@@ -38,7 +38,7 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
<adf-dropdown-breadcrumb *ngIf="needBreadcrumbs()"
|
<adf-dropdown-breadcrumb *ngIf="needBreadcrumbs()"
|
||||||
class="adf-content-node-selector-content-breadcrumb"
|
class="adf-content-node-selector-content-breadcrumb"
|
||||||
(navigate)="clear()"
|
(navigate)="clearSearch()"
|
||||||
[target]="documentList"
|
[target]="documentList"
|
||||||
[transform]="breadcrumbTransform"
|
[transform]="breadcrumbTransform"
|
||||||
[folderNode]="breadcrumbFolderNode"
|
[folderNode]="breadcrumbFolderNode"
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { MinimalNodeEntryEntity, SiteEntry, SitePaging } from 'alfresco-js-api';
|
import { MinimalNodeEntryEntity, SiteEntry, SitePaging } from 'alfresco-js-api';
|
||||||
import {
|
import {
|
||||||
@@ -54,6 +54,7 @@ const ONE_FOLDER_RESULT = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('ContentNodeSelectorComponent', () => {
|
describe('ContentNodeSelectorComponent', () => {
|
||||||
|
const debounceSearch = 200;
|
||||||
let component: ContentNodeSelectorPanelComponent;
|
let component: ContentNodeSelectorPanelComponent;
|
||||||
let fixture: ComponentFixture<ContentNodeSelectorPanelComponent>;
|
let fixture: ComponentFixture<ContentNodeSelectorPanelComponent>;
|
||||||
let searchService: SearchService;
|
let searchService: SearchService;
|
||||||
@@ -483,6 +484,44 @@ describe('ContentNodeSelectorComponent', () => {
|
|||||||
expect(component.showingSearchResults).toBeFalsy();
|
expect(component.showingSearchResults).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should clear the search field, nodes and chosenNode when deleting the search input', fakeAsync(() => {
|
||||||
|
spyOn(component, 'clear').and.callThrough();
|
||||||
|
typeToSearchBox('a');
|
||||||
|
|
||||||
|
tick(debounceSearch);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(searchSpy.calls.count()).toBe(1);
|
||||||
|
|
||||||
|
typeToSearchBox('');
|
||||||
|
|
||||||
|
tick(debounceSearch);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(searchSpy.calls.count()).toBe(1, 'no other search has been performed');
|
||||||
|
expect(component.clear).toHaveBeenCalled();
|
||||||
|
expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku', 'back to the folder in which the search was performed');
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should clear the search field, nodes and chosenNode on folder navigation in the results list', fakeAsync(() => {
|
||||||
|
spyOn(component, 'clearSearch').and.callThrough();
|
||||||
|
typeToSearchBox('a');
|
||||||
|
|
||||||
|
tick(debounceSearch);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
respondWithSearchResults(ONE_FOLDER_RESULT);
|
||||||
|
|
||||||
|
tick();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.onFolderChange();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.clearSearch).toHaveBeenCalled();
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
it('should show nodes from the same folder as selected in the dropdown on clearing the search input', (done) => {
|
it('should show nodes from the same folder as selected in the dropdown on clearing the search input', (done) => {
|
||||||
typeToSearchBox('piccolo');
|
typeToSearchBox('piccolo');
|
||||||
|
|
||||||
|
@@ -205,15 +205,22 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the search input
|
* Clear the search input and reset to last folder node in which search was performed
|
||||||
*/
|
*/
|
||||||
clear(): void {
|
clear(): void {
|
||||||
|
this.clearSearch();
|
||||||
|
this.folderIdToShow = this.siteId || this.currentFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the search input and search related data
|
||||||
|
*/
|
||||||
|
clearSearch() {
|
||||||
this.searchTerm = '';
|
this.searchTerm = '';
|
||||||
this.nodes = null;
|
this.nodes = null;
|
||||||
this.skipCount = 0;
|
this.skipCount = 0;
|
||||||
this.chosenNode = null;
|
this.chosenNode = null;
|
||||||
this.showingSearchResults = false;
|
this.showingSearchResults = false;
|
||||||
this.folderIdToShow = this.siteId || this.currentFolderId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -221,7 +228,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
private updateResults(): void {
|
private updateResults(): void {
|
||||||
if (this.searchTerm.length === 0) {
|
if (this.searchTerm.length === 0) {
|
||||||
this.folderIdToShow = this.siteId || this.currentFolderId;
|
this.clear();
|
||||||
} else {
|
} else {
|
||||||
this.startNewSearch();
|
this.startNewSearch();
|
||||||
}
|
}
|
||||||
@@ -306,9 +313,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
|
|||||||
* Sets showingSearchResults state to be able to differentiate between search results or folder results
|
* Sets showingSearchResults state to be able to differentiate between search results or folder results
|
||||||
*/
|
*/
|
||||||
onFolderChange(): void {
|
onFolderChange(): void {
|
||||||
this.skipCount = 0;
|
|
||||||
this.infiniteScroll = false;
|
this.infiniteScroll = false;
|
||||||
this.showingSearchResults = false;
|
this.clearSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user