Commit 1e28aed9 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Merge branch 'tests-integration' into 'develop'

Update tests + ngOnDestroy for Search results

See merge request !67
parents e1a7735c cae78b8f
Pipeline #1624 passed with stages
in 13 minutes and 36 seconds
......@@ -61,4 +61,4 @@ export function reducer(state: State = initialState, action: actions.Actions): S
export const getAttributeList = (state: State) => state.attributeList;
export const getObjectIsLoading = (state: State) => state.objectIsLoading;
export const getObjectIsLoaded = (state: State) => state.objectIsLoaded;
export const getObject = (state: State) => state.object;
\ No newline at end of file
export const getObject = (state: State) => state.object;
<div class="form-group row">
<label class="col-3 col-form-label">{{label}}</label>
<label class="col-3 col-form-label">{{ label }}</label>
<div class="col">
<div *ngFor="let cb of checkboxes.controls; let i=index" class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="cb_{{optionList[i].value}}" [formControl]="cb">
<label class="form-check-label" for="cb_{{optionList[i].value}}">{{optionList[i].label}}</label>
<label class="form-check-label" for="cb_{{optionList[i].value}}">{{ optionList[i].label }}</label>
</div>
</div>
<div class="col-2 text-center">
<button class="btn btn-outline-success" *ngIf="!checkboxes.disabled" [hidden]="!isChecked()" (click)="emitAdd()">
<button *ngIf="!checkboxes.disabled" class="btn btn-outline-success" [hidden]="!isChecked()"
(click)="emitAdd()">
<span class="fas fa-plus fa-fw"></span>
</button>
<button class="btn btn-outline-danger" *ngIf="checkboxes.disabled" (click)="emiteDelete()">
<button *ngIf="checkboxes.disabled" class="btn btn-outline-danger" (click)="emiteDelete()">
<span class="fa fa-times fa-fw"></span>
</button>
</div>
......
......@@ -30,8 +30,11 @@ describe('[Search][Criteria][SearchType] Component: CheckboxComponent', () => {
{label: 'Three', value: 'three', display: 3}
];
component.setCheckboxes(options);
// console.log(component.checkboxes.controls[0].value);
expect(component.checkboxes.length).toEqual(3);
expect(component.checkboxesFormControls.length).toEqual(3);
expect(component.checkboxesFormControls[0].value).toMatch('one');
expect(component.checkboxesFormControls[1].value).toMatch('two');
expect(component.checkboxesFormControls[2].value).toMatch('three');
});
// it('#getDefault() should not fill and enable form if criterion not defined', () => {
......@@ -78,12 +81,13 @@ describe('[Search][Criteria][SearchType] Component: CheckboxComponent', () => {
// it('raises the add criterion event when clicked', () => {
// component.id = 1;
// const values: Option[] = [
// const options: Option[] = [
// {label: 'One', value: 'one', display: 1},
// {label: 'Two', value: 'two', display: 2},
// {label: 'Three', value: 'three', display: 3}
// ];
// const expectedCriterion = new SelectMultipleCriterion(component.id, values);
// component.setCheckboxes(options);
// const expectedCriterion = new SelectMultipleCriterion(component.id, options);
// component.addCriterion.subscribe((event: SelectMultipleCriterion) => expect(event).toEqual(expectedCriterion));
// component.emitAdd();
// });
......
......@@ -50,7 +50,6 @@ export class CheckboxComponent {
this.checkboxesFormControls.push({ value: option.value, control });
return control;
}));
console.log(this.checkboxesFormControls);
}
getDefault(criterion: Criterion): void {
......
import { Component, OnInit, Query } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
......@@ -22,7 +22,7 @@ interface StoreState {
selector: 'app-result',
templateUrl: 'result.component.html'
})
export class ResultComponent implements OnInit {
export class ResultComponent implements OnInit, OnDestroy {
public datasetSearchMetaIsLoading: Observable<boolean>;
public datasetSearchMetaIsLoaded: Observable<boolean>;
public attributeSearchMetaIsLoading: Observable<boolean>;
......@@ -91,4 +91,8 @@ export class ResultComponent implements OnInit {
executeProcess(typeProcess: string): void {
this.store.dispatch(new searchActions.ExecuteProcessAction(typeProcess));
}
ngOnDestroy() {
this.store.dispatch(new searchActions.DestroyResultsAction());
}
}
......@@ -25,6 +25,7 @@ export const EXECUTE_PROCESS = '[Search] Execute Process';
export const EXECUTE_PROCESS_WIP = '[Search] Execute Process WIP';
export const EXECUTE_PROCESS_SUCCESS = '[Search] Execute Process Success';
export const EXECUTE_PROCESS_FAIL = '[Search] Execute Process Fail';
export const DESTROY_RESULTS = '[Search] Destroy Results';
export class InitSearchByUrl implements Action {
type = INIT_SEARCH_BY_URL;
......@@ -164,6 +165,12 @@ export class ExecuteProcessFailAction implements Action {
constructor(public payload: {} = null) { }
}
export class DestroyResultsAction implements Action {
type = DESTROY_RESULTS;
constructor(public payload: {} = null) { }
}
export type Actions
= InitSearchByUrl
| ChangeStepAction
......@@ -187,4 +194,5 @@ export type Actions
| ExecuteProcessAction
| ExecuteProcessWipAction
| ExecuteProcessSuccessAction
| ExecuteProcessFailAction;
| ExecuteProcessFailAction
| DestroyResultsAction;
......@@ -193,6 +193,14 @@ export function reducer(state: State = initialState, action: actions.Actions): S
processId: null
};
case actions.DESTROY_RESULTS:
return {
...state,
searchMetaIsLoaded: false,
searchMeta: null,
searchData: null,
};
default:
return state;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment