From 2f811a5ad7efad5108d7146d2777bef53b5ccb38 Mon Sep 17 00:00:00 2001 From: Florian Glombik Date: Sat, 2 Nov 2024 23:39:23 +0100 Subject: [PATCH] Fix client tests --- .../attachment-unit-form.component.ts | 4 ++-- .../attachment-unit-form.component.spec.ts | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts b/src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts index e48e513cdb2f..2d41ce99db23 100644 --- a/src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts +++ b/src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts @@ -3,7 +3,7 @@ import dayjs from 'dayjs/esm'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { faQuestionCircle, faTimes } from '@fortawesome/free-solid-svg-icons'; import { ACCEPTED_FILE_EXTENSIONS_FILE_BROWSER, ALLOWED_FILE_EXTENSIONS_HUMAN_READABLE } from 'app/shared/constants/file-extensions.constants'; -import { Competency, CompetencyLectureUnitLink } from 'app/entities/competency.model'; +import { CompetencyLectureUnitLink } from 'app/entities/competency.model'; import { MAX_FILE_SIZE } from 'app/shared/constants/input.constants'; import { toSignal } from '@angular/core/rxjs-interop'; @@ -62,7 +62,7 @@ export class AttachmentUnitFormComponent implements OnChanges { releaseDate: [undefined as dayjs.Dayjs | undefined], version: [{ value: 1, disabled: true }], updateNotificationText: [undefined as string | undefined, [Validators.maxLength(1000)]], - competencies: [undefined as Competency[] | undefined], + competencyLinks: [undefined as CompetencyLectureUnitLink[] | undefined], }); private readonly statusChanges = toSignal(this.form.statusChanges ?? 'INVALID'); diff --git a/src/test/javascript/spec/component/lecture-unit/attachment-unit/attachment-unit-form.component.spec.ts b/src/test/javascript/spec/component/lecture-unit/attachment-unit/attachment-unit-form.component.spec.ts index 4037d5764924..fa218d84c467 100644 --- a/src/test/javascript/spec/component/lecture-unit/attachment-unit/attachment-unit-form.component.spec.ts +++ b/src/test/javascript/spec/component/lecture-unit/attachment-unit/attachment-unit-form.component.spec.ts @@ -1,12 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; -import { TranslateService } from '@ngx-translate/core'; import { AttachmentUnitFormComponent, AttachmentUnitFormData } from 'app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component'; import { FormDateTimePickerComponent } from 'app/shared/date-time-picker/date-time-picker.component'; import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe'; import dayjs from 'dayjs/esm'; -import { MockComponent, MockDirective, MockPipe, MockProviders } from 'ng-mocks'; +import { MockComponent, MockDirective, MockPipe } from 'ng-mocks'; import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; import { CompetencySelectionComponent } from 'app/shared/competency-selection/competency-selection.component'; import { MAX_FILE_SIZE } from 'app/shared/constants/input.constants'; @@ -25,7 +24,6 @@ describe('AttachmentUnitFormComponent', () => { MockComponent(FaIconComponent), MockComponent(CompetencySelectionComponent), ], - providers: [MockProviders(TranslateService)], schemas: [], }) .compileComponents() @@ -71,7 +69,7 @@ describe('AttachmentUnitFormComponent', () => { expect(attachmentUnitFormComponent.descriptionControl?.value).toEqual(formData.formProperties.description); expect(attachmentUnitFormComponent.versionControl?.value).toEqual(formData.formProperties.version); expect(attachmentUnitFormComponent.updateNotificationTextControl?.value).toEqual(formData.formProperties.updateNotificationText); - expect(attachmentUnitFormComponent.fileName).toEqual(formData.fileProperties.fileName); + expect(attachmentUnitFormComponent.fileName()).toEqual(formData.fileProperties.fileName); expect(attachmentUnitFormComponent.file).toEqual(formData.fileProperties.file); }); it('should submit valid form', () => { @@ -90,7 +88,7 @@ describe('AttachmentUnitFormComponent', () => { const fakeFile = new File([''], 'Test-File.pdf', { type: 'application/pdf' }); attachmentUnitFormComponent.file = fakeFile; const exampleFileName = 'lorem Ipsum'; - attachmentUnitFormComponent.fileName = exampleFileName; + attachmentUnitFormComponent.fileName.set(exampleFileName); attachmentUnitFormComponentFixture.detectChanges(); expect(attachmentUnitFormComponent.form.valid).toBeTrue(); @@ -132,7 +130,7 @@ describe('AttachmentUnitFormComponent', () => { attachmentUnitFormComponent.updateNotificationTextControl!.setValue(exampleUpdateNotificationText); const fakeFile = new File([''], 'Test-File.pdf', { type: 'application/pdf' }); attachmentUnitFormComponent.file = fakeFile; - attachmentUnitFormComponent.fileName = 'lorem Ipsum'; + attachmentUnitFormComponent.fileName.set('lorem Ipsum'); expect(attachmentUnitFormComponent.form.invalid).toBeTrue(); const submitFormSpy = jest.spyOn(attachmentUnitFormComponent, 'submitForm'); @@ -166,7 +164,7 @@ describe('AttachmentUnitFormComponent', () => { attachmentUnitFormComponentFixture.detectChanges(); const submitButton = attachmentUnitFormComponentFixture.debugElement.nativeElement.querySelector('#submitButton'); - expect(attachmentUnitFormComponent.isFileTooBig).toBeTrue(); + expect(attachmentUnitFormComponent.isFileTooBig()).toBeTrue(); expect(submitButton.disabled).toBeTrue(); }); });