AAE 31996 refresh button on filters not working as expected (#10698)

* [AAE-31996] Refresh button on filters not working code fix test

* [AAE-31996] Altering the notification service for Refresh button

* [AAE-31996] Update typo in display-rich-text
This commit is contained in:
Soumyajit Chakraborty 2025-03-10 19:08:56 +05:30 committed by GitHub
parent f8f72edeb9
commit 946fe889e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 43 additions and 59 deletions

View File

@ -68,7 +68,7 @@ export class DisplayRichTextWidgetComponent extends WidgetComponent implements O
}
ngOnInit(): void {
this.parsedHTML = edjsHTML(DisplayRichTextWidgetComponent.CUSTOM_PARSER, { strict: true }).parse(this.field.value);
this.parsedHTML = edjsHTML(DisplayRichTextWidgetComponent.CUSTOM_PARSER, { strict: true }).parse(this.field.value);
if (!(this.parsedHTML instanceof Error)) {
this.sanitizeHtmlContent();

View File

@ -16,8 +16,8 @@
*/
import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { of, throwError } from 'rxjs';
import { ComponentFixture, fakeAsync, flush, TestBed } from '@angular/core/testing';
import { first, of, throwError } from 'rxjs';
import { ProcessFilterCloudService } from '../../services/process-filter-cloud.service';
import { ProcessFiltersCloudComponent } from './process-filters-cloud.component';
import { By } from '@angular/platform-browser';
@ -578,67 +578,60 @@ describe('ProcessFiltersCloudComponent', () => {
expect(getProcessNotificationSubscriptionSpy).toHaveBeenCalled();
});
it('should not emit filter key when filter counter is set for first time', () => {
it('should emit filter key when filter counter is set for first time', () => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
const fakeFilterValue = 10;
const updatedFilterSpy = spyOn(component.updatedFilter, 'emit');
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, fakeFilterValue);
fixture.detectChanges();
expect(component.currentFiltersValues).not.toEqual({});
expect(component.currentFiltersValues[fakeFilterKey]).toBe(fakeFilterValue);
expect(updatedFilterSpy).not.toHaveBeenCalled();
expect(updatedFilterSpy).toHaveBeenCalled();
});
it('should not emit filter key when filter counter has not changd', () => {
it('should not emit filter key when filter counter has not changed', fakeAsync(() => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
const fakeFilterValue = 10;
const updatedFilterSpy = spyOn(component.updatedFilter, 'emit');
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, fakeFilterValue);
fixture.detectChanges();
expect(component.currentFiltersValues).not.toEqual({});
expect(component.currentFiltersValues[fakeFilterKey]).toBe(fakeFilterValue);
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, fakeFilterValue);
expect(component.currentFiltersValues[fakeFilterKey]).toBe(fakeFilterValue);
expect(updatedFilterSpy).not.toHaveBeenCalled();
});
component.updatedFilter.pipe(first()).subscribe(() => {
fail('Should not have been called if the filterKey value is already there');
});
it('should emit filter key when filter counter is increased', () => {
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, fakeFilterValue);
fixture.detectChanges();
expect(component.currentFiltersValues[fakeFilterKey]).toBe(fakeFilterValue);
flush();
}));
it('should emit filter key when filter counter is increased', (done) => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
const updatedFilterSpy = spyOn(component.updatedFilter, 'emit');
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 10);
fixture.detectChanges();
expect(updatedFilterSpy).not.toHaveBeenCalledWith(fakeFilterKey);
expect(component.currentFiltersValues[fakeFilterKey]).toBe(10);
component.updatedFilter.pipe(first()).subscribe((updatedFilter: string) => {
expect(updatedFilter).toBe(fakeFilterKey);
expect(component.currentFiltersValues[fakeFilterKey]).toBe(20);
done();
});
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 20);
fixture.detectChanges();
expect(updatedFilterSpy).toHaveBeenCalledWith(fakeFilterKey);
expect(component.currentFiltersValues[fakeFilterKey]).toBe(20);
});
it('should emit filter key when filter counter is decreased', () => {
it('should emit filter key when filter counter is decreased', (done) => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
const updatedFilterSpy = spyOn(component.updatedFilter, 'emit');
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 10);
fixture.detectChanges();
expect(updatedFilterSpy).not.toHaveBeenCalledWith(fakeFilterKey);
expect(component.currentFiltersValues[fakeFilterKey]).toBe(10);
component.updatedFilter.pipe(first()).subscribe((updatedFilter: string) => {
expect(updatedFilter).toBe(fakeFilterKey);
done();
});
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 5);
fixture.detectChanges();
expect(updatedFilterSpy).toHaveBeenCalledWith(fakeFilterKey);
expect(component.currentFiltersValues[fakeFilterKey]).toBe(5);
});
});
});

