mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5177] Search-header execute when enter is pressed (#5840)
* [ADF-5177] Filter execute on enter key down * [ADF-5177] Add unit test
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<div (click)="onMenuClick($event)" class="adf-filter-container">
|
||||
<div class="adf-filter-title">{{ 'SEARCH.SEARCH_HEADER.TITLE' | translate }}</div>
|
||||
<adf-search-widget-container
|
||||
(keydown.enter)="onApply()"
|
||||
[id]="category?.id"
|
||||
[selector]="category?.component?.selector"
|
||||
[settings]="category?.component?.settings">
|
||||
@@ -28,7 +29,7 @@
|
||||
</button>
|
||||
<button mat-button color="primary"
|
||||
id="apply-filter-button"
|
||||
class="adf-filter-apply-button" (click)="onApplyButtonClick()">
|
||||
class="adf-filter-apply-button" (click)="onApply()">
|
||||
{{ 'SEARCH.SEARCH_HEADER.APPLY' | translate | uppercase }}
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
|
@@ -84,7 +84,7 @@ describe('SearchHeaderComponent', () => {
|
||||
expect(element).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it('should emit the node paging received from the queryBuilder after the filter gets applied', async (done) => {
|
||||
it('should emit the node paging received from the queryBuilder after the Apply button is clicked', async (done) => {
|
||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
||||
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
||||
component.update.subscribe((newNodePaging) => {
|
||||
@@ -102,6 +102,24 @@ describe('SearchHeaderComponent', () => {
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should emit the node paging received from the queryBuilder after the Enter key is pressed', async (done) => {
|
||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
||||
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
||||
component.update.subscribe((newNodePaging) => {
|
||||
expect(newNodePaging).toBe(fakeNodePaging);
|
||||
done();
|
||||
});
|
||||
const menuButton: HTMLButtonElement = fixture.nativeElement.querySelector('#filter-menu-button');
|
||||
menuButton.click();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
component.widgetContainer.componentRef.instance.value = 'searchText';
|
||||
const widgetContainer = fixture.debugElement.query(By.css('adf-search-widget-container'));
|
||||
widgetContainer.triggerEventHandler('keydown.enter', {});
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should execute a new query when the page size is changed', async (done) => {
|
||||
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
|
||||
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
|
||||
|
@@ -128,7 +128,7 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
onApplyButtonClick() {
|
||||
onApply() {
|
||||
// TODO Move this piece of code in the search text widget
|
||||
if (this.widgetContainer.selector === 'text' && this.widgetContainer.componentRef.instance.value === '') {
|
||||
this.clearHeader();
|
||||
|
Reference in New Issue
Block a user