From 7346de1a79695d6b30949c17780c881c3c7e3b43 Mon Sep 17 00:00:00 2001 From: Florian Glombik <63976129+florian-glombik@users.noreply.github.com> Date: Sun, 27 Oct 2024 20:27:51 +0100 Subject: [PATCH] Development: Fix DOM event name conflicts (#9589) --- .../assessment-header.component.html | 6 +++--- .../assessment-header.component.ts | 10 ++++------ .../assessment-layout.component.html | 4 ++-- .../assessment-layout.component.ts | 6 ++---- .../complaints-student-view.component.html | 2 +- .../complaints/form/complaints-form.component.ts | 5 ++--- .../assess/file-upload-assessment.component.html | 4 ++-- .../file-upload-exercise-update.component.html | 2 +- .../modeling-assessment-editor.component.html | 4 ++-- .../modeling-exercise-update.component.html | 2 +- ...tor-tutor-assessment-container.component.html | 4 ++-- .../programming-exercise-update.component.html | 2 +- .../text-submission-assessment.component.html | 4 ++-- .../textblock-assessment-card.component.html | 2 +- .../textblock-feedback-editor.component.ts | 4 ++-- .../text-exercise-update.component.html | 2 +- .../forms/form-footer/form-footer.component.html | 2 +- .../forms/form-footer/form-footer.component.ts | 4 ++-- .../assessment-header.component.spec.ts | 16 ++++++++-------- .../complaints/complaints-form.component.spec.ts | 8 ++++---- 20 files changed, 44 insertions(+), 49 deletions(-) diff --git a/src/main/webapp/app/assessment/assessment-header/assessment-header.component.html b/src/main/webapp/app/assessment/assessment-header/assessment-header.component.html index fbf4de107932..47c600031279 100644 --- a/src/main/webapp/app/assessment/assessment-header/assessment-header.component.html +++ b/src/main/webapp/app/assessment/assessment-header/assessment-header.component.html @@ -115,7 +115,7 @@

diff --git a/src/main/webapp/app/forms/form-footer/form-footer.component.ts b/src/main/webapp/app/forms/form-footer/form-footer.component.ts index 378422878b70..bb2192728381 100644 --- a/src/main/webapp/app/forms/form-footer/form-footer.component.ts +++ b/src/main/webapp/app/forms/form-footer/form-footer.component.ts @@ -10,8 +10,8 @@ import { ButtonSize } from 'app/shared/components/button.component'; }) export class FormFooterComponent { @Output() save = new EventEmitter(); - // eslint-disable-next-line @angular-eslint/no-output-native - @Output() cancel = new EventEmitter(); + + @Output() onCancel = new EventEmitter(); @Input() isSaving: boolean = false; @Input() isDisabled: boolean = false; diff --git a/src/test/javascript/spec/component/assessment-shared/assessment-header.component.spec.ts b/src/test/javascript/spec/component/assessment-shared/assessment-header.component.spec.ts index a85e5e47bc16..aa0073961211 100644 --- a/src/test/javascript/spec/component/assessment-shared/assessment-header.component.spec.ts +++ b/src/test/javascript/spec/component/assessment-shared/assessment-header.component.spec.ts @@ -159,14 +159,14 @@ describe('AssessmentHeaderComponent', () => { saveButtonSpan.nativeElement.click(); expect(component.save.emit).toHaveBeenCalledOnce(); - jest.spyOn(component.submit, 'emit'); + jest.spyOn(component.onSubmit, 'emit'); submitButtonSpan.nativeElement.click(); - expect(component.submit.emit).toHaveBeenCalledOnce(); + expect(component.onSubmit.emit).toHaveBeenCalledOnce(); const cancelButtonSpan = fixture.debugElement.query(By.css('[jhiTranslate$=cancel]')); - jest.spyOn(component.cancel, 'emit'); + jest.spyOn(component.onCancel, 'emit'); cancelButtonSpan.nativeElement.click(); - expect(component.cancel.emit).toHaveBeenCalledOnce(); + expect(component.onCancel.emit).toHaveBeenCalledOnce(); }); it('should show override button when result is present', () => { @@ -189,9 +189,9 @@ describe('AssessmentHeaderComponent', () => { overrideAssessmentButtonSpan = fixture.debugElement.query(By.css('[jhiTranslate$=overrideAssessment]')); expect(overrideAssessmentButtonSpan).toBeTruthy(); - jest.spyOn(component.submit, 'emit'); + jest.spyOn(component.onSubmit, 'emit'); overrideAssessmentButtonSpan.nativeElement.click(); - expect(component.submit.emit).toHaveBeenCalledOnce(); + expect(component.onSubmit.emit).toHaveBeenCalledOnce(); }); it('should show next submission if assessor or instructor, result is present and no complaint', () => { @@ -345,7 +345,7 @@ describe('AssessmentHeaderComponent', () => { const eventMock = new KeyboardEvent('keydown', { ctrlKey: true, key: 'Enter' }); const spyOnControlAndEnter = jest.spyOn(component, 'submitOnControlAndEnter'); - const submitSpy = jest.spyOn(component.submit, 'emit'); + const submitSpy = jest.spyOn(component.onSubmit, 'emit'); document.dispatchEvent(eventMock); expect(spyOnControlAndEnter).toHaveBeenCalledOnce(); @@ -362,7 +362,7 @@ describe('AssessmentHeaderComponent', () => { const eventMock = new KeyboardEvent('keydown', { ctrlKey: true, key: 'Enter' }); const spyOnControlAndEnter = jest.spyOn(component, 'submitOnControlAndEnter'); - const submitSpy = jest.spyOn(component.submit, 'emit'); + const submitSpy = jest.spyOn(component.onSubmit, 'emit'); document.dispatchEvent(eventMock); expect(spyOnControlAndEnter).toHaveBeenCalledOnce(); diff --git a/src/test/javascript/spec/component/complaints/complaints-form.component.spec.ts b/src/test/javascript/spec/component/complaints/complaints-form.component.spec.ts index c0e144ca8828..488c740be038 100644 --- a/src/test/javascript/spec/component/complaints/complaints-form.component.spec.ts +++ b/src/test/javascript/spec/component/complaints/complaints-form.component.spec.ts @@ -84,7 +84,7 @@ describe('ComplaintsFormComponent', () => { it('should submit after complaint creation', () => { const createMock = jest.spyOn(complaintService, 'create').mockReturnValue(of({} as EntityResponseType)); - const submitSpy = jest.spyOn(component.submit, 'emit'); + const submitSpy = jest.spyOn(component.onSubmit, 'emit'); component.createComplaint(); expect(createMock).toHaveBeenCalledOnce(); expect(submitSpy).toHaveBeenCalledOnce(); @@ -93,7 +93,7 @@ describe('ComplaintsFormComponent', () => { it('should throw unknown error after complaint creation', () => { const createMock = jest.spyOn(complaintService, 'create').mockReturnValue(throwError(() => ({ status: 400 }))); - const submitSpy = jest.spyOn(component.submit, 'emit'); + const submitSpy = jest.spyOn(component.onSubmit, 'emit'); const errorSpy = jest.spyOn(alertService, 'error'); component.createComplaint(); expect(createMock).toHaveBeenCalledOnce(); @@ -104,7 +104,7 @@ describe('ComplaintsFormComponent', () => { it('should throw known error after complaint creation', () => { const error = { error: { errorKey: 'tooManyComplaints' } } as HttpErrorResponse; const createMock = jest.spyOn(complaintService, 'create').mockReturnValue(throwError(() => error)); - const submitSpy = jest.spyOn(component.submit, 'emit'); + const submitSpy = jest.spyOn(component.onSubmit, 'emit'); const errorSpy = jest.spyOn(alertService, 'error'); const numberOfComplaints = 42; component.maxComplaintsPerCourse = numberOfComplaints; @@ -120,7 +120,7 @@ describe('ComplaintsFormComponent', () => { component.exercise = courseExercise; component.ngOnInit(); - const submitSpy = jest.spyOn(component.submit, 'emit'); + const submitSpy = jest.spyOn(component.onSubmit, 'emit'); const errorSpy = jest.spyOn(alertService, 'error'); // 26 characters component.complaintText = 'abcdefghijklmnopqrstuvwxyz';