diff --git a/src/test/javascript/spec/component/competencies/competency-form.component.spec.ts b/src/test/javascript/spec/component/competencies/competency-form.component.spec.ts index ef0419633a47..88fbfac87666 100644 --- a/src/test/javascript/spec/component/competencies/competency-form.component.spec.ts +++ b/src/test/javascript/spec/component/competencies/competency-form.component.spec.ts @@ -31,13 +31,13 @@ describe('CompetencyFormComponent', () => { }) .overrideModule(ArtemisMarkdownEditorModule, { remove: { exports: [MarkdownEditorMonacoComponent] }, - add: { exports: [MockComponent(MarkdownEditorMonacoComponent)], declarations: [MockComponent(MarkdownEditorMonacoComponent)] }, + add: { exports: [MockComponent(MarkdownEditorMonacoComponent)], imports: [MockComponent(MarkdownEditorMonacoComponent)] }, }) - .compileComponents() - .then(() => { - competencyFormComponentFixture = TestBed.createComponent(CompetencyFormComponent); - competencyFormComponent = competencyFormComponentFixture.componentInstance; - }); + .compileComponents(); + + competencyFormComponentFixture = TestBed.createComponent(CompetencyFormComponent); + competencyFormComponent = competencyFormComponentFixture.componentInstance; + translateService = TestBed.inject(TranslateService); }); diff --git a/src/test/javascript/spec/component/competencies/components/course-competencies-relation-graph.component.spec.ts b/src/test/javascript/spec/component/competencies/components/course-competencies-relation-graph.component.spec.ts index 561f3ae5bd07..8741d1364284 100644 --- a/src/test/javascript/spec/component/competencies/components/course-competencies-relation-graph.component.spec.ts +++ b/src/test/javascript/spec/component/competencies/components/course-competencies-relation-graph.component.spec.ts @@ -10,8 +10,15 @@ describe('CourseCompetenciesRelationGraphComponent', () => { let fixture: ComponentFixture; const courseCompetencies: CourseCompetency[] = [ - { id: 1, type: CourseCompetencyType.COMPETENCY, title: 'Competency' }, - { id: 2, type: CourseCompetencyType.PREREQUISITE, title: 'Prerequisite' }, + { id: 1, type: CourseCompetencyType.COMPETENCY, title: 'Competency', dimension: { height: 45.59, width: 0 }, meta: { forceDimensions: false }, position: { x: 0, y: 0 } }, + { + id: 2, + type: CourseCompetencyType.PREREQUISITE, + title: 'Prerequisite', + dimension: { height: 45.59, width: 0 }, + meta: { forceDimensions: false }, + position: { x: 0, y: 0 }, + }, ]; const relations: CompetencyRelationDTO[] = [ @@ -80,6 +87,9 @@ describe('CourseCompetenciesRelationGraphComponent', () => { id: cc.id, type: cc.type, }, + dimension: cc.dimension, + meta: cc.meta, + position: cc.position, }; }), ); diff --git a/src/test/javascript/spec/component/import/exercise-import.component.spec.ts b/src/test/javascript/spec/component/import/exercise-import.component.spec.ts index ae6201f3dea5..1bade48c017c 100644 --- a/src/test/javascript/spec/component/import/exercise-import.component.spec.ts +++ b/src/test/javascript/spec/component/import/exercise-import.component.spec.ts @@ -269,8 +269,7 @@ describe('ExerciseImportComponent', () => { comp.exerciseType = exerciseType; comp.ngOnInit(); - - expect(getSpy).toHaveBeenCalledExactlyOnceWith(expectedPagingService, undefined, 0); // default values for arguments 2 and 3 + expect(getSpy).toHaveBeenCalledWith(expectedPagingService, {}); }), ); @@ -285,7 +284,7 @@ describe('ExerciseImportComponent', () => { comp.ngOnInit(); expect(comp.titleKey).toContain('configureGrading'); - expect(getSpy).toHaveBeenCalledExactlyOnceWith(CodeAnalysisPagingService, undefined, 0); + expect(getSpy).toHaveBeenCalledWith(CodeAnalysisPagingService, {}); }); it('should sort by exam title when only the exam filter is active', () => { diff --git a/src/test/javascript/spec/component/tutorial-groups/helpers/tutorialGroupExampleModels.ts b/src/test/javascript/spec/component/tutorial-groups/helpers/tutorialGroupExampleModels.ts index 1d55425cf1a1..1712e6badc50 100644 --- a/src/test/javascript/spec/component/tutorial-groups/helpers/tutorialGroupExampleModels.ts +++ b/src/test/javascript/spec/component/tutorial-groups/helpers/tutorialGroupExampleModels.ts @@ -1,7 +1,6 @@ import { TutorialGroup } from 'app/entities/tutorial-group/tutorial-group.model'; import { Course } from 'app/entities/course.model'; -import { User } from 'app/core/user/user.model'; -import { TutorialGroupFormData } from 'app/course/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/tutorial-group-form/tutorial-group-form.component'; +import { TutorialGroupFormData, UserWithLabel } from 'app/course/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/tutorial-group-form/tutorial-group-form.component'; import dayjs from 'dayjs/esm'; export const generateExampleTutorialGroup = ({ @@ -12,7 +11,7 @@ export const generateExampleTutorialGroup = ({ language = 'ENGLISH', additionalInformation = 'Example Additional Information', isOnline = false, - teachingAssistant = { id: 1, login: 'Example TA' } as User, + teachingAssistant = { id: 1, login: 'Example TA', label: '(Example TA)' } as UserWithLabel, isUserRegistered = false, isUserTutor = false, numberOfRegisteredUsers = 5, diff --git a/src/test/javascript/spec/component/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/edit-tutorial-group.component.spec.ts b/src/test/javascript/spec/component/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/edit-tutorial-group.component.spec.ts index 979a8c999a5a..f857e82dae11 100644 --- a/src/test/javascript/spec/component/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/edit-tutorial-group.component.spec.ts +++ b/src/test/javascript/spec/component/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/edit-tutorial-group.component.spec.ts @@ -1,19 +1,22 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MockPipe, MockProvider } from 'ng-mocks'; +import { MockProvider } from 'ng-mocks'; import { AlertService } from 'app/core/util/alert.service'; import { Router } from '@angular/router'; import { MockRouter } from '../../../../../helpers/mocks/mock-router'; import { of } from 'rxjs'; import { TutorialGroupsService } from 'app/course/tutorial-groups/services/tutorial-groups.service'; -import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe'; import { HttpResponse } from '@angular/common/http'; import { TutorialGroup } from 'app/entities/tutorial-group/tutorial-group.model'; import { By } from '@angular/platform-browser'; import { EditTutorialGroupComponent } from 'app/course/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/edit-tutorial-group/edit-tutorial-group.component'; -import { TutorialGroupFormStubComponent } from '../../../stubs/tutorial-group-form-stub.component'; -import { LoadingIndicatorContainerStubComponent } from '../../../../../helpers/stubs/loading-indicator-container-stub.component'; import { generateExampleTutorialGroup, tutorialGroupToTutorialGroupFormData } from '../../../helpers/tutorialGroupExampleModels'; import { mockedActivatedRoute } from '../../../../../helpers/mocks/activated-route/mock-activated-route-query-param-map'; +import { ArtemisTestModule } from '../../../../../test.module'; +import '@angular/localize/init'; +import { OwlNativeDateTimeModule } from '@danielmoncada/angular-datetime-picker'; +import { ArtemisDatePipe } from '../../../../../../../../main/webapp/app/shared/pipes/artemis-date.pipe'; +import { MockResizeObserver } from '../../../../../helpers/mocks/service/mock-resize-observer'; +import { TutorialGroupFormComponent } from '../../../../../../../../main/webapp/app/course/tutorial-groups/tutorial-groups-management/tutorial-groups/crud/tutorial-group-form/tutorial-group-form.component'; describe('EditTutorialGroupComponent', () => { let fixture: ComponentFixture; @@ -26,12 +29,11 @@ describe('EditTutorialGroupComponent', () => { const router = new MockRouter(); - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [], - declarations: [EditTutorialGroupComponent, LoadingIndicatorContainerStubComponent, TutorialGroupFormStubComponent, MockPipe(ArtemisTranslatePipe)], + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ArtemisTestModule, EditTutorialGroupComponent, OwlNativeDateTimeModule], providers: [ - MockProvider(TutorialGroupsService), + MockProvider(ArtemisDatePipe), MockProvider(AlertService), { provide: Router, useValue: router }, mockedActivatedRoute( @@ -43,23 +45,25 @@ describe('EditTutorialGroupComponent', () => { {}, ), ], - }) - .compileComponents() - .then(() => { - fixture = TestBed.createComponent(EditTutorialGroupComponent); - component = fixture.componentInstance; - exampleTutorialGroup = generateExampleTutorialGroup({}); - - tutorialGroupService = TestBed.inject(TutorialGroupsService); - - const response: HttpResponse = new HttpResponse({ - body: exampleTutorialGroup, - status: 200, - }); - - findTutorialGroupSpy = jest.spyOn(tutorialGroupService, 'getOneOfCourse').mockReturnValue(of(response)); - fixture.detectChanges(); - }); + }).compileComponents(); + + fixture = TestBed.createComponent(EditTutorialGroupComponent); + component = fixture.componentInstance; + exampleTutorialGroup = generateExampleTutorialGroup({}); + + tutorialGroupService = TestBed.inject(TutorialGroupsService); + + const response: HttpResponse = new HttpResponse({ + body: exampleTutorialGroup, + status: 200, + }); + + global.ResizeObserver = jest.fn().mockImplementation((callback: ResizeObserverCallback) => { + return new MockResizeObserver(callback); + }); + + findTutorialGroupSpy = jest.spyOn(tutorialGroupService, 'getOneOfCourse').mockReturnValue(of(response)); + fixture.detectChanges(); }); afterEach(() => { @@ -73,14 +77,14 @@ describe('EditTutorialGroupComponent', () => { }); it('should set form data correctly', () => { - const tutorialGroupFormStubComponent: TutorialGroupFormStubComponent = fixture.debugElement.query(By.directive(TutorialGroupFormStubComponent)).componentInstance; + const tutorialGroupFormComponent: TutorialGroupFormComponent = fixture.debugElement.query(By.directive(TutorialGroupFormComponent)).componentInstance; expect(component.tutorialGroup).toEqual(exampleTutorialGroup); expect(findTutorialGroupSpy).toHaveBeenCalledWith(2, 1); expect(findTutorialGroupSpy).toHaveBeenCalledOnce(); expect(component.formData).toEqual(tutorialGroupToTutorialGroupFormData(exampleTutorialGroup)); - expect(tutorialGroupFormStubComponent.formData).toEqual(component.formData); + expect(tutorialGroupFormComponent.formData).toEqual(component.formData); }); it('should send PUT request upon form submission and navigate', () => { @@ -106,7 +110,7 @@ describe('EditTutorialGroupComponent', () => { const updatedStub = jest.spyOn(tutorialGroupService, 'update').mockReturnValue(of(updateResponse)); const navigateSpy = jest.spyOn(router, 'navigate'); - const tutorialGroupForm: TutorialGroupFormStubComponent = fixture.debugElement.query(By.directive(TutorialGroupFormStubComponent)).componentInstance; + const tutorialGroupForm: TutorialGroupFormComponent = fixture.debugElement.query(By.directive(TutorialGroupFormComponent)).componentInstance; const formData = tutorialGroupToTutorialGroupFormData(changedTutorialGroup);