AAE-39679 Counting click event twice for attach file widget (#11645)

This commit is contained in:
David Olson
2026-02-18 09:45:22 -06:00
committed by GitHub
parent 3f542d99ba
commit bc30b74213
2 changed files with 27 additions and 1 deletions
@@ -1,7 +1,7 @@
<div class="adf-attach-file-widget-container"> <div class="adf-attach-file-widget-container">
<div class="adf-attach-widget {{field.className}}" <div class="adf-attach-widget {{field.className}}"
[class.adf-readonly]="field.readOnly"> [class.adf-readonly]="field.readOnly">
<label class="adf-label" [attr.for]="field.id">{{field.name}} <label class="adf-label" [attr.for]="field.id + '-label'">{{field.name}}
<span class="adf-asterisk" *ngIf="isRequired()">*</span> <span class="adf-asterisk" *ngIf="isRequired()">*</span>
</label> </label>
<div class="adf-attach-widget-container" (focusout)="markAsTouched()"> <div class="adf-attach-widget-container" (focusout)="markAsTouched()">
@@ -186,6 +186,32 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(eventSpy).toHaveBeenCalledTimes(1); expect(eventSpy).toHaveBeenCalledTimes(1);
expect(eventSpy).toHaveBeenCalledWith(clickEvent); expect(eventSpy).toHaveBeenCalledWith(clickEvent);
}); });
it('should not trigger button click when label is clicked', async () => {
const openSelectDialogSpy = spyOn(widget, 'openSelectDialog');
createUploadWidgetField(new FormModel(), 'attach-file-test', [], contentSourceParam);
fixture.detectChanges();
await fixture.whenStable();
const label = element.querySelector('.adf-label') as HTMLElement;
label.click();
fixture.detectChanges();
expect(openSelectDialogSpy).not.toHaveBeenCalled();
});
it('should call openSelectDialog only once when button is clicked', async () => {
const openSelectDialogSpy = spyOn(widget, 'openSelectDialog');
createUploadWidgetField(new FormModel(), 'attach-file-test', [], contentSourceParam);
fixture.detectChanges();
await fixture.whenStable();
const button = element.querySelector('.adf-attach-widget__menu-upload__button') as HTMLButtonElement;
button.click();
fixture.detectChanges();
expect(openSelectDialogSpy).toHaveBeenCalledTimes(1);
});
}); });
it('should show up as simple upload when is configured for only local files', async () => { it('should show up as simple upload when is configured for only local files', async () => {