Skip to content

Commit

Permalink
AAE-13282: Fixing save preferences on service tasks (#8476)
Browse files Browse the repository at this point in the history
* AAE-13282: Fixing save preferences on service tasks

* AAE-13282: Removing comments
  • Loading branch information
ehsan-2019 authored Apr 14, 2023
1 parent 4556546 commit f093438
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export abstract class BaseTaskListCloudComponent<T = unknown> extends DataTableS
if (changes['sorting']) {
this.formatSorting(changes['sorting'].currentValue);
}
if (changes['appName']) {
this.retrieveTasksPreferences();
}
this.reload();
}

Expand All @@ -165,7 +168,8 @@ export abstract class BaseTaskListCloudComponent<T = unknown> extends DataTableS
this.onDestroy$.complete();
}

ngAfterContentInit() {
private retrieveTasksPreferences(): void {
this.isLoading = true;
this.cloudPreferenceService.getPreferences(this.appName).pipe(
take(1),
map((preferences => {
Expand Down Expand Up @@ -194,8 +198,16 @@ export abstract class BaseTaskListCloudComponent<T = unknown> extends DataTableS
}

this.createDatatableSchema();
}
);
this.createColumns();
this.isLoading = false;
}, (error) => {
this.error.emit(error);
this.isLoading = false;
});
}

ngAfterContentInit(): void {
this.retrieveTasksPreferences();
}

isListEmpty(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,9 @@ describe('ServiceTaskListCloudComponent', () => {
spyOn(serviceTaskListCloudService, 'getServiceTaskByRequest').and.returnValue(of(emptyList));

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();

const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
component.ngOnChanges({ appName });
fixture.detectChanges();
expect(component.isLoading).toBe(false);

loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand All @@ -150,15 +144,13 @@ describe('ServiceTaskListCloudComponent', () => {
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();
expect(component.isLoading).toBe(false);

component.ngOnChanges({ appName });
fixture.detectChanges();

expect(component.isLoading).toBe(false);
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent {
this.requestNode = this.createRequestNode();

if (this.requestNode.appName || this.requestNode.appName === '') {
this.isLoading = true;

combineLatest([
this.serviceTaskListCloudService.getServiceTaskByRequest(this.requestNode),
Expand All @@ -63,7 +62,6 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent {
([tasks]) => {
this.rows = tasks.list.entries;
this.success.emit(tasks);
this.isLoading = false;
this.pagination.next(tasks.list.pagination);
}, (error) => {
this.error.emit(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,13 @@ describe('TaskListCloudComponent', () => {
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(emptyList));

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();
expect(component.isLoading).toBe(false);

const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
component.ngOnChanges({ appName });
fixture.detectChanges();

loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand All @@ -180,15 +178,13 @@ describe('TaskListCloudComponent', () => {
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();
expect(component.isLoading).toBe(false);

component.ngOnChanges({ appName });
fixture.detectChanges();

expect(component.isLoading).toBe(false);
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand Down

0 comments on commit f093438

Please sign in to comment.