From 01d53d7f238a2816ff41f17a16720a1d7d0c2c44 Mon Sep 17 00:00:00 2001 From: Faust1 Date: Wed, 20 Mar 2024 11:43:09 +0100 Subject: [PATCH 1/6] chore: remove commented code --- .../services/applications-index.service.ts | 1 - ...w-tasks-by-status-dialog.component.spec.ts | 8 ------ src/app/services/share-url.service.ts | 1 - src/app/types/filters.ts | 28 ------------------- 4 files changed, 38 deletions(-) diff --git a/src/app/applications/services/applications-index.service.ts b/src/app/applications/services/applications-index.service.ts index 05be12bf9..203c896e0 100644 --- a/src/app/applications/services/applications-index.service.ts +++ b/src/app/applications/services/applications-index.service.ts @@ -6,7 +6,6 @@ import { TableService } from '@services/table.service'; import { ApplicationRaw, ApplicationRawColumnKey, ApplicationRawListOptions } from '../types'; @Injectable() -// export class ApplicationsIndexService implements AppIndexService { export class ApplicationsIndexService implements IndexServiceInterface { readonly tableService = inject(TableService); readonly defaultConfigService = inject(DefaultConfigService); diff --git a/src/app/components/view-tasks-by-status-dialog.component.spec.ts b/src/app/components/view-tasks-by-status-dialog.component.spec.ts index f8ac28b69..5167db530 100644 --- a/src/app/components/view-tasks-by-status-dialog.component.spec.ts +++ b/src/app/components/view-tasks-by-status-dialog.component.spec.ts @@ -152,12 +152,6 @@ describe('ViewTasksByStatusDialogComponent', () => { { status: TaskStatus.TASK_STATUS_CREATING, color: 'dark-red'} ]); }); - - // it('should not remove anythin if the list is null', () => { - // component.statusesCounts = null; - // component.onRemove(0); - // expect(component.statusesCounts).toBen - // }) }); describe('onAdd', () => { @@ -170,8 +164,6 @@ describe('ViewTasksByStatusDialogComponent', () => { { status: TaskStatus.TASK_STATUS_UNSPECIFIED, color: '#000000'} ]); }); - - // it('should not add a default ') }); it('should call MatDialogRef.close on close', () => { diff --git a/src/app/services/share-url.service.ts b/src/app/services/share-url.service.ts index cb9eb9eb5..20c83cff9 100644 --- a/src/app/services/share-url.service.ts +++ b/src/app/services/share-url.service.ts @@ -37,7 +37,6 @@ export class ShareUrlService { return keys.reduce((acc, key) => { const value = object[key]; - // const encodedValue = encodeURIComponent(JSON.stringify(value)); if (!value) return acc; diff --git a/src/app/types/filters.ts b/src/app/types/filters.ts index a1a42f158..5633b3ce9 100644 --- a/src/app/types/filters.ts +++ b/src/app/types/filters.ts @@ -36,34 +36,6 @@ export type Filter = { operator: MaybeNull }; - -// // Used to define filters available for the query builder. -// type FilterDefinitionBase = { -// // The couple key/field is used to know which field use for the filter. In fact, the key is the column name and the field, the id of the field. -// key: T -// field?: U -// type: FilterType -// }; - -// export interface FiltersDefinitionString extends FilterDefinitionBase { -// type: 'string' -// } -// export interface FiltersDefinitionNumber extends FilterDefinitionBase { -// type: 'number' -// } -// export interface FiltersDefinitionDate extends FilterDefinitionBase { -// type: 'date' -// } -// export interface FiltersDefinitionStatus extends FilterDefinitionBase { -// type: 'status' -// statuses: FilterValueOptions; -// } -// export interface FiltersDefinitionArray extends FilterDefinitionBase { -// type: 'array' -// } -// // Filters used to create the query builder. -// export type FiltersDefinition = FiltersDefinitionString | FiltersDefinitionNumber | FiltersDefinitionDate | FiltersDefinitionStatus | FiltersDefinitionArray; - // Value of a filter input. export type FilterInputValueString = MaybeNull; export type FilterInputValueNumber = MaybeNull; From c9413eb266fb7cc695f1226d89b056ee06b89e32 Mon Sep 17 00:00:00 2001 From: Faust1 Date: Wed, 20 Mar 2024 11:46:28 +0100 Subject: [PATCH 2/6] chore: rework filters dialog tests --- ...ters-dialog-filter-field.component.spec.ts | 81 +++++++++---------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/src/app/components/filters/filters-dialog-filter-field.component.spec.ts b/src/app/components/filters/filters-dialog-filter-field.component.spec.ts index 0dfd8e447..39a15033f 100644 --- a/src/app/components/filters/filters-dialog-filter-field.component.spec.ts +++ b/src/app/components/filters/filters-dialog-filter-field.component.spec.ts @@ -113,59 +113,57 @@ describe('FiltersDialogFilterFieldComponent', () => { expect(component).toBeTruthy(); }); - describe('ngOnInit', () => { - describe('filteredProperties', () => { - it('should filter properly', () => { - component.filteredProperties.subscribe(value => { - expect(value).toEqual(['status', 'Start to End duration', 'Created at']); - }); - component.propertyFormControl.setValue('at'); - component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + describe('filteredProperties', () => { + it('should filter properly', () => { + component.filteredProperties.subscribe(value => { + expect(value).toEqual(['status', 'Start to End duration', 'Created at']); }); + component.propertyFormControl.setValue('at'); + component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + }); - it('should return all the list in case of null value', () => { - component.filteredProperties.subscribe(value => { - expect(value).toEqual(Object.values(propertiesLabel)); - }); - component.propertyFormControl.setValue(null); - component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + it('should return all the list in case of null value', () => { + component.filteredProperties.subscribe(value => { + expect(value).toEqual(Object.values(propertiesLabel)); }); + component.propertyFormControl.setValue(null); + component.propertyFormControl.updateValueAndValidity({emitEvent: true}); }); + }); - describe('filteredOperators', () => { - it('should filter properly', () => { - component.filteredOperators.subscribe(value => { - expect(value).toEqual(['equal', 'not equal']); - }); - component.propertyFormControl.setValue('equal'); - component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + describe('filteredOperators', () => { + it('should filter properly', () => { + component.filteredOperators.subscribe(value => { + expect(value).toEqual(['equal', 'not equal']); }); + component.propertyFormControl.setValue('equal'); + component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + }); - it('should return all the list in case of null value', () => { - component.filteredOperators.subscribe(value => { - expect(value).toEqual(['equal', 'not equal']); - }); - component.propertyFormControl.setValue(null); - component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + it('should return all the list in case of null value', () => { + component.filteredOperators.subscribe(value => { + expect(value).toEqual(['equal', 'not equal']); }); + component.propertyFormControl.setValue(null); + component.propertyFormControl.updateValueAndValidity({emitEvent: true}); }); + }); - describe('filteredStatuses', () => { - it('should filter properly', () => { - component.filteredStatuses.subscribe(value => { - expect(value).toEqual(['sumbitted', 'Ended']); - }); - component.propertyFormControl.setValue('ed'); - component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + describe('filteredStatuses', () => { + it('should filter properly', () => { + component.filteredStatuses.subscribe(value => { + expect(value).toEqual(['sumbitted', 'Ended']); }); + component.propertyFormControl.setValue('ed'); + component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + }); - it('should return all the list in case of null value', () => { - component.filteredStatuses.subscribe(value => { - expect(value).toEqual(Object.values(allStatuses)); - }); - component.propertyFormControl.setValue(null); - component.propertyFormControl.updateValueAndValidity({emitEvent: true}); + it('should return all the list in case of null value', () => { + component.filteredStatuses.subscribe(value => { + expect(value).toEqual(Object.values(allStatuses)); }); + component.propertyFormControl.setValue(null); + component.propertyFormControl.updateValueAndValidity({emitEvent: true}); }); }); @@ -220,7 +218,6 @@ describe('FiltersDialogFilterFieldComponent', () => { }); }); - //TODO: security type check it('should retrieve the label', () => { component.retrieveLabel(filterDefinitions[0]); expect(mockDataFiltersService.retrieveLabel).toHaveBeenCalledWith( @@ -229,14 +226,12 @@ describe('FiltersDialogFilterFieldComponent', () => { ); }); - //TODO: security type check it('should change the operator of the filter', () => { component.operatorFormControl.setValue('Equal'); component.onOperatorChange(); expect(component.filter.operator).toEqual(0); }); - //TODO: security type check describe('onInputChange', () => { it('should change the filter value on string input', () => { const inputEvent = { From 243b814a02bdda2c41d5d544515b068bb366785c Mon Sep 17 00:00:00 2001 From: Faust1 Date: Wed, 20 Mar 2024 11:51:27 +0100 Subject: [PATCH 3/6] chore: remove unnecessary conditional statement --- src/app/components/filters/filters-dialog-input.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/filters/filters-dialog-input.component.ts b/src/app/components/filters/filters-dialog-input.component.ts index 11761a4ab..8a683829a 100644 --- a/src/app/components/filters/filters-dialog-input.component.ts +++ b/src/app/components/filters/filters-dialog-input.component.ts @@ -94,7 +94,7 @@ export class FiltersDialogInputComponent implements OnInit { this.valueChange.emit({ type: 'status', - value: formValue ? formValue : null, + value: formValue, }); } From e1e755da6ad298e986ad447877085a6f59e2faba Mon Sep 17 00:00:00 2001 From: Faust1 Date: Wed, 20 Mar 2024 11:54:55 +0100 Subject: [PATCH 4/6] chore: remove useless assignment to variable --- src/app/services/auto-refresh.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/services/auto-refresh.service.ts b/src/app/services/auto-refresh.service.ts index 983a10549..36afba6c8 100644 --- a/src/app/services/auto-refresh.service.ts +++ b/src/app/services/auto-refresh.service.ts @@ -11,7 +11,7 @@ export class AutoRefreshService { */ createInterval(intervalSubject: Subject, stopIntervalSubject: Subject): Observable { return merge(intervalSubject).pipe( - map(value => !value || value < 0 ? value = 0 : value), + map(value => !value || value < 0 ? 0 : value), switchMap((value) => { return interval((value as number) * 1000).pipe(takeUntil(stopIntervalSubject)); }) From 5a97b7900f2266d3878d64a35f005cafd7000ff4 Mon Sep 17 00:00:00 2001 From: Faust1 Date: Wed, 20 Mar 2024 14:11:08 +0100 Subject: [PATCH 5/6] chore: update default configuration tests --- .../services/default-config-service.spec.ts | 94 +++++++------------ 1 file changed, 33 insertions(+), 61 deletions(-) diff --git a/src/app/services/default-config-service.spec.ts b/src/app/services/default-config-service.spec.ts index 2bf099626..63b5fb94a 100644 --- a/src/app/services/default-config-service.spec.ts +++ b/src/app/services/default-config-service.spec.ts @@ -13,93 +13,65 @@ describe('DefaultConfigService', () => { expect(service.defaultTheme).toBe('indigo-pink'); }); - it('should call defaultExternalServices getter', () => { - const spyGetDefaultExternalServices = jest.spyOn(service, 'defaultExternalServices', 'get'); - service.defaultExternalServices; - expect(spyGetDefaultExternalServices).toHaveBeenCalled(); + it('should have a defined defaultExternalServices configuration', () => { + expect(service.defaultExternalServices).toBeDefined(); }); - it('should call defaultTasks getter', () => { - const spyGetDefaultTasks = jest.spyOn(service, 'defaultTasks', 'get'); - service.defaultTasks; - expect(spyGetDefaultTasks).toHaveBeenCalled(); + it('should have a defined defaultTasks configuration', () => { + expect(service.defaultTasks).toBeDefined(); }); - it('should call defaultTasksByStatus getter', () => { - const spyGetDefaultTasksByStatus = jest.spyOn(service, 'defaultTasksByStatus', 'get'); - service.defaultTasksByStatus; - expect(spyGetDefaultTasksByStatus).toHaveBeenCalled(); + it('should have a defined defaultTasksByStatus configuration', () => { + expect(service.defaultTasksByStatus).toBeDefined(); }); - it('should call defaultPartititons getter', () => { - const spyGetDefaultPartitions = jest.spyOn(service, 'defaultPartitions', 'get'); - service.defaultPartitions; - expect(spyGetDefaultPartitions).toHaveBeenCalled(); + it('should have a defined defaultPartititons configuration', () => { + expect(service.defaultPartitions).toBeDefined(); }); - it('should call defaultDashboardSplitLines getter', ()=> { - const spyGetDefaultDashboardSplitLines = jest.spyOn(service, 'defaultDashboardSplitLines', 'get'); - service.defaultDashboardSplitLines; - expect(spyGetDefaultDashboardSplitLines).toHaveBeenCalled(); + it('should have a defined defaultDashboardSplitLines configuration', ()=> { + expect(service.defaultDashboardSplitLines).toBeDefined(); }); - it('should call defaultDashboardLines getter', ()=> { - const spyGetDefaultDashboardLines = jest.spyOn(service, 'defaultDashboardLines', 'get'); - service.defaultDashboardLines; - expect(spyGetDefaultDashboardLines).toHaveBeenCalled(); - }); + it('should have a defined defaultSessions configuration', () => { + expect(service.defaultSessions).toBeDefined(); + }); - it('should call defaultSessions getter', () => { - const spyGetDefaultSessions = jest.spyOn(service, 'defaultSessions', 'get'); - service.defaultSessions; - expect(spyGetDefaultSessions).toHaveBeenCalled(); + it('should have a defined defaultResults configuration', () => { + expect(service.defaultResults).toBeDefined(); }); - it('should call defaultResults getter', () => { - const spyGetDefaultResults = jest.spyOn(service, 'defaultResults', 'get'); - service.defaultResults; - expect(spyGetDefaultResults).toHaveBeenCalled(); + it('should have a defined defaultApplications configuration', () => { + expect(service.defaultApplications).toBeDefined(); }); - it('should call defaultApplications getter', () => { - const spyGetDefaultApplications = jest.spyOn(service, 'defaultApplications', 'get'); - service.defaultApplications; - expect(spyGetDefaultApplications).toHaveBeenCalled(); + it('should have a defined defaultSidebar configuration', () => { + expect(service.defaultSidebar).toBeDefined(); }); - it('should call defaultSidebar getter', () => { - const spyGetDefaultSidebar = jest.spyOn(service, 'defaultSidebar', 'get'); - service.defaultSidebar; - expect(spyGetDefaultSidebar).toHaveBeenCalled(); + it('should have a defined defaultTasksViewInLogs configuration', () => { + expect(service.defaultTasksViewInLogs).toBeDefined(); }); - it('should call defaultTasksViewInLogs getter', () => { - const spyGetDefaultTasksViewInLogs = jest.spyOn(service, 'defaultTasksViewInLogs', 'get'); - service.defaultTasksViewInLogs; - expect(spyGetDefaultTasksViewInLogs).toHaveBeenCalled(); + it('should have a defined exportedDefaultConfig configuration', () => { + expect(service.exportedDefaultConfig).toBeDefined(); }); - it('should call exportedDefaultConfig getter', () => { - const spyGetExportedDefaultConfig = jest.spyOn(service, 'exportedDefaultConfig', 'get'); - service.exportedDefaultConfig; - expect(spyGetExportedDefaultConfig).toHaveBeenCalled(); + it('should have a defined defaultLanguage configuration', () => { + expect(service.defaultLanguage).toBeDefined(); }); - it('should call defaultLanguage getter', () => { - const spyGetDefaultLanguage = jest.spyOn(service, 'defaultLanguage', 'get'); - service.defaultLanguage; - expect(spyGetDefaultLanguage).toHaveBeenCalled(); + it('should have a defined availableLanguages configuration', () => { + expect(service.availableLanguages).toBeDefined(); }); - it('should call availableLanguages getter', () => { - const spyGetAvailableLanguage = jest.spyOn(service, 'availableLanguages', 'get'); - service.availableLanguages; - expect(spyGetAvailableLanguage).toHaveBeenCalled(); + it('should have a defined healthcheck configuration', () => { + expect(service.healthCheck).toBeDefined(); }); describe(' default dashboard configuration', () => { it('the dashboard lines configuration should display at least 1 line', () => { - expect(service.defaultDashboardLines).toHaveLength(1); + expect(service.defaultDashboardLines).toBeDefined(); }); it('the line by default should contain 3 task statuses', () => { @@ -110,9 +82,9 @@ describe('DefaultConfigService', () => { it('the line by default should have finished, running, error, task statuses by default ', () => { const defaultDashboardLines = service.defaultDashboardLines; const taskStatuses = defaultDashboardLines.map( line => line.taskStatusesGroups) as unknown as TasksStatusesGroup[][]; - expect(taskStatuses[0].map(taskStatus => taskStatus.name === 'Finished')).toBeTruthy(); - expect(taskStatuses[0].map(taskStatus => taskStatus.name === 'Running')).toBeTruthy(); - expect(taskStatuses[0].map(taskStatus => taskStatus.name === 'Errors')).toBeTruthy(); + expect(taskStatuses[0].map(taskStatus => taskStatus.name === 'Finished')).toBeTruthy(); + expect(taskStatuses[0].map(taskStatus => taskStatus.name === 'Running')).toBeTruthy(); + expect(taskStatuses[0].map(taskStatus => taskStatus.name === 'Errors')).toBeTruthy(); }); it('default DashboardSplitLines should return 1 line', ()=> { From 6ac406e427ac9195f71d59e9362dc2ee6378c205 Mon Sep 17 00:00:00 2001 From: Faust1 Date: Wed, 20 Mar 2024 14:14:16 +0100 Subject: [PATCH 6/6] chore: removed useless variable called in user grpc service tests --- src/app/services/user-grpc.service.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/services/user-grpc.service.spec.ts b/src/app/services/user-grpc.service.spec.ts index 1b6532354..eee31cb4d 100644 --- a/src/app/services/user-grpc.service.spec.ts +++ b/src/app/services/user-grpc.service.spec.ts @@ -2,7 +2,6 @@ import { AuthenticationClient, GetCurrentUserResponse } from '@aneoconsultingfr/ import { TestBed } from '@angular/core/testing'; import { BehaviorSubject } from 'rxjs'; import { UserGrpcService } from './user-grpc.service'; -TestBed; describe('VersionsGrpcService', () => { let service: UserGrpcService;