From a403177b44f0d51edc6bedabba81620764ca8522 Mon Sep 17 00:00:00 2001 From: Lias Kleisa Date: Thu, 30 Nov 2023 16:42:51 +0100 Subject: [PATCH] Fix frontend tests --- .../app/objective/objective.component.spec.ts | 5 +++++ .../check-in-form-metric.component.spec.ts | 5 +++++ .../check-in-form.component.spec.ts | 5 +++++ .../complete-dialog.component.spec.ts | 2 ++ .../key-result-form.component.spec.ts | 5 +++++ .../objective-form.component.spec.ts | 5 +++++ .../team-management.component.spec.ts | 2 ++ frontend/src/app/team/team.component.spec.ts | 21 +++++++++++-------- 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/objective/objective.component.spec.ts b/frontend/src/app/objective/objective.component.spec.ts index 6dc8d69ec7..ecdf43dd01 100644 --- a/frontend/src/app/objective/objective.component.spec.ts +++ b/frontend/src/app/objective/objective.component.spec.ts @@ -19,6 +19,8 @@ import { MatTooltipModule } from '@angular/material/tooltip'; import { ScoringComponent } from '../shared/custom/scoring/scoring.component'; import { ConfidenceComponent } from '../confidence/confidence.component'; import { ReactiveFormsModule } from '@angular/forms'; +import * as de from '../../assets/i18n/de.json'; +import { TranslateTestingModule } from 'ngx-translate-testing'; const overviewServiceMock = { getObjectiveWithKeyresults: jest.fn(), @@ -42,6 +44,9 @@ describe('ObjectiveColumnComponent', () => { MatIconModule, MatTooltipModule, ReactiveFormsModule, + TranslateTestingModule.withTranslations({ + de: de, + }), ], providers: [{ provide: OverviewService, useValue: overviewServiceMock }], }).compileComponents(); diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts index 9962c2d462..2c7d15bb3b 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -11,6 +11,8 @@ import { MatInputModule } from '@angular/material/input'; import { MatRadioModule } from '@angular/material/radio'; import { Unit } from '../../../types/enums/Unit'; import { ParseUnitValuePipe } from '../../../pipes/parse-unit-value/parse-unit-value.pipe'; +import { TranslateTestingModule } from 'ngx-translate-testing'; +import * as de from '../../../../../assets/i18n/de.json'; describe('CheckInFormComponent', () => { let component: CheckInFormMetricComponent; @@ -25,6 +27,9 @@ describe('CheckInFormComponent', () => { MatInputModule, MatRadioModule, ReactiveFormsModule, + TranslateTestingModule.withTranslations({ + de: de, + }), ], declarations: [CheckInFormMetricComponent, UnitValueTransformationPipe], providers: [UnitValueTransformationPipe, ParseUnitValuePipe], diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts index bb5f938552..e63bc52673 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts @@ -23,6 +23,8 @@ import { ParseUnitValuePipe } from '../../../pipes/parse-unit-value/parse-unit-v import { CheckInService } from '../../../services/check-in.service'; import { of } from 'rxjs'; import { ActionService } from '../../../services/action.service'; +import * as de from '../../../../../assets/i18n/de.json'; +import { TranslateTestingModule } from 'ngx-translate-testing'; const dialogMock = { close: jest.fn(), @@ -52,6 +54,9 @@ describe('CheckInFormComponent', () => { MatInputModule, NoopAnimationsModule, MatCheckboxModule, + TranslateTestingModule.withTranslations({ + de: de, + }), ], providers: [ { provide: MAT_DIALOG_DATA, useValue: { keyResult: {} } }, diff --git a/frontend/src/app/shared/dialog/complete-dialog/complete-dialog.component.spec.ts b/frontend/src/app/shared/dialog/complete-dialog/complete-dialog.component.spec.ts index 53b4b9ec22..96dd62fa53 100644 --- a/frontend/src/app/shared/dialog/complete-dialog/complete-dialog.component.spec.ts +++ b/frontend/src/app/shared/dialog/complete-dialog/complete-dialog.component.spec.ts @@ -3,6 +3,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CompleteDialogComponent } from './complete-dialog.component'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { DialogHeaderComponent } from '../../custom/dialog-header/dialog-header.component'; +import { TranslateService } from '@ngx-translate/core'; const dialogMock = { close: jest.fn(), @@ -25,6 +26,7 @@ describe('CompleteDialogComponent', () => { providers: [ { provide: MatDialogRef, useValue: dialogMock }, { provide: MAT_DIALOG_DATA, useValue: matDataMock }, + { provide: TranslateService, useValue: {} }, ], }); fixture = TestBed.createComponent(CompleteDialogComponent); diff --git a/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.spec.ts b/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.spec.ts index 0d8caa98cd..70df372799 100644 --- a/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/key-result-form/key-result-form.component.spec.ts @@ -25,6 +25,8 @@ import { KeyResultFormComponent } from '../key-result-form/key-result-form.compo import { Action } from '../../types/model/Action'; import { KeyResultMetric } from '../../types/model/KeyResultMetric'; import { KeyResultOrdinal } from '../../types/model/KeyResultOrdinal'; +import { TranslateTestingModule } from 'ngx-translate-testing'; +import * as de from '../../../../assets/i18n/de.json'; describe('KeyResultFormComponent', () => { let component: KeyResultFormComponent; @@ -100,6 +102,9 @@ describe('KeyResultFormComponent', () => { MatIconModule, TranslateModule.forRoot(), DragDropModule, + TranslateTestingModule.withTranslations({ + de: de, + }), ], providers: [ KeyresultService, diff --git a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts index 040e880c1f..f4c47ce796 100644 --- a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.spec.ts @@ -24,6 +24,8 @@ import { By } from '@angular/platform-browser'; import { MatCheckboxHarness } from '@angular/material/checkbox/testing'; import { RouterTestingHarness, RouterTestingModule } from '@angular/router/testing'; import { DialogHeaderComponent } from '../../custom/dialog-header/dialog-header.component'; +import { TranslateTestingModule } from 'ngx-translate-testing'; +import * as de from '../../../../assets/i18n/de.json'; let objectiveService = { getFullObjective: jest.fn(), @@ -78,6 +80,9 @@ describe('ObjectiveDialogComponent', () => { NoopAnimationsModule, MatCheckboxModule, RouterTestingModule, + TranslateTestingModule.withTranslations({ + de: de, + }), ], declarations: [ObjectiveFormComponent, DialogHeaderComponent], providers: [ diff --git a/frontend/src/app/shared/dialog/team-management/team-management.component.spec.ts b/frontend/src/app/shared/dialog/team-management/team-management.component.spec.ts index e4e5819190..feadaf94cb 100644 --- a/frontend/src/app/shared/dialog/team-management/team-management.component.spec.ts +++ b/frontend/src/app/shared/dialog/team-management/team-management.component.spec.ts @@ -18,6 +18,7 @@ import { of } from 'rxjs'; import { organisationActive, organisationInActive, teamFormObject, teamMin1 } from '../../testData'; import { Team } from '../../types/model/Team'; import { OrganisationService } from '../../services/organisation.service'; +import { TranslateService } from '@ngx-translate/core'; const dialogRefMock = { close: jest.fn(), @@ -79,6 +80,7 @@ describe('TeamManagementComponent', () => { provide: MAT_DIALOG_DATA, useValue: null, }, + { provide: TranslateService, useValue: {} }, ], }); fixture = TestBed.createComponent(TeamManagementComponent); diff --git a/frontend/src/app/team/team.component.spec.ts b/frontend/src/app/team/team.component.spec.ts index 9923830fff..21f808a76a 100644 --- a/frontend/src/app/team/team.component.spec.ts +++ b/frontend/src/app/team/team.component.spec.ts @@ -1,14 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TeamComponent } from './team.component'; import { MatIcon } from '@angular/material/icon'; -import { - organisationActive, - organisationInActive, - overViewEntity1, - overViewEntity2, - team1, - teamMin1, -} from '../shared/testData'; +import { overViewEntity1, overViewEntity2, team1, teamMin1 } from '../shared/testData'; import { ObjectiveComponent } from '../objective/objective.component'; import { RouterTestingModule } from '@angular/router/testing'; import { MatMenuModule } from '@angular/material/menu'; @@ -19,6 +12,8 @@ import { By } from '@angular/platform-browser'; import { OrganisationService } from '../shared/services/organisation.service'; import { of, ReplaySubject } from 'rxjs'; import { RefreshDataService } from '../shared/services/refresh-data.service'; +import { TranslateTestingModule } from 'ngx-translate-testing'; +import * as de from '../../assets/i18n/de.json'; const organisationServiceMock = { getOrganisationsByTeamId: jest.fn(), @@ -38,7 +33,15 @@ describe('TeamComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [RouterTestingModule, MatMenuModule, MatDialogModule, HttpClientTestingModule], + imports: [ + RouterTestingModule, + MatMenuModule, + MatDialogModule, + HttpClientTestingModule, + TranslateTestingModule.withTranslations({ + de: de, + }), + ], declarations: [TeamComponent, MatIcon, ObjectiveComponent, KeyresultComponent], providers: [ {