mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[ADF-2128] facet container component (#3094)
* (wip) facet container * shaping out the API * code lint fixes * radiobox facet example * fields selector facet * search limits support * scope locations facet example * move custom search to 'search.query' config * use facet fields and queries from the config file * use facet filters * use facet buckets in query * preserve expanded/checked states * code cleanup and binding fixes * fix apis after rebase * extract query builder into separate class * code improvements * full chip list (merge facet fields with queries) * placeholder for range requests * move search infrastructure to ADF core * cleanup code * auto-search on init * move search components to the content services * selected facets chip list * split into separate components at ADF level * move the rest of the implementation to ADF * facet builder fixes and tests * translation support for category names * docs placeholders * update language level * unit tests and packaging updates * fix after rebase * remove fdescribe * some docs on search settings * rename components as per review * simplify chip list as per review * turn query builder into service * improve search service, integrate old search results * fix node selector integration * move service to the top module * update tests * remove fdescribe * update tests * test fixes * test fixes * test updates * fix tests * code and test fixes * remove fit * fix tests * fix tests * remove obsolete test * increase bundle threshold * update docs to reflect PR changes * fix docs
This commit is contained in:
committed by
Eugenio Romano
parent
d6f51c22aa
commit
ed48994e67
@@ -20,7 +20,6 @@ import { async, discardPeriodicTasks, fakeAsync, ComponentFixture, TestBed, tick
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AuthenticationService, SearchService } from '@alfresco/adf-core';
|
||||
import { ThumbnailService } from '@alfresco/adf-core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { noResult, results } from '../../mock';
|
||||
import { SearchControlComponent } from './search-control.component';
|
||||
import { SearchTriggerDirective } from './search-trigger.directive';
|
||||
@@ -83,9 +82,9 @@ describe('SearchControlComponent', () => {
|
||||
}));
|
||||
|
||||
it('should emit searchChange when search term input changed', async(() => {
|
||||
spyOn(searchService, 'search').and.callFake(() => {
|
||||
return Observable.of({ entry: { list: [] } });
|
||||
});
|
||||
spyOn(searchService, 'search').and.returnValue(
|
||||
Promise.resolve({ entry: { list: [] } })
|
||||
);
|
||||
component.searchChange.subscribe(value => {
|
||||
expect(value).toBe('customSearchTerm');
|
||||
});
|
||||
@@ -97,7 +96,7 @@ describe('SearchControlComponent', () => {
|
||||
it('should update FAYT search when user inputs a valid term', async(() => {
|
||||
typeWordIntoSearchInput('customSearchTerm');
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -111,7 +110,7 @@ describe('SearchControlComponent', () => {
|
||||
it('should NOT update FAYT term when user inputs an empty string as search term ', async(() => {
|
||||
typeWordIntoSearchInput('');
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -179,7 +178,7 @@ describe('SearchControlComponent', () => {
|
||||
});
|
||||
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
|
||||
fixture.detectChanges();
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
@@ -199,7 +198,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should make autocomplete list control visible when search box has focus and there is a search result', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
|
||||
typeWordIntoSearchInput('TEST');
|
||||
@@ -214,7 +213,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should show autocomplete list noe results when search box has focus and there is search result with length 0', async(() => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(noResult));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(noResult));
|
||||
fixture.detectChanges();
|
||||
|
||||
typeWordIntoSearchInput('NO RES');
|
||||
@@ -228,7 +227,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should hide autocomplete list results when the search box loses focus', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
@@ -249,7 +248,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should keep autocomplete list control visible when user tabs into results', async(() => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
@@ -269,7 +268,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should close the autocomplete when user press ESCAPE', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
@@ -293,7 +292,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should close the autocomplete when user press ENTER on input', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
@@ -317,7 +316,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should focus input element when autocomplete list is cancelled', async(() => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
@@ -333,7 +332,7 @@ describe('SearchControlComponent', () => {
|
||||
}));
|
||||
|
||||
it('should NOT display a autocomplete list control when configured not to', async(() => {
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
component.liveSearchEnabled = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -345,7 +344,7 @@ describe('SearchControlComponent', () => {
|
||||
}));
|
||||
|
||||
it('should select the first item on autocomplete list when ARROW DOWN is pressed on input', async(() => {
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
typeWordIntoSearchInput('TEST');
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
@@ -361,7 +360,7 @@ describe('SearchControlComponent', () => {
|
||||
}));
|
||||
|
||||
it('should select the second item on autocomplete list when ARROW DOWN is pressed on list', async(() => {
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
@@ -382,7 +381,7 @@ describe('SearchControlComponent', () => {
|
||||
}));
|
||||
|
||||
it('should focus the input search when ARROW UP is pressed on the first list item', (done) => {
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
fixture.detectChanges();
|
||||
let inputDebugElement = debugElement.query(By.css('#adf-control-input'));
|
||||
typeWordIntoSearchInput('TEST');
|
||||
@@ -494,7 +493,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should emit a option clicked event when item is clicked', async(() => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
component.optionClicked.subscribe((item) => {
|
||||
expect(item.entry.id).toBe('123');
|
||||
});
|
||||
@@ -510,7 +509,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should set deactivate the search after element is clicked', (done) => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
component.optionClicked.subscribe((item) => {
|
||||
window.setTimeout(() => {
|
||||
expect(component.subscriptAnimationState).toBe('inactive');
|
||||
@@ -530,7 +529,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
it('should NOT reset the search term after element is clicked', async(() => {
|
||||
spyOn(component, 'isSearchBarActive').and.returnValue(true);
|
||||
spyOn(searchService, 'search').and.returnValue(Observable.of(results));
|
||||
spyOn(searchService, 'search').and.returnValue(Promise.resolve(results));
|
||||
component.optionClicked.subscribe((item) => {
|
||||
expect(component.searchTerm).not.toBeFalsy();
|
||||
expect(component.searchTerm).toBe('TEST');
|
||||
@@ -585,7 +584,7 @@ describe('SearchControlComponent - No result custom', () => {
|
||||
it('should display the custom no results when it is configured', async(() => {
|
||||
const noResultCustomMessage = 'BANDI IS NOTHING';
|
||||
componentCustom.setCustomMessageForNoResult(noResultCustomMessage);
|
||||
spyOn(searchServiceCustom, 'search').and.returnValue(Observable.of(noResult));
|
||||
spyOn(searchServiceCustom, 'search').and.returnValue(Promise.resolve(noResult));
|
||||
fixtureCustom.detectChanges();
|
||||
|
||||
let inputDebugElement = fixtureCustom.debugElement.query(By.css('#adf-control-input'));
|
||||
|
Reference in New Issue
Block a user