Skip to content

Commit

Permalink
Development: Fix DOM event name conflicts (#9589)
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-glombik authored Oct 27, 2024
1 parent 432efc3 commit 7346de1
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h3 class="top-container flex-wrap flex-lg-nowrap">
<button
id="submit"
class="btn m-1 btn-success"
(click)="submit.emit(); sendSubmitAssessmentEventToAnalytics()"
(click)="onSubmit.emit(); sendSubmitAssessmentEventToAnalytics()"
[disabled]="submitDisabled"
[ngbTooltip]="('artemisApp.assessment.button.control' | artemisTranslate) + ' + Enter'"
>
Expand All @@ -127,7 +127,7 @@ <h3 class="top-container flex-wrap flex-lg-nowrap">
@if (!isTestRun) {
<button
class="btn m-1 btn-danger"
(click)="cancel.emit()"
(click)="onCancel.emit()"
[disabled]="!(exercise?.isAtLeastInstructor || isAssessor) || saveBusy || submitBusy || cancelBusy"
>
@if (cancelBusy) {
Expand All @@ -140,7 +140,7 @@ <h3 class="top-container flex-wrap flex-lg-nowrap">
@if (overrideVisible) {
<button
class="btn m-1 btn-danger"
(click)="submit.emit()"
(click)="onSubmit.emit()"
[disabled]="overrideDisabled"
[ngbTooltip]="('artemisApp.assessment.button.control' | artemisTranslate) + ' + Enter'"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ export class AssessmentHeaderComponent {
@Input() isProgrammingExercise = false; // remove once diff view activated for programming exercises

@Output() save = new EventEmitter<void>();
// eslint-disable-next-line @angular-eslint/no-output-native
@Output() submit = new EventEmitter<void>();
// eslint-disable-next-line @angular-eslint/no-output-native
@Output() cancel = new EventEmitter<void>();
@Output() onSubmit = new EventEmitter<void>();
@Output() onCancel = new EventEmitter<void>();
@Output() nextSubmission = new EventEmitter<void>();
@Output() highlightDifferencesChange = new EventEmitter<boolean>();
@Output() useAsExampleSubmission = new EventEmitter<void>();
Expand Down Expand Up @@ -143,9 +141,9 @@ export class AssessmentHeaderComponent {
submitOnControlAndEnter(event: KeyboardEvent) {
event.preventDefault();
if (!this.overrideDisabled) {
this.submit.emit();
this.onSubmit.emit();
} else if (!this.submitDisabled) {
this.submit.emit();
this.onSubmit.emit();
this.sendSubmitAssessmentEventToAnalytics();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
[correctionRound]="correctionRound"
[isProgrammingExercise]="isProgrammingExercise"
(save)="save.emit()"
(submit)="submit.emit()"
(cancel)="cancel.emit()"
(onSubmit)="onSubmit.emit()"
(onCancel)="onCancel.emit()"
[(highlightDifferences)]="highlightDifferences"
(nextSubmission)="nextSubmission.emit()"
[hasComplaint]="!!complaint"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ export class AssessmentLayoutComponent {
}

@Output() save = new EventEmitter<void>();
// eslint-disable-next-line @angular-eslint/no-output-native
@Output() submit = new EventEmitter<void>();
// eslint-disable-next-line @angular-eslint/no-output-native
@Output() cancel = new EventEmitter<void>();
@Output() onSubmit = new EventEmitter<void>();
@Output() onCancel = new EventEmitter<void>();
@Output() nextSubmission = new EventEmitter<void>();
@Output() updateAssessmentAfterComplaint = new EventEmitter<AssessmentAfterComplaint>();
@Output() highlightDifferencesChange = new EventEmitter<boolean>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
[examId]="exam?.id!"
[complaintType]="formComplaintType"
[isCurrentUserSubmissionAuthor]="isCorrectUserToFileAction"
(submit)="loadPotentialComplaint()"
(onSubmit)="loadPotentialComplaint()"
/>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export class ComplaintsFormComponent implements OnInit {
@Input() examId?: number;
@Input() complaintType: ComplaintType;
@Input() isCurrentUserSubmissionAuthor = false;
// eslint-disable-next-line @angular-eslint/no-output-native
@Output() submit: EventEmitter<void> = new EventEmitter();
@Output() onSubmit: EventEmitter<void> = new EventEmitter();
maxComplaintsPerCourse = 1;
maxComplaintTextLimit: number;
complaintText?: string;
Expand Down Expand Up @@ -63,7 +62,7 @@ export class ComplaintsFormComponent implements OnInit {

this.complaintService.create(complaintRequest).subscribe({
next: () => {
this.submit.emit();
this.onSubmit.emit();
},
error: (err: HttpErrorResponse) => {
if (err?.error?.errorKey === 'tooManyComplaints') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
[correctionRound]="correctionRound"
[(highlightDifferences)]="highlightDifferences"
(save)="onSaveAssessment()"
(submit)="onSubmitAssessment()"
(cancel)="onCancelAssessment()"
(onSubmit)="onSubmitAssessment()"
(onCancel)="onCancelAssessment()"
(nextSubmission)="assessNext()"
(updateAssessmentAfterComplaint)="onUpdateAssessmentAfterComplaint($event)"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ <h3 jhiTranslate="artemisApp.exercise.sections.grading" id="artemisApp.exercise.
[isDisabled]="
!!(editForm.form.invalid || fileUploadExercise.dueDateError || fileUploadExercise.assessmentDueDateError || fileUploadExercise.exampleSolutionPublicationDateError)
"
(cancel)="previousState()"
(onCancel)="previousState()"
(save)="save()"
[(notificationText)]="notificationText"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
[submission]="submission"
[hasAssessmentDueDatePassed]="hasAssessmentDueDatePassed"
(save)="onSaveAssessment()"
(submit)="onSubmitAssessment()"
(cancel)="onCancelAssessment()"
(onSubmit)="onSubmitAssessment()"
(onCancel)="onCancelAssessment()"
(nextSubmission)="assessNext()"
(updateAssessmentAfterComplaint)="onUpdateAssessmentAfterComplaint($event)"
[(highlightDifferences)]="highlightDifferences"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ <h3 jhiTranslate="artemisApp.exercise.sections.grading" id="artemisApp.exercise.
[isCreation]="!modelingExercise.id"
[isSaving]="isSaving"
[isDisabled]="!!(editForm.form.invalid || modelingExercise.dueDateError || modelingExercise.assessmentDueDateError || modelingExercise.exampleSolutionPublicationDateError)"
(cancel)="previousState()"
(onCancel)="previousState()"
(save)="save()"
[(notificationText)]="notificationText"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
[correctionRound]="correctionRound"
[isProgrammingExercise]="true"
(save)="save()"
(submit)="submit()"
(cancel)="cancel()"
(onSubmit)="submit()"
(onCancel)="cancel()"
(nextSubmission)="nextSubmission()"
(updateAssessmentAfterComplaint)="onUpdateAssessmentAfterComplaint($event)"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2 id="jhi-programming-exercise-heading-import" jhiTranslate="artemisApp.progra
[isSaving]="isSaving"
[invalidReasons]="getInvalidReasons()"
(save)="save()"
(cancel)="previousState()"
(onCancel)="previousState()"
[(notificationText)]="notificationText"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
[hasAssessmentDueDatePassed]="hasAssessmentDueDatePassed"
[correctionRound]="correctionRound"
(save)="save()"
(submit)="submit()"
(cancel)="cancel()"
(onSubmit)="submit()"
(onCancel)="cancel()"
(nextSubmission)="nextSubmission()"
[(highlightDifferences)]="highlightDifferences"
(updateAssessmentAfterComplaint)="updateAssessmentAfterComplaint($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class="guided-tour-text-assessment"
(click)="select(false)"
(onFocus)="select(false)"
(close)="unselect()"
(onClose)="unselect()"
(feedbackChange)="feedbackDidChange()"
[readOnly]="readOnly"
[highlightDifferences]="highlightDifferences"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class TextblockFeedbackEditorComponent implements AfterViewInit {
@Input() textBlock: TextBlock = new TextBlock();
@Input() feedback: Feedback = new Feedback();
@Output() feedbackChange = new EventEmitter<Feedback>();
@Output() close = new EventEmitter<void>();
@Output() onClose = new EventEmitter<void>();
@Output() onFocus = new EventEmitter<void>();
@ViewChild('detailText') textareaRef: ElementRef;
@ViewChild(ConfirmIconComponent) confirmIconComponent: ConfirmIconComponent;
Expand Down Expand Up @@ -95,7 +95,7 @@ export class TextblockFeedbackEditorComponent implements AfterViewInit {
* Dismiss changes in feedback editor
*/
dismiss(): void {
this.close.emit();
this.onClose.emit();
this.textAssessmentAnalytics.sendAssessmentEvent(TextAssessmentEventType.DELETE_FEEDBACK, this.feedback.type, this.textBlock.type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ <h3 jhiTranslate="artemisApp.exercise.sections.grading" id="artemisApp.exercise.
[isImport]="isImport"
[isSaving]="isSaving"
[isDisabled]="!!(editForm.form.invalid || textExercise.dueDateError || textExercise.assessmentDueDateError || textExercise.exampleSolutionPublicationDateError)"
(cancel)="previousState()"
(onCancel)="previousState()"
(save)="save()"
[(notificationText)]="notificationText"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<span class="d-none d-md-inline">({{ invalidReasons.length }})</span>
</div>
}
<button type="button" id="cancel-save" class="btn btn-sm btn-secondary" (click)="cancel.next()">
<button type="button" id="cancel-save" class="btn btn-sm btn-secondary" (click)="onCancel.next()">
<fa-icon [fixedWidth]="true" [icon]="faBan" class="sm" />
<span class="d-none d-sm-inline" jhiTranslate="entity.action.cancel"></span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { ButtonSize } from 'app/shared/components/button.component';
})
export class FormFooterComponent {
@Output() save = new EventEmitter<void>();
// eslint-disable-next-line @angular-eslint/no-output-native
@Output() cancel = new EventEmitter<void>();

@Output() onCancel = new EventEmitter<void>();

@Input() isSaving: boolean = false;
@Input() isDisabled: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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';
Expand Down

0 comments on commit 7346de1

Please sign in to comment.