Skip to content

Commit

Permalink
Merge branch 'main' into fix/table-with-less-data
Browse files Browse the repository at this point in the history
  • Loading branch information
ngruelaneo authored Mar 20, 2024
2 parents dd43593 + f679951 commit 88f0ee4
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { TableService } from '@services/table.service';
import { ApplicationRaw, ApplicationRawColumnKey, ApplicationRawListOptions } from '../types';

@Injectable()
// export class ApplicationsIndexService implements AppIndexService<ApplicationRaw> {
export class ApplicationsIndexService implements IndexServiceInterface<ApplicationRawColumnKey, ApplicationRawListOptions> {
readonly tableService = inject(TableService);
readonly defaultConfigService = inject(DefaultConfigService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
});
});

Expand Down Expand Up @@ -220,7 +218,6 @@ describe('FiltersDialogFilterFieldComponent', () => {
});
});

//TODO: security type check
it('should retrieve the label', () => {
component.retrieveLabel(filterDefinitions[0]);
expect(mockDataFiltersService.retrieveLabel).toHaveBeenCalledWith(
Expand All @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class FiltersDialogInputComponent implements OnInit {

this.valueChange.emit({
type: 'status',
value: formValue ? formValue : null,
value: formValue,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/auto-refresh.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class AutoRefreshService {
*/
createInterval(intervalSubject: Subject<number>, stopIntervalSubject: Subject<void>): Observable<number> {
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));
})
Expand Down
94 changes: 33 additions & 61 deletions src/app/services/default-config-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', ()=> {
Expand Down
1 change: 0 additions & 1 deletion src/app/services/share-url.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/app/services/user-grpc.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 0 additions & 28 deletions src/app/types/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,6 @@ export type Filter<T extends number, U extends number | null = null> = {
operator: MaybeNull<number>
};


// // Used to define filters available for the query builder.
// type FilterDefinitionBase<T, U = null> = {
// // 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<T extends number, U> extends FilterDefinitionBase<T, U> {
// type: 'string'
// }
// export interface FiltersDefinitionNumber<T, U> extends FilterDefinitionBase<T, U> {
// type: 'number'
// }
// export interface FiltersDefinitionDate<T, U> extends FilterDefinitionBase<T, U> {
// type: 'date'
// }
// export interface FiltersDefinitionStatus<T, U> extends FilterDefinitionBase<T, U> {
// type: 'status'
// statuses: FilterValueOptions;
// }
// export interface FiltersDefinitionArray<T, U> extends FilterDefinitionBase<T, U> {
// type: 'array'
// }
// // Filters used to create the query builder.
// export type FiltersDefinition<T extends number, U = null> = FiltersDefinitionString<T, U> | FiltersDefinitionNumber<T, U> | FiltersDefinitionDate<T, U> | FiltersDefinitionStatus<T, U> | FiltersDefinitionArray<T, U>;

// Value of a filter input.
export type FilterInputValueString = MaybeNull<string>;
export type FilterInputValueNumber = MaybeNull<number>;
Expand Down

0 comments on commit 88f0ee4

Please sign in to comment.