mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-5514] Fix red dot still present after filter being cleared (#8181)
* [ADF-5514] Fix red dot still present after filter being cleared * Add unit test * Added statement clearing filter after each test so the ordering doesn't cause the unit test to fail
This commit is contained in:
parent
4c7e500ea8
commit
1a00249f6a
@ -74,6 +74,7 @@ describe('SearchFilterContainerComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
queryBuilder.removeActiveFilter(mockCategory.columnKey);
|
||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -150,6 +151,32 @@ describe('SearchFilterContainerComponent', () => {
|
|||||||
expect(eventRaised).toBe(true);
|
expect(eventRaised).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should hide the red dot after the filter is cleared', async () => {
|
||||||
|
const badge: HTMLElement = fixture.nativeElement.querySelector(`[data-automation-id="filter-menu-button"] .mat-badge-content`);
|
||||||
|
expect(window.getComputedStyle(badge).display).toBe('none');
|
||||||
|
|
||||||
|
const menuButton: HTMLButtonElement = fixture.nativeElement.querySelector('[data-automation-id="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('keypress', {key: 'Enter'});
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expect(window.getComputedStyle(badge).display).not.toBe('none');
|
||||||
|
|
||||||
|
menuButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
const fakeEvent = jasmine.createSpyObj('event', ['stopPropagation']);
|
||||||
|
const clearButton = fixture.debugElement.query(By.css('#clear-filter-button'));
|
||||||
|
clearButton.triggerEventHandler('click', fakeEvent);
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expect(window.getComputedStyle(badge).display).toBe('none');
|
||||||
|
});
|
||||||
|
|
||||||
describe('Accessibility', () => {
|
describe('Accessibility', () => {
|
||||||
|
|
||||||
it('should set up a focus trap on the filter when the menu is opened', async () => {
|
it('should set up a focus trap on the filter when the menu is opened', async () => {
|
||||||
|
@ -35,6 +35,7 @@ import { SearchCategory } from '../../models/search-category.interface';
|
|||||||
import { SEARCH_QUERY_SERVICE_TOKEN } from '../../search-query-service.token';
|
import { SEARCH_QUERY_SERVICE_TOKEN } from '../../search-query-service.token';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { MatMenuTrigger } from '@angular/material/menu';
|
import { MatMenuTrigger } from '@angular/material/menu';
|
||||||
|
import { FilterSearch } from '../../models/filter-search.interface';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-search-filter-container',
|
selector: 'adf-search-filter-container',
|
||||||
@ -119,7 +120,7 @@ export class SearchFilterContainerComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isActive(): boolean {
|
isActive(): boolean {
|
||||||
return this.widgetContainer && this.widgetContainer.componentRef && this.widgetContainer.componentRef.instance.isActive;
|
return this.searchFilterQueryBuilder.getActiveFilters().findIndex((f: FilterSearch) => f.key === this.category.columnKey) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMenuOpen() {
|
onMenuOpen() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user