diff --git a/src/app/detail/components/spectra-graph/spectra-graph.component.css b/src/app/detail/components/spectra-graph/spectra-graph.component.css index 7e44d5b9cea072bf7e00c27b59aaed921764fcb5..43a6ba6e48be0d7f76bc91c348abafe93a697fde 100644 --- a/src/app/detail/components/spectra-graph/spectra-graph.component.css +++ b/src/app/detail/components/spectra-graph/spectra-graph.component.css @@ -70,8 +70,7 @@ } .text-tooltip { - font-size: 13px; - font-family: "Segoe UI"; + font-size: 15px; color: #333333; fill: #333333; } diff --git a/src/app/detail/store/detail.reducer.ts b/src/app/detail/store/detail.reducer.ts index 1660b048fe83c01bb294041f811e976ded1beef2..9024ee4fb3be13dc1ec22a5e9579e1495f09b3f2 100644 --- a/src/app/detail/store/detail.reducer.ts +++ b/src/app/detail/store/detail.reducer.ts @@ -31,7 +31,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.LOAD_ATTRIBUTE_LIST_SUCCESS: - const attributeList = action.payload as Attribute[]; + const attributeList: Attribute[] = action.payload; return { ...state, diff --git a/src/app/documentation/containers/documentation.component.ts b/src/app/documentation/containers/documentation.component.ts index 14fd652facdc5dd3f137963335498e4a64c17349..82166fc875af4ebe0a9c66dbeb3425e62c7fdd43 100644 --- a/src/app/documentation/containers/documentation.component.ts +++ b/src/app/documentation/containers/documentation.component.ts @@ -39,6 +39,6 @@ export class DocumentationComponent implements OnInit { getDatasetAttributes(dataset: Dataset, attributeList: Attribute[]): Attribute[] { return attributeList .filter(attribute => attribute.table_name === dataset.table_ref) - .sort((a, b) => a.id - b.id);; + .sort((a, b) => a.id - b.id); } } diff --git a/src/app/documentation/store/documentation.reducer.ts b/src/app/documentation/store/documentation.reducer.ts index ff5b20a05f1103c2c9e656bfb054f9a1a2f93eeb..83057bc52e57867a22f9a212d26cf564f6a04c30 100644 --- a/src/app/documentation/store/documentation.reducer.ts +++ b/src/app/documentation/store/documentation.reducer.ts @@ -28,7 +28,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.RETRIEVE_DATASET_LIST_SUCCESS: - const datasetList = action.payload as Dataset[]; + const datasetList: Dataset[] = action.payload; return { ...state, datasetList, @@ -49,7 +49,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.RETRIEVE_ATTRIBUTE_LIST_SUCCESS: - const attributeList = action.payload as Attribute[]; + const attributeList: Attribute[] = action.payload; return { ...state, diff --git a/src/app/login/store/login.reducer.ts b/src/app/login/store/login.reducer.ts index f071bb1777c0b39ca65d1a917b018ffb95c1bcaf..1273bf75cc00b6c3fab023fe791f2022314dc862 100644 --- a/src/app/login/store/login.reducer.ts +++ b/src/app/login/store/login.reducer.ts @@ -16,7 +16,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S switch (action.type) { case actions.LOGIN_LOCAL_STORAGE_SUCCESS: case actions.LOGIN_SUCCESS: - const loginToken = action.payload as LoginToken; + const loginToken: LoginToken = action.payload; return { ...state, diff --git a/src/app/metamodel/reducers/attribute.reducer.ts b/src/app/metamodel/reducers/attribute.reducer.ts index 75a7c5df4a3d1159a4c130f451765477da7deac3..9d36a54e60383cab38e8d67b69ed68d335b45993 100644 --- a/src/app/metamodel/reducers/attribute.reducer.ts +++ b/src/app/metamodel/reducers/attribute.reducer.ts @@ -23,7 +23,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.LOAD_ATTRIBUTE_SEARCH_META_SUCCESS: - const attributeList = action.payload as Attribute[]; + const attributeList: Attribute[] = action.payload; return { ...state, diff --git a/src/app/metamodel/reducers/criteria.reducer.ts b/src/app/metamodel/reducers/criteria.reducer.ts index d2eab9c967017610d7d1e3ea25482c3e40864e8b..5de2ab2789c87cc62fad8ab288f534a835528f36 100644 --- a/src/app/metamodel/reducers/criteria.reducer.ts +++ b/src/app/metamodel/reducers/criteria.reducer.ts @@ -22,7 +22,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.LOAD_CRITERIA_SEARCH_META_SUCCESS: - const criteriaSearchMeta = action.payload as Family[]; + const criteriaSearchMeta: Family[] = action.payload; return { ...state, diff --git a/src/app/metamodel/reducers/dataset.reducer.ts b/src/app/metamodel/reducers/dataset.reducer.ts index 77b19ab11869fb5c4462573b80ba677de4642056..c2ac30c8092874e3d52cd821db8fe636eab430f9 100644 --- a/src/app/metamodel/reducers/dataset.reducer.ts +++ b/src/app/metamodel/reducers/dataset.reducer.ts @@ -26,7 +26,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.LOAD_DATASET_SEARCH_META_SUCCESS: - const datasetSearchMeta = action.payload as [Project[], Dataset[], Family[]]; + const datasetSearchMeta: [Project[], Dataset[], Family[]] = action.payload; return { ...state, diff --git a/src/app/metamodel/reducers/output.reducer.ts b/src/app/metamodel/reducers/output.reducer.ts index 15639db78ba1a39225760bd50bbc256e1c1e9741..4d19602b8111dec73dbf6899545a7a6e97ff4dcc 100644 --- a/src/app/metamodel/reducers/output.reducer.ts +++ b/src/app/metamodel/reducers/output.reducer.ts @@ -24,7 +24,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.LOAD_OUTPUT_SEARCH_META_SUCCESS: - const outputSearchMeta = action.payload as [Family[], Category[]]; + const outputSearchMeta: [Family[], Category[]] = action.payload; return { ...state, diff --git a/src/app/search/containers/result.component.spec.ts b/src/app/search/containers/result.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8765c1c6ddfc7f0e4fa054e3480f20b64585244 --- /dev/null +++ b/src/app/search/containers/result.component.spec.ts @@ -0,0 +1,106 @@ +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; +import { provideMockStore, MockStore } from '@ngrx/store/testing'; +import { Component, Input } from '@angular/core'; + +import { ResultComponent } from './result.component'; +import * as fromMetamodel from '../../metamodel/reducers'; +import * as fromSearch from '../store/search.reducer'; +import * as datasetActions from '../../metamodel/action/dataset.action'; +import { Dataset, Attribute } from 'src/app/metamodel/model'; +import { Criterion, SearchQueryParams } from '../store/model'; +import { ScrollTopService } from '../../shared/service/sroll-top.service'; +import { RouterLinkDirectiveStub } from '../../../settings/test-data/router-link-directive-stub'; + +describe('[Search] Container: ResultComponent', () => { + @Component({ selector: 'app-result-download', template: '' }) + class DownloadSectionStubComponent { + @Input() datasetName: string; + @Input() datasetList: Dataset[]; + @Input() dataLength: number; + @Input() apiPath: string; + @Input() criteriaList: Criterion[]; + @Input() outputList: number[]; + } + + @Component({ selector: 'app-result-summary', template: '' }) + class SummarySectionStubComponent { + @Input() datasetAttributeList: Attribute[]; + @Input() criteriaList: Criterion[]; + @Input() outputList: number[]; + } + + @Component({ selector: 'app-result-url-display', template: '' }) + class UrlDisplaySectionStubComponent { + @Input() apiPath: string; + @Input() datasetName: string; + @Input() criteriaList: Criterion[]; + @Input() outputList: number[]; + } + + @Component({ selector: 'app-result-datatable', template: '' }) + class DatatableSectionStubComponent { + @Input() apiPath: string; + @Input() datasetName: string; + @Input() datasetList: Dataset[]; + @Input() queryParams: SearchQueryParams; + @Input() datasetAttributeList: Attribute[]; + @Input() outputList: number[]; + @Input() searchData: any[]; + @Input() dataLength: number; + @Input() selectedData: any[]; + @Input() processWip: boolean; + @Input() processDone: boolean; + @Input() processId: string; + } + + let scrollTopServiceStub: Partial<ScrollTopService> = { + setScrollTop() {} + }; + + let component: ResultComponent; + let fixture: ComponentFixture<ResultComponent>; + let store: MockStore; + const initialState = { + search: { ...fromSearch.initialState }, + metamodel: { ...fromMetamodel } + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ + ResultComponent, + DownloadSectionStubComponent, + SummarySectionStubComponent, + UrlDisplaySectionStubComponent, + DatatableSectionStubComponent, + RouterLinkDirectiveStub + ], + providers: [ + provideMockStore({ initialState }), + { provide: ScrollTopService, useValue: scrollTopServiceStub } + ] + }); + fixture = TestBed.createComponent(ResultComponent); + component = fixture.componentInstance; + store = TestBed.inject(MockStore); + })); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + +// it('should execute ngOnInit lifecycle', () => { +// // const changeStepAction = new searchActions.ChangeStepAction('result'); +// const loadDatasetSearchMetaAction = new datasetActions.LoadDatasetSearchMetaAction(); +// const spy = spyOn(store, 'dispatch'); +// fixture.detectChanges(); + +// // expect(spy).toHaveBeenCalledTimes(1); +// expect(spy).toHaveBeenCalledWith(loadDatasetSearchMetaAction); +// }); +}); +// Promise.resolve(null).then(() => this.store.dispatch(new searchActions.ChangeStepAction('result'))); +// Promise.resolve(null).then(() => this.store.dispatch(new searchActions.ResultChecked())); +// Promise.resolve(null).then(() => this.store.dispatch(new searchActions.InitSearchByUrl())); +// this.store.dispatch(new datasetActions.LoadDatasetSearchMetaAction()); +// this.scrollTopService.setScrollTop(); diff --git a/src/app/search/containers/search.component.spec.ts b/src/app/search/containers/search.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..1a6e4faa9f025ae13bb507470cabc98dcf84c366 --- /dev/null +++ b/src/app/search/containers/search.component.spec.ts @@ -0,0 +1,47 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideMockStore, MockStore } from '@ngrx/store/testing'; +import { Component, Input } from '@angular/core'; + +import { SearchComponent } from './search.component'; +import * as fromSearch from '../store/search.reducer'; +import { SearchQueryParams } from '../store/model'; + +describe('[Search] Container: SearchComponent', () => { + @Component({ selector: 'app-progress-bar', template: '' }) + class ProgressBarStubComponent { + @Input() currentStep: string; + @Input() datasetName: string; + @Input() criteriaStepChecked: boolean; + @Input() outputStepChecked: boolean; + @Input() resultStepChecked: boolean; + @Input() queryParams: SearchQueryParams; + @Input() outputListEmpty: boolean; + } + + @Component({ selector: 'router-outlet', template: '' }) + class RouterOutletStubComponent { } + + let component: SearchComponent; + let fixture: ComponentFixture<SearchComponent>; + let store: MockStore; + const initialState = { documentation: { ...fromSearch.initialState } };; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + SearchComponent, + ProgressBarStubComponent, + RouterOutletStubComponent + ], + providers: [provideMockStore({ initialState })] + }); + fixture = TestBed.createComponent(SearchComponent); + component = fixture.componentInstance; + store = TestBed.inject(MockStore); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); +}); + diff --git a/src/app/search/store/search.effects.ts b/src/app/search/store/search.effects.ts index 17aaf3df8fbd288cb7002ff0aa59c8d3917774be..40589fff1a5c7a4d692f89455c39cffcf6531e08 100644 --- a/src/app/search/store/search.effects.ts +++ b/src/app/search/store/search.effects.ts @@ -242,7 +242,7 @@ export class SearchEffects { withLatestFrom(this.store$), switchMap(([action, state]) => { const executeProcessWipAction = action as searchActions.ExecuteProcessWipAction; - const idProcess = executeProcessWipAction.payload as string; + const idProcess: string = executeProcessWipAction.payload; return this.searchService.checkProcess(idProcess).pipe( map(_ => { return new searchActions.ExecuteProcessSuccessAction(idProcess); diff --git a/src/app/search/store/search.reducer.ts b/src/app/search/store/search.reducer.ts index 94f0c9c8b7565be54225d9a1554f0f06697809a5..fcda137df10e524f8d24ab2460a5c5bb5ea3c4e3 100644 --- a/src/app/search/store/search.reducer.ts +++ b/src/app/search/store/search.reducer.ts @@ -43,14 +43,14 @@ export const initialState: State = { export function reducer(state: State = initialState, action: actions.Actions): State { switch (action.type) { case actions.CHANGE_STEP: - const currentStep = action.payload as string; + const currentStep: string = action.payload; return { ...state, currentStep }; case actions.SELECT_DATASET: - const datasetName = action.payload as string; + const datasetName: string = action.payload; return { ...state, pristine: false, @@ -82,7 +82,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.ADD_CONE_SEARCH: - const coneSearch = action.payload as ConeSearch; + const coneSearch: ConeSearch = action.payload; return { ...state, coneSearch @@ -95,56 +95,56 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.UPDATE_CRITERIA_LIST: - const criteriaList = action.payload as Criterion[]; + const criteriaList: Criterion[] = action.payload; return { ...state, criteriaList }; case actions.ADD_CRITERION: - const criterion = action.payload as Criterion; + const criterion: Criterion = action.payload; return { ...state, criteriaList: [...state.criteriaList, criterion] }; case actions.DELETE_CRITERION: - const id = action.payload as number; + const id: number = action.payload; return { ...state, criteriaList: [...state.criteriaList.filter(c => c.id !== id)] }; case actions.UPDATE_OUTPUT_LIST: - const outputList = action.payload as number[]; + const outputList: number[] = action.payload; return { ...state, outputList }; case actions.RETRIEVE_DATA_SUCCESS: - const searchData = action.payload as any[]; + const searchData: any[] = action.payload; return { ...state, searchData }; case actions.GET_DATA_LENGTH_SUCCESS: - const dataLength = action.payload as number; + const dataLength: number = action.payload; return { ...state, dataLength }; case actions.ADD_SELECTED_DATA: - const addData = action.payload as number | string; + const addData: number | string = action.payload; return { ...state, selectedData: [...state.selectedData, addData] }; case actions.DELETE_SELECTED_DATA: - const deleteData = action.payload as number | string; + const deleteData: number | string = action.payload; return { ...state, selectedData: [...state.selectedData.filter(d => d !== deleteData)] @@ -158,7 +158,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.EXECUTE_PROCESS_WIP: - const processId = action.payload as string; + const processId: string = action.payload; return { ...state, processId @@ -180,7 +180,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S }; case actions.OUTPUT_LIST_EMPTY: - const outputListEmpty = action.payload as boolean; + const outputListEmpty: boolean = action.payload; return { ...state, outputListEmpty diff --git a/src/settings/test-data/router-link-directive-stub.ts b/src/settings/test-data/router-link-directive-stub.ts new file mode 100644 index 0000000000000000000000000000000000000000..a08acd45ccc190f11da55653f2f4f6351018abd2 --- /dev/null +++ b/src/settings/test-data/router-link-directive-stub.ts @@ -0,0 +1,10 @@ +import { Input, Directive } from '@angular/core'; + +@Directive({ + selector: '[routerLink]' +}) +export class RouterLinkDirectiveStub { + @Input('routerLink') linkParams: any; + @Input('queryParams') queryParams: any; + navigatedTo: any = null; +} \ No newline at end of file