Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADF-5177] Search-header execute when enter is pressed #5840

Merged
merged 2 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down