diff --git a/ui/ui-frontend/projects/referential/src/app/access-contract/access-contract-create/access-contract-create.component.ts b/ui/ui-frontend/projects/referential/src/app/access-contract/access-contract-create/access-contract-create.component.ts index 6d94a0dfc1711b62ed643f55bbe1c1b3ad90a4b8..e2da956a45d2dbc908cabc321cdb2dcda21e0133 100644 --- a/ui/ui-frontend/projects/referential/src/app/access-contract/access-contract-create/access-contract-create.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/access-contract/access-contract-create/access-contract-create.component.ts @@ -34,16 +34,16 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-C license and that you accept its terms. */ -import {Component, Inject, Input, OnDestroy, OnInit, ViewChild} from '@angular/core'; -import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; -import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; -import {Subscription} from 'rxjs'; -import {ConfirmDialogService, Option} from 'ui-frontend-common'; +import { Component, Inject, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { Subscription } from 'rxjs'; +import { ConfirmDialogService, Option } from 'ui-frontend-common'; -import {AccessContract, FilingPlanMode} from 'projects/vitamui-library/src/public-api'; -import {AgencyService} from '../../agency/agency.service'; -import {AccessContractService} from '../access-contract.service'; -import {AccessContractCreateValidators} from './access-contract-create.validators'; +import { AccessContract, FilingPlanMode } from 'projects/vitamui-library/src/public-api'; +import { AgencyService } from '../../agency/agency.service'; +import { AccessContractService } from '../access-contract.service'; +import { AccessContractCreateValidators } from './access-contract-create.validators'; const PROGRESS_BAR_MULTIPLICATOR = 100; @@ -71,7 +71,7 @@ export class AccessContractCreateComponent implements OnInit, OnDestroy { private stepCount = 4; private keyPressSubscription: Subscription; - @ViewChild('fileSearch', {static: false}) fileSearch: any; + @ViewChild('fileSearch', { static: false }) fileSearch: any; constructor( public dialogRef: MatDialogRef<AccessContractCreateComponent>, @@ -88,7 +88,7 @@ export class AccessContractCreateComponent implements OnInit, OnDestroy { accessLogControl = new FormControl(true); allNodes = new FormControl(false); ruleFilter = new FormControl(false); - selectNodesControl = new FormControl({included: [], excluded: []}); + selectNodesControl = new FormControl({ included: [], excluded: [] }); accessContractSelect = new FormControl(null, Validators.required); originatingAgencies: Option[] = []; @@ -96,28 +96,28 @@ export class AccessContractCreateComponent implements OnInit, OnDestroy { // FIXME: Get list from common var ? rules: Option[] = [ - {key: 'StorageRule', label: 'Durée d\'utilité courante', info: ''}, - {key: 'ReuseRule', label: 'Durée de réutilisation', info: ''}, - {key: 'ClassificationRule', label: 'Durée de classification', info: ''}, - {key: 'DisseminationRule', label: 'Délai de diffusion', info: ''}, - {key: 'AccessRule', label: 'Durée d\'utilité administrative', info: ''}, - {key: 'AppraisalRule', label: 'Délai de communicabilité', info: ''} + { key: 'StorageRule', label: 'Durée d\'utilité courante', info: '' }, + { key: 'ReuseRule', label: 'Durée de réutilisation', info: '' }, + { key: 'ClassificationRule', label: 'Durée de classification', info: '' }, + { key: 'DisseminationRule', label: 'Délai de diffusion', info: '' }, + { key: 'AccessRule', label: 'Durée d\'utilité administrative', info: '' }, + { key: 'AppraisalRule', label: 'Délai de communicabilité', info: '' } ]; // FIXME: Get list from common var ? usages: Option[] = [ - {key: 'BinaryMaster', label: 'Archives numériques originales', info: ''}, - {key: 'Dissemination', label: 'Copies de diffusion', info: ''}, - {key: 'Thumbnail', label: 'Vignettes', info: ''}, - {key: 'TextContent', label: 'Contenu textuel', info: ''}, - {key: 'PhysicalMaster', label: 'Archives physiques', info: ''} + { key: 'BinaryMaster', label: 'Archives numériques originales', info: '' }, + { key: 'Dissemination', label: 'Copies de diffusion', info: '' }, + { key: 'Thumbnail', label: 'Vignettes', info: '' }, + { key: 'TextContent', label: 'Contenu textuel', info: '' }, + { key: 'PhysicalMaster', label: 'Archives physiques', info: '' } ]; ngOnInit() { console.log('tenantIdentifier', this.tenantIdentifier); this.agencyService.getAll().subscribe(agencies => - this.originatingAgencies = agencies.map(x => ({label: x.name, key: x.identifier})) + this.originatingAgencies = agencies.map(x => ({ label: x.name, key: x.identifier })) ); this.accessContractService.getAll().subscribe((value) => { @@ -177,8 +177,8 @@ export class AccessContractCreateComponent implements OnInit, OnDestroy { } onSubmit() { - if (this.lastStepInvalid()) { - return; + if (this.lastStepInvalid()) { + return; } const accessContract = this.form.value as AccessContract; this.accessContractService.create(accessContract).subscribe( diff --git a/ui/ui-frontend/projects/referential/src/app/admin-dsl/admin-dsl.component.ts b/ui/ui-frontend/projects/referential/src/app/admin-dsl/admin-dsl.component.ts index caa1e96d844f640d7c4878f008c8f88ef8914020..c8cb5380008295907c977c2c3625deacf228fe59 100644 --- a/ui/ui-frontend/projects/referential/src/app/admin-dsl/admin-dsl.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/admin-dsl/admin-dsl.component.ts @@ -39,8 +39,8 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; import {AppRootComponent, Option} from 'ui-frontend-common'; import {AccessContractService} from '../access-contract/access-contract.service'; +import {VitamUISnackBar} from '../shared/vitamui-snack-bar'; import {AdminDslService} from './admin-dsl.service'; -import {VitamUISnackBar} from "../shared/vitamui-snack-bar"; @Component({ selector: 'app-admin-dsl', @@ -106,8 +106,8 @@ export class AdminDslComponent extends AppRootComponent implements OnInit { const dsl = this.form.value.dsl; try { return dsl.length > 1 && !!JSON.parse(dsl); - } catch(syntaxError) { - this.snackBar.open("Format de la requête invalide", null, { + } catch (syntaxError) { + this.snackBar.open('Format de la requête invalide', null, { panelClass: 'vitamui-snack-bar', duration: 1000 }); diff --git a/ui/ui-frontend/projects/referential/src/app/audit/audit.component.spec.ts b/ui/ui-frontend/projects/referential/src/app/audit/audit.component.spec.ts index 9866f56bd0104b8d0800b075ea3552cef3d2dca4..22e5ef458088151c2ace03a68cb7d24170ca8cd9 100644 --- a/ui/ui-frontend/projects/referential/src/app/audit/audit.component.spec.ts +++ b/ui/ui-frontend/projects/referential/src/app/audit/audit.component.spec.ts @@ -4,7 +4,7 @@ import {NO_ERRORS_SCHEMA} from '@angular/core'; import {FormBuilder, ReactiveFormsModule} from '@angular/forms'; import {MatDialog, MatDialogRef, MatSelectModule, MatSidenavModule} from '@angular/material'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {ActivatedRoute} from '@angular/router'; +import {ActivatedRoute, Router} from '@angular/router'; import {of} from 'rxjs'; import {GlobalEventService, InjectorModule, LoggerModule} from 'ui-frontend-common'; import {VitamUICommonTestModule} from 'ui-frontend-common/testing'; @@ -22,6 +22,7 @@ describe('AuditComponent', () => { params: of({tenantIdentifier: 1}), data: of({appId: 'AUDIT_APP'}) }; + const routerSpy = jasmine.createSpyObj('Router', ['navigate']); TestBed.configureTestingModule({ imports: @@ -40,7 +41,8 @@ describe('AuditComponent', () => { GlobalEventService, {provide: MatDialogRef, useValue: matDialogRefSpy}, {provide: MatDialog, useValue: {}}, - {provide: ActivatedRoute, useValue: activatedRouteMock} + {provide: ActivatedRoute, useValue: activatedRouteMock}, + {provide: Router, useValue: routerSpy} ], schemas: [NO_ERRORS_SCHEMA] }) diff --git a/ui/ui-frontend/projects/referential/src/app/context/context-create/context-create.validators.ts b/ui/ui-frontend/projects/referential/src/app/context/context-create/context-create.validators.ts index 5baf61edf6edfe68d37578e2a9b90ed45f621b6e..acbefb3fff1e0188db3057134a7e7c4dd6c87709 100644 --- a/ui/ui-frontend/projects/referential/src/app/context/context-create/context-create.validators.ts +++ b/ui/ui-frontend/projects/referential/src/app/context/context-create/context-create.validators.ts @@ -38,8 +38,8 @@ import {Injectable} from '@angular/core'; import {AbstractControl, AsyncValidatorFn} from '@angular/forms'; import {of, timer} from 'rxjs'; -import {ContextPermission} from "vitamui-library"; import {map, switchMap, take} from 'rxjs/operators'; +import {ContextPermission} from 'vitamui-library'; import {ContextService} from '../context.service'; @Injectable() @@ -76,9 +76,9 @@ export class ContextCreateValidators { public permissionInvalid() { return (control: AbstractControl) => { - switch(this.checkTenantsValid(control.value)) { - case 'tenant': return of({ 'permissionsTenant': true }); - case 'empty': return of({ 'noPermissions': true }); + switch (this.checkTenantsValid(control.value)) { + case 'tenant': return of({ permissionsTenant: true }); + case 'empty': return of({ noPermissions: true }); default: return of(null); } }; @@ -89,13 +89,13 @@ export class ContextCreateValidators { return 'empty'; } - for (let permission of value) { + for (const permission of value) { if (!permission.tenant) { return 'tenant'; } } return null; - }; + } } diff --git a/ui/ui-frontend/projects/referential/src/app/context/context-create/context-edit-permission/context-edit-permission.component.ts b/ui/ui-frontend/projects/referential/src/app/context/context-create/context-edit-permission/context-edit-permission.component.ts index f3c41b466e9d763a5b70a18437abdd3af8458152..df4d310ebc7263492ebdc6d9731c8249b33860f2 100644 --- a/ui/ui-frontend/projects/referential/src/app/context/context-create/context-edit-permission/context-edit-permission.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/context/context-create/context-edit-permission/context-edit-permission.component.ts @@ -36,13 +36,13 @@ */ /* tslint:disable:no-use-before-declare */ -import {Component, forwardRef, Input, OnInit} from '@angular/core'; -import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; -import {ContextPermission} from 'projects/vitamui-library/src/public-api'; -import {AuthService, Option} from 'ui-frontend-common'; -import {Tenant} from 'ui-frontend-common/app/modules/models/customer'; -import {AccessContractService} from '../../../access-contract/access-contract.service'; -import {IngestContractService} from '../../../ingest-contract/ingest-contract.service'; +import { Component, forwardRef, Input, OnInit } from '@angular/core'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { ContextPermission } from 'projects/vitamui-library/src/public-api'; +import { AuthService, Option } from 'ui-frontend-common'; +import { Tenant } from 'ui-frontend-common/app/modules/models/customer'; +import { AccessContractService } from '../../../access-contract/access-contract.service'; +import { IngestContractService } from '../../../ingest-contract/ingest-contract.service'; export const CONTEXT_PERMISSION_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, @@ -58,9 +58,10 @@ export const CONTEXT_PERMISSION_VALUE_ACCESSOR: any = { }) export class ContextEditPermissionComponent implements ControlValueAccessor, OnInit { - constructor(private accessService: AccessContractService, - private ingestService: IngestContractService, - private authService: AuthService) { + constructor( + private accessService: AccessContractService, + private ingestService: IngestContractService, + private authService: AuthService) { } permissions: ContextPermission[]; @@ -84,7 +85,7 @@ export class ContextEditPermissionComponent implements ControlValueAccessor, OnI const accessTenants: Tenant[] = accessTenantsInfo ? accessTenantsInfo.tenants : []; accessTenants.forEach((tenant) => { if (!this.tenants.find(appTenant => appTenant.key === '' + tenant.identifier)) { - this.tenants.push({key: '' + tenant.identifier, label: tenant.name}); + this.tenants.push({ key: '' + tenant.identifier, label: tenant.name }); } this.accessService.getAllForTenant('' + tenant.identifier).subscribe( accessContracts => { @@ -100,7 +101,7 @@ export class ContextEditPermissionComponent implements ControlValueAccessor, OnI const ingestTenants: Tenant[] = ingestTenantsInfo ? ingestTenantsInfo.tenants : []; ingestTenants.forEach((tenant) => { if (!this.tenants.find(appTenant => appTenant.key === '' + tenant.identifier)) { - this.tenants.push({key: '' + tenant.identifier, label: tenant.name}); + this.tenants.push({ key: '' + tenant.identifier, label: tenant.name }); } this.ingestService.getAllForTenant('' + tenant.identifier).subscribe( ingestContracts => { @@ -117,29 +118,39 @@ export class ContextEditPermissionComponent implements ControlValueAccessor, OnI onDelete(index: number) { this.permissions.splice(index, 1); - this.onChange && this.onChange(this.permissions); + if (this.onChange) { + this.onChange(this.permissions); + } } onAdd() { - this.permissions.push({tenant: '', accessContracts: [], ingestContracts: []}); - this.onChange && this.onChange(this.permissions); + this.permissions.push({ tenant: '', accessContracts: [], ingestContracts: [] }); + if (this.onChange) { + this.onChange(this.permissions); + } } onTenantSelect() { - this.onChange && this.onChange(this.permissions); + if (this.onChange) { + this.onChange(this.permissions); + } } onContractSelect() { - this.onChange && this.onChange(this.permissions); + if (this.onChange) { + this.onChange(this.permissions); + } } writeValue(value: ContextPermission[]) { if (value) { this.permissions = value; } else { - this.permissions = [{tenant: null, accessContracts: [], ingestContracts: []}]; + this.permissions = [{ tenant: null, accessContracts: [], ingestContracts: [] }]; + } + if (this.onChange) { + this.onChange(this.permissions); } - this.onChange && this.onChange(this.permissions); } registerOnChange(fn: any): void { diff --git a/ui/ui-frontend/projects/referential/src/app/context/context-preview/context-permission-tab/context-permission-tab.component.ts b/ui/ui-frontend/projects/referential/src/app/context/context-preview/context-permission-tab/context-permission-tab.component.ts index 0a9ca865c14fcf9001390a6efbd6d8b52b75f833..7a56473053eeb1a84b80b30146cea975ff2c78ff 100644 --- a/ui/ui-frontend/projects/referential/src/app/context/context-preview/context-permission-tab/context-permission-tab.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/context/context-preview/context-permission-tab/context-permission-tab.component.ts @@ -34,17 +34,17 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-C license and that you accept its terms. */ -import {Component, EventEmitter, Input, Output} from '@angular/core'; -import {FormBuilder, FormGroup, Validators} from '@angular/forms'; -import {Context} from 'projects/vitamui-library/src/public-api'; -import {Observable, of} from 'rxjs'; -import {catchError, filter, map, switchMap} from 'rxjs/operators'; -import {diff} from 'ui-frontend-common'; -import {extend, isEmpty} from 'underscore'; -import {ContextPermission} from "vitamui-library"; +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { Context } from 'projects/vitamui-library/src/public-api'; +import { Observable, of } from 'rxjs'; +import { catchError, filter, map, switchMap } from 'rxjs/operators'; +import { diff } from 'ui-frontend-common'; +import { extend, isEmpty } from 'underscore'; +import { ContextPermission } from 'vitamui-library'; -import {ContextService} from '../../context.service'; -import {ContextCreateValidators} from "../../context-create/context-create.validators"; +import { ContextCreateValidators } from '../../context-create/context-create.validators'; +import { ContextService } from '../../context.service'; @Component({ @@ -57,11 +57,15 @@ export class ContextPermissionTabComponent { @Output() updated: EventEmitter<boolean> = new EventEmitter<boolean>(); form: FormGroup; - previousValue = (): Context => { - return this._context - }; - submited: boolean = false; + submited = false; + + // tslint:disable-next-line:variable-name + private _context: Context; + + previousValue = (): Context => { + return this._context; + } @Input() set context(context: Context) { @@ -69,7 +73,7 @@ export class ContextPermissionTabComponent { context.permissions = []; } - for (let permission of context.permissions) { + for (const permission of context.permissions) { if (!permission.accessContracts) { permission.accessContracts = []; } @@ -83,8 +87,6 @@ export class ContextPermissionTabComponent { this.updated.emit(false); } get context(): Context { return this._context; } - // tslint:disable-next-line:variable-name - private _context: Context; @Input() set readOnly(readOnly: boolean) { @@ -128,11 +130,11 @@ export class ContextPermissionTabComponent { samePermission(p1: ContextPermission[], p2: ContextPermission[]): boolean { if (!p1 && !p2) { return true; } if (!p1 || !p2) { return false; } - if (p1.length != p2.length) { + if (p1.length !== p2.length) { return false; } - for(let i = 0; i < p1.length; i++) { + for (let i = 0; i < p1.length; i++) { if (p1[i].tenant !== p2[i].tenant) { return false; } @@ -165,7 +167,7 @@ export class ContextPermissionTabComponent { prepareSubmit(): Observable<Context> { return of(diff(this.form.getRawValue(), this.previousValue())).pipe( filter((formData) => !isEmpty(formData)), - map((formData) => extend({id: this.previousValue().id, identifier: this.previousValue().identifier}, formData)), + map((formData) => extend({ id: this.previousValue().id, identifier: this.previousValue().identifier }, formData)), switchMap((formData: { id: string, [key: string]: any }) => this.contextService.patch(formData).pipe(catchError(() => of(null))))); } @@ -179,19 +181,18 @@ export class ContextPermissionTabComponent { this.context = response; } ); - },() => { + }, () => { this.submited = false; }); } resetForm(context: Context) { - console.log('Reset: ', context); this.form.reset(context, { emitEvent: false }); - let permissionCopy: ContextPermission[] = []; - for (let permission of context.permissions) { + const permissionCopy: ContextPermission[] = []; + for (const permission of context.permissions) { permissionCopy.push(new ContextPermission(permission.tenant, - [...(permission.accessContracts ? permission.accessContracts: [])], - [...(permission.ingestContracts ? permission.ingestContracts: [])])); + [...(permission.accessContracts ? permission.accessContracts : [])], + [...(permission.ingestContracts ? permission.ingestContracts : [])])); } this.form.controls.permissions.setValue(permissionCopy); } diff --git a/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.spec.ts b/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.spec.ts index 9ee708cbd58aa9dda16431ee7e55c00b542ef1a1..b77faae33dad549e77efda3012b4f0bcc761d22f 100644 --- a/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.spec.ts +++ b/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.spec.ts @@ -12,6 +12,7 @@ describe('IngestContractObjectTabComponent', () => { const ingestContractValue = { everyDataObjectVersion: true, + masterMandatory: true, dataObjectVersion: [''] }; diff --git a/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.ts b/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.ts index 79da8c763ed5474ac4c401b94a9ba09d86848065..c32b63e8dacf083597b67d4b73de6531721a49c0 100644 --- a/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/ingest-contract/ingest-contract-preview/ingest-contract-object-tab/ingest-contract-object-tab.component.ts @@ -28,7 +28,7 @@ export class IngestContractObjectTabComponent implements OnInit { {key: 'Dissemination', label: 'Diffusion', info: ''}, {key: 'Thumbnail', label: 'Vignette', info: ''}, {key: 'TextContent', label: 'Contenu brut', info: ''}, - {key: 'PhysicalMaster', label: 'Originel papier', info: ''} + {key: 'PhysicalMaster', label: 'Original papier', info: ''} ]; previousValue = (): IngestContract => { @@ -59,15 +59,6 @@ export class IngestContractObjectTabComponent implements OnInit { } } - // FIXME: Get list from common var ? - usages: Option[] = [ - { key: 'BinaryMaster', label: 'Original numérique', info: '' }, - { key: 'Dissemination', label: 'Diffusion', info: '' }, - { key: 'Thumbnail', label: 'Vignette', info: '' }, - { key: 'TextContent', label: 'Contenu brut', info: '' }, - { key: 'PhysicalMaster', label: 'Original papier', info: '' } - ]; - constructor( private formBuilder: FormBuilder, private ingestContractService: IngestContractService diff --git a/ui/ui-frontend/projects/referential/src/app/probative-value/probative-value.component.spec.ts b/ui/ui-frontend/projects/referential/src/app/probative-value/probative-value.component.spec.ts index be649c06cea4e3d5ae93e68fc4e8efc4e38fed01..9ac21cee8a9d3b5c6ca5c5fdc7f2b77469eef95b 100644 --- a/ui/ui-frontend/projects/referential/src/app/probative-value/probative-value.component.spec.ts +++ b/ui/ui-frontend/projects/referential/src/app/probative-value/probative-value.component.spec.ts @@ -3,7 +3,7 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormBuilder, ReactiveFormsModule} from '@angular/forms'; import {MatDialog, MatSelectModule, MatSidenavModule} from '@angular/material'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {ActivatedRoute} from '@angular/router'; +import {ActivatedRoute, Router} from '@angular/router'; import {of} from 'rxjs'; import {InjectorModule, LoggerModule} from 'ui-frontend-common'; import {VitamUICommonTestModule} from 'ui-frontend-common/testing'; @@ -34,7 +34,8 @@ describe('ProbativeValueComponent', () => { providers: [ FormBuilder, {provide: MatDialog, useValue: {}}, - {provide: ActivatedRoute, useValue: activatedRouteMock} + {provide: ActivatedRoute, useValue: activatedRouteMock}, + { provide: Router, useValue: { navigate: () => {} } } ], schemas: [NO_ERRORS_SCHEMA] }) diff --git a/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.spec.ts b/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.spec.ts index 0186b68aeafde34544ab026480f848a8375115fd..163c624940437b3d7f64fbebda325b4ee35202f3 100644 --- a/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.spec.ts +++ b/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.spec.ts @@ -35,22 +35,34 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {ActivatedRoute} from '@angular/router'; import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { AuthService } from '../../../auth.service'; -import { LogbookService } from '../../logbook.service'; +import {of} from 'rxjs'; +import {AccessContractService} from '../../../access-contract/access-contract.service'; +import {SecurisationService} from '../../securisation.service'; import { SecurisationCheckTabComponent } from './securisation-check-tab.component'; -describe('OperationHistoryTabComponent', () => { +fdescribe('SecurisationCheckTabComponent', () => { let component: SecurisationCheckTabComponent; let fixture: ComponentFixture<SecurisationCheckTabComponent>; beforeEach(async(() => { + const activatedRouteMock = { + params: of({tenantIdentifier: 1}), + data: of({appId: 'TRACEABILITY_APP'}) + }; + + const accessContractServiceMock = { + getAllForTenant: () => of([]) + }; + TestBed.configureTestingModule({ declarations: [ SecurisationCheckTabComponent ], providers: [ - { provide: AuthService, useValue: {}}, - { provide: LogbookService, useValue: {}}, + {provide: AccessContractService, useValue: accessContractServiceMock}, + {provide: SecurisationService, useValue: {}}, + {provide: ActivatedRoute, useValue: activatedRouteMock} ], schemas: [NO_ERRORS_SCHEMA], }) diff --git a/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.ts b/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.ts index 53a11ad9a997772927950926199db95eeaf2b59d..2d679f59878d383c114d3bf951832f52a1c29dca 100644 --- a/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.ts +++ b/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-check-tab/securisation-check-tab.component.ts @@ -34,13 +34,12 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-C license and that you accept its terms. */ -import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; - -import { SecurisationService } from "../../securisation.service"; -import {AccessContractService} from "../../../access-contract/access-contract.service"; -import {ActivatedRoute} from "@angular/router"; -import {AccessContract} from "vitamui-library"; -import {ApiEvent, Event, LogbookApiService} from "ui-frontend-common"; +import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {ApiEvent, Event, LogbookApiService} from 'ui-frontend-common'; +import {AccessContract} from 'vitamui-library'; +import {AccessContractService} from '../../../access-contract/access-contract.service'; +import {SecurisationService} from '../../securisation.service'; @Component({ selector: 'app-securisation-check-tab', @@ -48,7 +47,7 @@ import {ApiEvent, Event, LogbookApiService} from "ui-frontend-common"; styleUrls: ['./securisation-check-tab.component.scss'] }) -export class SecurisationCheckTabComponent implements OnChanges { +export class SecurisationCheckTabComponent implements OnChanges, OnInit { @Input() id: string; events: Event[] = []; @@ -57,7 +56,10 @@ export class SecurisationCheckTabComponent implements OnChanges { accessContracts: AccessContract[]; accessContractId: string; - constructor(private securisationService: SecurisationService, private accessContractService: AccessContractService, private route: ActivatedRoute) { } + constructor( + private securisationService: SecurisationService, + private accessContractService: AccessContractService, + private route: ActivatedRoute) { } ngOnInit() { @@ -85,6 +87,6 @@ export class SecurisationCheckTabComponent implements OnChanges { this.securisationService.checkTraceabilityOperation(this.id, this.accessContractId).subscribe((response: {$results: ApiEvent[]}) => { this.events = response.$results.map(LogbookApiService.toEvent)[0].events; this.display = true; - }) + }); } } diff --git a/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-preview.module.ts b/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-preview.module.ts index e5be9d1d36e6110c3b4cafed171a0d415d74d13e..f0da3097ce3090c7330eb56d83b7b2cfeb280a49 100644 --- a/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-preview.module.ts +++ b/ui/ui-frontend/projects/referential/src/app/securisation/securisation-preview/securisation-preview.module.ts @@ -15,7 +15,7 @@ import {RouterModule} from '@angular/router'; import {NgxFilesizeModule} from 'ngx-filesize'; import {VitamUILibraryModule} from 'projects/vitamui-library/src/public-api'; import {VitamUICommonModule} from 'ui-frontend-common'; -import { SecurisationCheckTabComponent } from "./securisation-check-tab/securisation-check-tab.component"; +import {SecurisationCheckTabComponent} from './securisation-check-tab/securisation-check-tab.component'; import {SecurisationInformationTabComponent} from './securisation-information-tab/securisation-information-tab.component'; import {SecurisationPreviewComponent} from './securisation-preview.component'; diff --git a/ui/ui-frontend/projects/referential/src/app/securisation/securisation.component.spec.ts b/ui/ui-frontend/projects/referential/src/app/securisation/securisation.component.spec.ts index 0b9f2d4affe89588fb82c01987102a64d555f22c..5b8e7e799b3093ffb55e317f4aa971c3b7278292 100644 --- a/ui/ui-frontend/projects/referential/src/app/securisation/securisation.component.spec.ts +++ b/ui/ui-frontend/projects/referential/src/app/securisation/securisation.component.spec.ts @@ -4,7 +4,7 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormBuilder} from '@angular/forms'; import {MatDatepickerModule, MatDialog, MatNativeDateModule, MatSidenavModule} from '@angular/material'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {ActivatedRoute} from '@angular/router'; +import {ActivatedRoute, Router} from '@angular/router'; import {of} from 'rxjs'; import {GlobalEventService, InjectorModule, LoggerModule} from 'ui-frontend-common'; @@ -35,7 +35,8 @@ describe('SecurisationComponent', () => { FormBuilder, GlobalEventService, {provide: MatDialog, useValue: {}}, - {provide: ActivatedRoute, useValue: activatedRouteMock} + {provide: ActivatedRoute, useValue: activatedRouteMock}, + {provide: Router, useValue: { navigate: () => {} }} ], schemas: [NO_ERRORS_SCHEMA] })