From 2dd9d3d39be1f6166d58fc1d24c8d899f14c8f75 Mon Sep 17 00:00:00 2001 From: Daniel Appelgren Date: Tue, 21 Sep 2021 10:46:49 +0200 Subject: [PATCH] Merge pull request #110 in TEA/mina-sidor-fa-web from fix-Fixed-some-failing-tests to develop Squashed commit of the following: commit ff92c6bd63560c8e0dab6c711c09150fbaf7ce37 Author: Daniel Appelgren Date: Tue Sep 21 10:46:33 2021 +0200 fix comments and type commit 3d246398a3a4d5b0397cdfda7aa8b7e2f285303e Merge: d4d00f4 91eeb1d Author: Daniel Appelgren Date: Tue Sep 21 10:43:11 2021 +0200 Merge branch 'develop' into fix-Fixed-some-failing-tests commit d4d00f447b8641167c5c6a19c64cb9303d5bd5e9 Author: Daniel Appelgren Date: Mon Sep 20 14:11:24 2021 +0200 Fix lint errors commit 3b203efbc92380a9fadba1521c83c22debb49420 Author: Daniel Appelgren Date: Mon Sep 20 14:05:42 2021 +0200 Fix failing tests & type fails commit b26ab4e13aa646b90431608c697c9d40ca41e67d Author: Daniel Appelgren Date: Mon Sep 20 13:50:26 2021 +0200 Fix: Fixed failing tests --- .../src/app/pages/avrop/avrop.component.spec.ts | 13 +------------ .../src/app/pages/avrop/avrop.component.ts | 9 +++------ .../src/app/pages/avrop/avrop.module.ts | 2 +- .../avrop-filters/avrop-filters.component.spec.ts | 6 +++--- .../deltagare-card/deltagare-card.component.ts | 4 ++-- .../components/loader/loader.component.spec.ts | 10 +++++----- .../app/shared/components/loader/loader.module.ts | 3 +-- .../multiselect/multiselect.component.spec.ts | 2 ++ .../components/multiselect/multiselect.component.ts | 3 +++ .../src/app/shared/services/avrop.service.ts | 10 +++++----- 10 files changed, 26 insertions(+), 36 deletions(-) diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts index 9f7bd9c..b291fbf 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts @@ -1,12 +1,8 @@ -import { DigiNgProgressProgressbarModule } from '@af/digi-ng/_progress/progressbar'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { LayoutModule } from '@msfa-shared/components/layout/layout.module'; import { AvropComponent } from './avrop.component'; -import { AvropFiltersModule } from './components/avrop-filters/avrop-filters.module'; -import { AvropListModule } from './components/avrop-list/avrop-list.module'; describe('AvropComponent', () => { let component: AvropComponent; @@ -16,14 +12,7 @@ describe('AvropComponent', () => { waitForAsync(() => { void TestBed.configureTestingModule({ declarations: [AvropComponent], - imports: [ - RouterTestingModule, - HttpClientTestingModule, - DigiNgProgressProgressbarModule, - LayoutModule, - AvropFiltersModule, - AvropListModule, - ], + imports: [RouterTestingModule, HttpClientTestingModule], schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); }) diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts index 22345a4..227df83 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts @@ -1,8 +1,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { Avrop, AvropCompactData } from '@msfa-models/avrop.model'; +import { Avrop, AvropCompact, AvropCompactData } from '@msfa-models/avrop.model'; import { Handledare } from '@msfa-models/handledare.model'; import { AvropService } from '@msfa-services/avrop.service'; -import { MultiselectFilterOption } from '@msfa-shared/components/multiselect/multiselect-filter-option'; import { Observable } from 'rxjs'; @Component({ @@ -16,10 +15,8 @@ export class AvropComponent { currentStep$: Observable = this.avropService.currentStep$; error$: Observable = this.avropService.error$; - filteredUtforandeVerksamheter$: Observable = this.avropService - .filteredUtforandeVerksamheter$; avropData$: Observable = this.avropService.avropData$; - selectedAvrop$: Observable = this.avropService.selectedAvrop$; + selectedAvrop$: Observable = this.avropService.selectedAvrop$; availableHandledare$: Observable = this.avropService.availableHandledare$; selectedHandledare$: Observable = this.avropService.selectedHandledare$; avropIsLocked$: Observable = this.avropService.avropIsLocked$; @@ -29,7 +26,7 @@ export class AvropComponent { constructor(private avropService: AvropService) {} - updateSelectedAvrop(deltagareList: Avrop[], currentStep: number): void { + updateSelectedAvrop(deltagareList: AvropCompact[], currentStep: number): void { if (currentStep !== 1 && !deltagareList.length) { this.avropService.goToStep1(); } else { diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts index 9368882..615c24c 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts @@ -4,10 +4,10 @@ import { CommonModule } from '@angular/common'; import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { LayoutModule } from '@msfa-shared/components/layout/layout.module'; -import { LoaderModule } from '@msfa-shared/components/loader/loader.module'; import { AvropComponent } from './avrop.component'; import { AvropFiltersModule } from './components/avrop-filters/avrop-filters.module'; import { AvropListModule } from './components/avrop-list/avrop-list.module'; +import { LoaderModule } from '@msfa-shared/components/loader/loader.module'; @NgModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts index 387cc97..0dd71a4 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts @@ -47,9 +47,9 @@ describe('AvropFiltersComponent', () => { discardPeriodicTasks(); })); - it('should show loading spinners when filters are loading', () => { + it('should show loading spinner when filters are loading', () => { fixture.detectChanges(); - const tags = fixture.debugElement.queryAll(By.css('digi-icon-spinner')); - expect(tags.length).toBe(3); + const tags = fixture.debugElement.queryAll(By.css('msfa-loader')); + expect(tags.length).toBe(1); }); }); diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-card/deltagare-card.component.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-card/deltagare-card.component.ts index 31edd1b..e88fa12 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-card/deltagare-card.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-card/deltagare-card.component.ts @@ -69,10 +69,10 @@ export class DeltagareCardComponent { switch (reportType) { case 'planering': - this.reportsFormControl.valid ? this.router.navigate(['/deltagare/planering', deltagareId]) : null; + this.reportsFormControl.valid ? void this.router.navigate(['/deltagare/planering', deltagareId]) : null; break; case 'avvikelse': - this.reportsFormControl.valid ? this.router.navigate(['/deltagare/rapportera', deltagareId]) : null; + this.reportsFormControl.valid ? void this.router.navigate(['/deltagare/rapportera', deltagareId]) : null; break; default: return; diff --git a/apps/mina-sidor-fa/src/app/shared/components/loader/loader.component.spec.ts b/apps/mina-sidor-fa/src/app/shared/components/loader/loader.component.spec.ts index d937e0c..1b7198c 100644 --- a/apps/mina-sidor-fa/src/app/shared/components/loader/loader.component.spec.ts +++ b/apps/mina-sidor-fa/src/app/shared/components/loader/loader.component.spec.ts @@ -1,18 +1,18 @@ /* tslint:disable:no-unused-variable */ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { LoaderComponent } from './loader.component'; describe('LoaderComponent', () => { let component: LoaderComponent; let fixture: ComponentFixture; - beforeEach(async(() => { - void TestBed.configureTestingModule({ - schemas: [CUSTOM_ELEMENTS_SCHEMA], + beforeEach(async () => { + await TestBed.configureTestingModule({ declarations: [LoaderComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); - })); + }); beforeEach(() => { fixture = TestBed.createComponent(LoaderComponent); diff --git a/apps/mina-sidor-fa/src/app/shared/components/loader/loader.module.ts b/apps/mina-sidor-fa/src/app/shared/components/loader/loader.module.ts index b92c4ff..61fef3d 100644 --- a/apps/mina-sidor-fa/src/app/shared/components/loader/loader.module.ts +++ b/apps/mina-sidor-fa/src/app/shared/components/loader/loader.module.ts @@ -1,4 +1,3 @@ -import { DigiNgDialogModule } from '@af/digi-ng/_dialog/dialog'; import { CommonModule } from '@angular/common'; import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { LoaderComponent } from './loader.component'; @@ -6,7 +5,7 @@ import { LoaderComponent } from './loader.component'; @NgModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [LoaderComponent], - imports: [CommonModule, DigiNgDialogModule], + imports: [CommonModule], exports: [LoaderComponent], }) export class LoaderModule {} diff --git a/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.spec.ts b/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.spec.ts index cf12f8e..d317ae6 100644 --- a/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.spec.ts +++ b/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.spec.ts @@ -1,6 +1,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MultiselectComponent } from './multiselect.component'; +import { DropdownModule } from '@msfa-shared/components/dropdown/dropdown.module'; describe('MultiselectComponent', () => { let component: MultiselectComponent; @@ -8,6 +9,7 @@ describe('MultiselectComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ + imports: [DropdownModule], declarations: [MultiselectComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); diff --git a/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.ts b/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.ts index 31ce949..7344eea 100644 --- a/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.ts +++ b/apps/mina-sidor-fa/src/app/shared/components/multiselect/multiselect.component.ts @@ -94,6 +94,9 @@ export class MultiselectComponent implements AfterViewInit, ControlValueAccessor } ngAfterViewInit(): void { + if (!this.dropdownRef) { + return; + } this.dropdownRef.onOpen(() => { // force refresh of selected options if it's reopened this.selectedOptions = [...(this.selectedOptions || [])]; diff --git a/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts b/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts index cb4cd20..33e883e 100644 --- a/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts +++ b/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { Params } from '@msfa-models/api/params.model'; -import { Avrop, AvropCompactData } from '@msfa-models/avrop.model'; +import { AvropCompact, AvropCompactData } from '@msfa-models/avrop.model'; import { Handledare } from '@msfa-models/handledare.model'; import { AvropApiService } from '@msfa-services/api/avrop-api.service'; import { MultiselectFilterOption } from '@msfa-shared/components/multiselect/multiselect-filter-option'; @@ -18,7 +18,7 @@ export class AvropService { private _filteredTjanster$ = new BehaviorSubject(null); private _filteredUtforandeVerksamheter$ = new BehaviorSubject(null); private _filteredKommuner$ = new BehaviorSubject(null); - private _selectedAvrop$ = new BehaviorSubject([]); + private _selectedAvrop$ = new BehaviorSubject([]); private _avropIsLocked$ = new BehaviorSubject(null); private _selectedHandledareId$ = new BehaviorSubject(null); private _handledareIsConfirmed$ = new BehaviorSubject(false); @@ -32,7 +32,7 @@ export class AvropService { MultiselectFilterOption[] > = this._filteredUtforandeVerksamheter$.asObservable(); public filteredKommuner$: Observable = this._filteredKommuner$.asObservable(); - public selectedAvrop$: Observable = this._selectedAvrop$.asObservable(); + public selectedAvrop$: Observable = this._selectedAvrop$.asObservable(); public avropIsLocked$: Observable = this._avropIsLocked$.asObservable(); public selectedHandledare$: Observable = this._selectedHandledareId$.pipe( filter(selectedHandledare => !!selectedHandledare), @@ -80,7 +80,7 @@ export class AvropService { this._filteredUtforandeVerksamheter$, ]).pipe(switchMap(() => this.avropApiService.fetchAvailableKommuner$(this.filtersForKommuner))); - private _lockedAvrop$: Observable = combineLatest([this.selectedAvrop$, this.avropIsLocked$]).pipe( + private _lockedAvrop$: Observable = combineLatest([this.selectedAvrop$, this.avropIsLocked$]).pipe( map(([selectedAvrop, isLocked]) => (isLocked ? selectedAvrop : null)) ); @@ -166,7 +166,7 @@ export class AvropService { }; } - public setSelectedAvrop(deltagare: Avrop[]): void { + public setSelectedAvrop(deltagare: AvropCompact[]): void { this._selectedAvrop$.next(deltagare); }