View File

@ -293,11 +293,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges {
}
checkIfFilterValuesHasBeenUpdated(filterKey: string, filterValue: number): void {
if (!this.currentFiltersValues[filterKey]) {
this.currentFiltersValues[filterKey] = filterValue;
return;
}
if (this.currentFiltersValues[filterKey] !== filterValue) {
if (this.currentFiltersValues[filterKey] === undefined || this.currentFiltersValues[filterKey] !== filterValue) {
this.currentFiltersValues[filterKey] = filterValue;
this.updatedFilter.emit(filterKey);
this.updatedFiltersSet.add(filterKey);

View File

@ -17,7 +17,7 @@
import { AppConfigService } from '@alfresco/adf-core';
import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
import { ComponentFixture, TestBed, fakeAsync, flush } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { first, of, throwError } from 'rxjs';
import { TASK_FILTERS_SERVICE_TOKEN } from '../../../../services/cloud-token.service';
@ -468,40 +468,42 @@ describe('TaskFiltersCloudComponent', () => {
expect(component.getFilters).toHaveBeenCalledWith(appName);
});
it('should not emit filter key when filter counter is set for first time', () => {
it('should emit filter key when filter counter is set for first time', () => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
const fakeFilterValue = 10;
const updatedFilterSpy = spyOn(component.updatedFilter, 'emit');
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, fakeFilterValue);
fixture.detectChanges();
expect(component.currentFiltersValues).not.toEqual({});
expect(component.currentFiltersValues[fakeFilterKey]).toBe(fakeFilterValue);
expect(updatedFilterSpy).not.toHaveBeenCalled();
expect(updatedFilterSpy).toHaveBeenCalled();
});
it('should not emit filter key when filter counter has not changd', () => {
it('should not emit filter key when filter counter has not changed', fakeAsync(() => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
const fakeFilterValue = 10;
const updatedFilterSpy = spyOn(component.updatedFilter, 'emit');
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, fakeFilterValue);
fixture.detectChanges();
expect(component.currentFiltersValues).not.toEqual({});
expect(component.currentFiltersValues[fakeFilterKey]).toBe(fakeFilterValue);
component.updatedFilter.pipe(first()).subscribe(() => {
fail('Should not have been called if the filterKey value is already there');
});
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, fakeFilterValue);
fixture.detectChanges();
expect(component.currentFiltersValues[fakeFilterKey]).toBe(fakeFilterValue);
expect(updatedFilterSpy).not.toHaveBeenCalled();
});
flush();
}));
it('should emit filter key when filter counter is increased', (done) => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 10);
component.updatedFilter.pipe(first()).subscribe((updatedFilter: string) => {
expect(updatedFilter).toBe(fakeFilterKey);
expect(component.currentFiltersValues[fakeFilterKey]).toBe(20);
@ -510,17 +512,14 @@ describe('TaskFiltersCloudComponent', () => {
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 20);
fixture.detectChanges();
});
it('should emit filter key when filter counter is decreased', (done) => {
component.currentFiltersValues = {};
const fakeFilterKey = 'testKey';
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 10);
component.updatedFilter.pipe(first()).subscribe((updatedFilter: string) => {
expect(updatedFilter).toBe(fakeFilterKey);
done();
});
component.checkIfFilterValuesHasBeenUpdated(fakeFilterKey, 5);
fixture.detectChanges();
});

View File

@ -261,11 +261,7 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
}
checkIfFilterValuesHasBeenUpdated(filterKey: string, filterValue: number) {
if (!this.currentFiltersValues[filterKey]) {
this.currentFiltersValues[filterKey] = filterValue;
return;
}
if (this.currentFiltersValues[filterKey] !== filterValue) {
if (this.currentFiltersValues[filterKey] == undefined || this.currentFiltersValues[filterKey] !== filterValue) {
this.currentFiltersValues[filterKey] = filterValue;
this.updatedFilter.emit(filterKey);
this.updatedCountersSet.add(filterKey);