mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Allow navigation to folders from search results (#1209)
* Allow navigation to folders from search results - Uses router to pass ID of the folder - Modified document list component to accept folder ID without path - Current limitations - Breadcrumb cannot currently be shown when navigating via folder id - Clicking between folders does not update the current route * Allow root folder ID to be changed and have documentlist reload - e.g switching from Company home to My Files * New tests for navigating to folders based on ID Refs #666
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ReflectiveInjector, SimpleChange } from '@angular/core';
|
||||
import { DebugElement, ReflectiveInjector, SimpleChange } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
@@ -256,44 +257,91 @@ describe('AlfrescoSearchComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('search result actions', () => {
|
||||
describe('search result interactions', () => {
|
||||
|
||||
it('should emit preview when file item clicked', (done) => {
|
||||
let debugElement: DebugElement;
|
||||
let searchService: AlfrescoSearchService;
|
||||
let querySpy: jasmine.Spy;
|
||||
let emitSpy: jasmine.Spy;
|
||||
const rowSelector = '[data-automation-id="search_result_table"] tbody tr';
|
||||
|
||||
let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
spyOn(searchService, 'getQueryNodesPromise')
|
||||
.and.returnValue(Promise.resolve(result));
|
||||
beforeEach(() => {
|
||||
debugElement = fixture.debugElement;
|
||||
searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
querySpy = spyOn(searchService, 'getQueryNodesPromise').and.returnValue(Promise.resolve(result));
|
||||
emitSpy = spyOn(component.navigate, 'emit');
|
||||
});
|
||||
|
||||
component.resultsLoad.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
(<HTMLTableRowElement> element.querySelector('#result_row_0')).click();
|
||||
describe('click results', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.navigationMode = AlfrescoSearchComponent.SINGLE_CLICK_NAVIGATION;
|
||||
});
|
||||
|
||||
component.searchTerm = 'searchTerm';
|
||||
component.ngOnInit();
|
||||
it('should emit navigation event when file item clicked', (done) => {
|
||||
|
||||
component.preview.subscribe(() => {
|
||||
done();
|
||||
component.resultsLoad.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
debugElement.query(By.css(rowSelector)).triggerEventHandler('click', {});
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.searchTerm = 'searchTerm';
|
||||
component.ngOnInit();
|
||||
});
|
||||
|
||||
it('should emit navigation event when non-file item is clicked', (done) => {
|
||||
|
||||
querySpy.and.returnValue(Promise.resolve(folderResult));
|
||||
|
||||
component.resultsLoad.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
debugElement.query(By.css(rowSelector)).triggerEventHandler('click', {});
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.searchTerm = 'searchTerm';
|
||||
component.ngOnInit();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not emit preview when non-file item is clicked', (done) => {
|
||||
describe('double click results', () => {
|
||||
|
||||
let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
|
||||
spyOn(searchService, 'getQueryNodesPromise')
|
||||
.and.returnValue(Promise.resolve(folderResult));
|
||||
|
||||
spyOn(component.preview, 'emit');
|
||||
component.resultsLoad.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
(<HTMLTableRowElement> element.querySelector('#result_row_0')).click();
|
||||
expect(component.preview.emit).not.toHaveBeenCalled();
|
||||
done();
|
||||
beforeEach(() => {
|
||||
component.navigationMode = AlfrescoSearchComponent.DOUBLE_CLICK_NAVIGATION;
|
||||
});
|
||||
|
||||
component.searchTerm = 'searchTerm';
|
||||
component.ngOnInit();
|
||||
it('should emit navigation event when file item clicked', (done) => {
|
||||
|
||||
component.resultsLoad.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
debugElement.query(By.css(rowSelector)).triggerEventHandler('dblclick', {});
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.searchTerm = 'searchTerm';
|
||||
component.ngOnInit();
|
||||
});
|
||||
|
||||
it('should emit navigation event when non-file item is clicked', (done) => {
|
||||
|
||||
querySpy.and.returnValue(Promise.resolve(folderResult));
|
||||
|
||||
component.resultsLoad.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
debugElement.query(By.css(rowSelector)).triggerEventHandler('dblclick', {});
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.searchTerm = 'searchTerm';
|
||||
component.ngOnInit();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user