mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-39612 Registering click event on form widget twice (#11323)
* AAE-39612 Remove click from base and add it directly to the implementations * AAE-39612 Add unit tests for the Text Widgets * AAE-39612 Add unit tests for the Date Widgets * AAE-39612 Add unit tests for the UI Widgets * AAE-39612 Add unit tests for the People Widgets * AAE-39612 Add unit tests for the Display Text Widgets * AAE-39612 Add unit tests for the Base Viewer Widget * AAE-39612 Add unit tests for the Object View Widgets * AAE-39612 Add unit tests for the File Upload Widgets * AAE-39612 Add unit tests for the Data Table Widget
This commit is contained in:
@@ -40,6 +40,24 @@ describe('AmountWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should setup currency from field', () => {
|
||||
const currency = 'UAH';
|
||||
widget.field = new FormFieldModel(null, {
|
||||
|
||||
@@ -52,6 +52,24 @@ describe('BaseViewerWidgetComponent', () => {
|
||||
widget = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event');
|
||||
widget.field = new FormFieldModel(new FormModel(), { value: { urlFile: '' } });
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the file id corretly when the field value is an array', (done) => {
|
||||
assertFileId([fakePngAnswer], '1933', fakeForm, widget, fixture, done);
|
||||
});
|
||||
|
||||
@@ -29,15 +29,7 @@ import { WidgetComponent } from '../widget.component';
|
||||
templateUrl: './base-viewer.widget.html',
|
||||
styleUrls: ['./base-viewer.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)',
|
||||
'(blur)': 'event($event)',
|
||||
'(change)': 'event($event)',
|
||||
'(focus)': 'event($event)',
|
||||
'(focusin)': 'event($event)',
|
||||
'(focusout)': 'event($event)',
|
||||
'(input)': 'event($event)',
|
||||
'(invalid)': 'event($event)',
|
||||
'(select)': 'event($event)'
|
||||
'(click)': 'event($event)'
|
||||
},
|
||||
imports: [TranslatePipe, ViewerComponent, ErrorWidgetComponent],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { UnitTestingUtils } from '../../../../testing';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel } from '../core';
|
||||
import { CheckboxWidgetComponent } from './checkbox.widget';
|
||||
@@ -31,7 +30,7 @@ describe('CheckboxWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MatCheckboxModule]
|
||||
imports: [CheckboxWidgetComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(CheckboxWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -39,7 +38,23 @@ describe('CheckboxWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
afterEach(() => fixture.destroy());
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when template is ready', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -23,9 +23,6 @@ import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { HarnessLoader, TestKey } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { addMinutes } from 'date-fns';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatDatetimepickerModule, MatNativeDatetimeModule } from '@mat-datetimepicker/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { UnitTestingUtils } from '../../../../testing/unit-testing-utils';
|
||||
|
||||
describe('DateTimeWidgetComponent', () => {
|
||||
@@ -37,7 +34,7 @@ describe('DateTimeWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MatDialogModule, MatNativeDatetimeModule, MatDatepickerModule, MatDatetimepickerModule, DateTimeWidgetComponent]
|
||||
imports: [DateTimeWidgetComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(DateTimeWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -51,6 +48,24 @@ describe('DateTimeWidgetComponent', () => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not call onFieldChanged on init', () => {
|
||||
spyOn(widget, 'onFieldChanged').and.callThrough();
|
||||
expect(widget.onFieldChanged).not.toHaveBeenCalled();
|
||||
|
||||
@@ -43,6 +43,9 @@ import { ReactiveFormWidget } from '../reactive-widget.interface';
|
||||
],
|
||||
templateUrl: './date-time.widget.html',
|
||||
styleUrls: ['./date-time.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)'
|
||||
},
|
||||
imports: [NgIf, TranslatePipe, MatFormFieldModule, MatInputModule, MatDatetimepickerModule, ReactiveFormsModule, ErrorWidgetComponent],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
|
||||
@@ -42,6 +42,24 @@ describe('DateWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not call onFieldChanged on init', () => {
|
||||
spyOn(widget, 'onFieldChanged').and.callThrough();
|
||||
expect(widget.onFieldChanged).not.toHaveBeenCalled();
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { UnitTestingUtils } from '../../../../testing';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel } from '../core';
|
||||
@@ -32,7 +31,7 @@ describe('DecimalComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MatInputModule, DecimalWidgetComponent],
|
||||
imports: [DecimalWidgetComponent],
|
||||
providers: [FormService]
|
||||
});
|
||||
|
||||
@@ -42,6 +41,24 @@ describe('DecimalComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when tooltip is set', () => {
|
||||
beforeEach(() => {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FormFieldModel, FormModel } from '../core';
|
||||
import { DisplayTextWidgetComponent } from './display-text.widget';
|
||||
|
||||
describe('DisplayTextWidgetComponent', () => {
|
||||
let fixture: ComponentFixture<DisplayTextWidgetComponent>;
|
||||
let widget: DisplayTextWidgetComponent;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [DisplayTextWidgetComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(DisplayTextWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -34,6 +34,24 @@ describe('HyperlinkWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should get link text from field display text', () => {
|
||||
const text = 'hello world';
|
||||
|
||||
|
||||
@@ -40,6 +40,24 @@ describe('MultilineTextWidgetComponentComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when tooltip is set', () => {
|
||||
beforeEach(() => {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { UnitTestingUtils } from '../../../../testing';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel } from '../core';
|
||||
import { NumberWidgetComponent } from './number.widget';
|
||||
@@ -36,7 +34,7 @@ describe('NumberWidgetComponent', () => {
|
||||
mockDecimalNumberPipe = jasmine.createSpyObj('DecimalNumberPipe', ['transform']);
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [MatInputModule, MatIconModule]
|
||||
imports: [NumberWidgetComponent]
|
||||
})
|
||||
.overrideComponent(NumberWidgetComponent, {
|
||||
set: {
|
||||
@@ -51,8 +49,22 @@ describe('NumberWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(widget).toBeTruthy();
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with readonly true', () => {
|
||||
|
||||
@@ -43,6 +43,24 @@ describe('TextWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when template is ready', () => {
|
||||
describe('and no mask is configured on text element', () => {
|
||||
it('should raise ngModelChange event', async () => {
|
||||
|
||||
@@ -29,7 +29,6 @@ import { FormFieldModel } from './core';
|
||||
selector: 'base-widget',
|
||||
template: '',
|
||||
host: {
|
||||
'(click)': 'event($event)',
|
||||
'(blur)': 'event($event)',
|
||||
'(change)': 'event($event)',
|
||||
'(focus)': 'event($event)',
|
||||
|
||||
@@ -28,6 +28,9 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
selector: 'analytics-checkbox-widget',
|
||||
imports: [CommonModule, TranslatePipe, ReactiveFormsModule, MatCheckboxModule],
|
||||
templateUrl: './checkbox.widget.html',
|
||||
host: {
|
||||
'(click)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class CheckboxWidgetAnalyticsComponent extends WidgetComponent {
|
||||
|
||||
@@ -28,6 +28,9 @@ import { TranslatePipe } from '@ngx-translate/core';
|
||||
imports: [CommonModule, TranslatePipe, ReactiveFormsModule],
|
||||
templateUrl: './dropdown.widget.html',
|
||||
styleUrls: ['./dropdown.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DropdownWidgetAnalyticsComponent extends WidgetComponent implements OnInit {
|
||||
|
||||
@@ -30,6 +30,9 @@ import { MatInputModule } from '@angular/material/input';
|
||||
imports: [CommonModule, TranslatePipe, ReactiveFormsModule, MatFormFieldModule, MatInputModule],
|
||||
templateUrl: './number.widget.html',
|
||||
styleUrls: ['./number.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class NumberWidgetAnalyticsComponent extends WidgetComponent implements OnInit {
|
||||
|
||||
+16
-2
@@ -170,8 +170,22 @@ describe('AttachFileCloudWidgetComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should show up as simple upload when is configured for only local files', async () => {
|
||||
|
||||
-11
@@ -56,17 +56,6 @@ const VALID_ALIAS = [ALIAS_ROOT_FOLDER, ALIAS_USER_FOLDER, '-shared-'];
|
||||
imports: [CommonModule, ErrorWidgetComponent, TranslatePipe, MatIconModule, FilePropertiesTableCloudComponent, MatButtonModule],
|
||||
templateUrl: './attach-file-cloud-widget.component.html',
|
||||
styleUrls: ['./attach-file-cloud-widget.component.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)',
|
||||
'(blur)': 'event($event)',
|
||||
'(change)': 'event($event)',
|
||||
'(focus)': 'event($event)',
|
||||
'(focusin)': 'event($event)',
|
||||
'(focusout)': 'event($event)',
|
||||
'(input)': 'event($event)',
|
||||
'(invalid)': 'event($event)',
|
||||
'(select)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit, OnDestroy {
|
||||
|
||||
+18
@@ -96,6 +96,24 @@ describe('DataTableWidgetComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display label', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
|
||||
+18
@@ -48,6 +48,24 @@ describe('DateCloudWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not call onFieldChanged on init', () => {
|
||||
spyOn(widget, 'onFieldChanged').and.callThrough();
|
||||
expect(widget.onFieldChanged).not.toHaveBeenCalled();
|
||||
|
||||
+18
@@ -46,6 +46,24 @@ describe('DisplayExternalPropertyWidgetComponent', () => {
|
||||
testingUtils = new UnitTestingUtils(fixture.debugElement, loader);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display initial value', async () => {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||
type: FormFieldTypes.DISPLAY_EXTERNAL_PROPERTY,
|
||||
|
||||
+19
@@ -20,6 +20,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DisplayRichTextWidgetComponent, RICH_TEXT_PARSER_TOKEN } from './display-rich-text.widget';
|
||||
import { RichTextParserService } from '../../../services/rich-text-parser.service';
|
||||
import { FormFieldModel, FormModel } from '@alfresco/adf-core';
|
||||
|
||||
describe('DisplayRichTextWidgetComponent', () => {
|
||||
let widget: DisplayRichTextWidgetComponent;
|
||||
@@ -96,6 +97,24 @@ describe('DisplayRichTextWidgetComponent', () => {
|
||||
widget.field = fakeFormField;
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should call RichTextParserService.parse() method', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
|
||||
+18
@@ -74,6 +74,24 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Simple Dropdown', () => {
|
||||
beforeEach(() => {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', readOnly: false, id: 'form-id' }), {
|
||||
|
||||
+4
-2
@@ -29,7 +29,7 @@ import {
|
||||
SelectFilterInputComponent,
|
||||
WidgetComponent
|
||||
} from '@alfresco/adf-core';
|
||||
import { AsyncPipe, NgClass, NgFor, NgIf } from '@angular/common';
|
||||
import { AsyncPipe, NgClass, NgIf } from '@angular/common';
|
||||
import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
@@ -56,10 +56,12 @@ export const DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE = 100;
|
||||
selector: 'dropdown-cloud-widget',
|
||||
templateUrl: './dropdown-cloud.widget.html',
|
||||
styleUrls: ['./dropdown-cloud.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
imports: [
|
||||
NgIf,
|
||||
NgFor,
|
||||
NgClass,
|
||||
AsyncPipe,
|
||||
ReactiveFormsModule,
|
||||
|
||||
+18
@@ -51,6 +51,24 @@ describe('FileViewerWidgetComponent', () => {
|
||||
widget = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the file id corretly when the field value is an array', async () => {
|
||||
widget.field = new FormFieldModel(fakeForm, { id: 'fakeField', value: [fakePngAnswer] });
|
||||
|
||||
|
||||
-11
@@ -27,17 +27,6 @@ import { TranslatePipe } from '@ngx-translate/core';
|
||||
imports: [ErrorWidgetComponent, AlfrescoViewerComponent, TranslatePipe],
|
||||
templateUrl: './file-viewer.widget.html',
|
||||
styleUrls: ['./file-viewer.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)',
|
||||
'(blur)': 'event($event)',
|
||||
'(change)': 'event($event)',
|
||||
'(focus)': 'event($event)',
|
||||
'(focusin)': 'event($event)',
|
||||
'(focusout)': 'event($event)',
|
||||
'(input)': 'event($event)',
|
||||
'(invalid)': 'event($event)',
|
||||
'(select)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class FileViewerWidgetComponent extends BaseViewerWidgetComponent {
|
||||
|
||||
+18
-4
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, IdentityGroupModel, NoopAuthModule, CoreModule } from '@alfresco/adf-core';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, IdentityGroupModel, NoopAuthModule } from '@alfresco/adf-core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { GroupCloudWidgetComponent } from './group-cloud.widget';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
@@ -30,7 +30,7 @@ describe('GroupCloudWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreModule.forRoot(), NoopAuthModule, GroupCloudWidgetComponent]
|
||||
imports: [NoopAuthModule, GroupCloudWidgetComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(GroupCloudWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
@@ -38,8 +38,22 @@ describe('GroupCloudWidgetComponent', () => {
|
||||
loader = TestbedHarnessEnvironment.loader(fixture);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have enabled validation if field is NOT readOnly', () => {
|
||||
|
||||
+18
-4
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, IdentityUserModel, NoopAuthModule, CoreModule } from '@alfresco/adf-core';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, IdentityUserModel, NoopAuthModule } from '@alfresco/adf-core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PeopleCloudWidgetComponent } from './people-cloud.widget';
|
||||
import { IdentityUserService } from '../../../../people/services/identity-user.service';
|
||||
@@ -33,7 +33,7 @@ describe('PeopleCloudWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreModule.forRoot(), NoopAuthModule, PeopleCloudWidgetComponent]
|
||||
imports: [NoopAuthModule, PeopleCloudWidgetComponent]
|
||||
});
|
||||
identityUserService = TestBed.inject(IdentityUserService);
|
||||
fixture = TestBed.createComponent(PeopleCloudWidgetComponent);
|
||||
@@ -43,8 +43,22 @@ describe('PeopleCloudWidgetComponent', () => {
|
||||
loader = TestbedHarnessEnvironment.loader(fixture);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should preselect the current user', () => {
|
||||
|
||||
+17
-1
@@ -57,7 +57,23 @@ describe('PropertiesViewerWidgetComponent', () => {
|
||||
spyOn(nodesApiService, 'getNode').and.returnValue(of(fakeNodeWithProperties));
|
||||
});
|
||||
|
||||
afterEach(() => fixture.destroy());
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not display properties viewer when value is not set', async () => {
|
||||
widget.field.value = undefined;
|
||||
|
||||
-11
@@ -29,17 +29,6 @@ import { CommonModule } from '@angular/common';
|
||||
imports: [CommonModule, ErrorWidgetComponent, PropertiesViewerWrapperComponent, TranslatePipe],
|
||||
templateUrl: './properties-viewer.widget.html',
|
||||
styleUrls: ['./properties-viewer.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)',
|
||||
'(blur)': 'event($event)',
|
||||
'(change)': 'event($event)',
|
||||
'(focus)': 'event($event)',
|
||||
'(focusin)': 'event($event)',
|
||||
'(focusout)': 'event($event)',
|
||||
'(input)': 'event($event)',
|
||||
'(invalid)': 'event($event)',
|
||||
'(select)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class PropertiesViewerWidgetComponent extends BaseViewerWidgetComponent {
|
||||
|
||||
+18
@@ -56,6 +56,24 @@ describe('RadioButtonsCloudWidgetComponent', () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), { restUrl: '<url>' });
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should update form on values fetched', () => {
|
||||
spyOn(formCloudService, 'getRestWidgetData').and.returnValue(of(restOption));
|
||||
const taskId = '<form-id>';
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { UploadCloudWidgetComponent } from './upload-cloud.widget';
|
||||
import { FormFieldModel, FormModel, ThumbnailService, NotificationService } from '@alfresco/adf-core';
|
||||
import { ProcessCloudContentService } from '../../../services/process-cloud-content.service';
|
||||
|
||||
describe('UploadCloudWidgetComponent', () => {
|
||||
let fixture: ComponentFixture<UploadCloudWidgetComponent>;
|
||||
let widget: UploadCloudWidgetComponent;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [UploadCloudWidgetComponent],
|
||||
providers: [
|
||||
{ provide: ThumbnailService, useValue: {} },
|
||||
{ provide: ProcessCloudContentService, useValue: {} },
|
||||
{ provide: NotificationService, useValue: {} }
|
||||
]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(UploadCloudWidgetComponent);
|
||||
widget = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
});
|
||||
+21
@@ -207,6 +207,27 @@ describe('AttachFileWidgetComponent', () => {
|
||||
return showFileButton.isDisabled();
|
||||
};
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of([]));
|
||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of({}));
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should add file to tempFilesList when form has value and file source is configured', () => {
|
||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||
spyOn(widget, 'isFileSourceConfigured').and.returnValue(true);
|
||||
|
||||
-11
@@ -41,17 +41,6 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
imports: [CommonModule, TranslatePipe, MatIconModule, MatButtonModule, MatMenuModule, MatListModule, ErrorWidgetComponent, AlfrescoIconComponent],
|
||||
templateUrl: './attach-file-widget.component.html',
|
||||
styleUrls: ['./attach-file-widget.component.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)',
|
||||
'(blur)': 'event($event)',
|
||||
'(change)': 'event($event)',
|
||||
'(focus)': 'event($event)',
|
||||
'(focusin)': 'event($event)',
|
||||
'(focusout)': 'event($event)',
|
||||
'(input)': 'event($event)',
|
||||
'(invalid)': 'event($event)',
|
||||
'(select)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AttachFileWidgetComponent extends UploadWidgetComponent implements OnInit {
|
||||
|
||||
@@ -54,6 +54,24 @@ describe('DropdownWidgetComponent', () => {
|
||||
loader = TestbedHarnessEnvironment.loader(fixture);
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should require field with restUrl', () => {
|
||||
spyOn(taskFormService, 'getRestFieldValues').and.stub();
|
||||
|
||||
|
||||
@@ -57,6 +57,24 @@ describe('FileViewerWidgetComponent', () => {
|
||||
widget = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the file id corretly when the field value is an array', (done) => {
|
||||
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: [fakePngAnswer] });
|
||||
widget.field = fakeField;
|
||||
|
||||
@@ -28,17 +28,6 @@ import { AlfrescoViewerComponent } from '@alfresco/adf-content-services';
|
||||
imports: [CommonModule, TranslatePipe, AlfrescoViewerComponent, ErrorWidgetComponent],
|
||||
templateUrl: './file-viewer.widget.html',
|
||||
styleUrls: ['./file-viewer.widget.scss'],
|
||||
host: {
|
||||
'(click)': 'event($event)',
|
||||
'(blur)': 'event($event)',
|
||||
'(change)': 'event($event)',
|
||||
'(focus)': 'event($event)',
|
||||
'(focusin)': 'event($event)',
|
||||
'(focusout)': 'event($event)',
|
||||
'(input)': 'event($event)',
|
||||
'(invalid)': 'event($event)',
|
||||
'(select)': 'event($event)'
|
||||
},
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class FileViewerWidgetComponent extends BaseViewerWidgetComponent {
|
||||
|
||||
@@ -56,6 +56,24 @@ describe('PeopleWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(widget, 'event').and.callThrough();
|
||||
widget.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
|
||||
describe('display name', () => {
|
||||
it('should return empty display name for missing model', () => {
|
||||
expect(widget.getDisplayName(null)).toBe('');
|
||||
|
||||
@@ -383,5 +383,23 @@ describe('UploadWidgetComponent', () => {
|
||||
fileJpegIcon.nativeElement.dispatchEvent(new MouseEvent('click'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('event tracking', () => {
|
||||
let eventSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
eventSpy = spyOn(uploadWidgetComponent, 'event').and.callThrough();
|
||||
uploadWidgetComponent.field = new FormFieldModel(new FormModel(), {});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call event method only once when widget is clicked', () => {
|
||||
const clickEvent = new MouseEvent('click', { bubbles: true });
|
||||
fixture.debugElement.nativeElement.dispatchEvent(clickEvent);
|
||||
|
||||
expect(eventSpy).toHaveBeenCalledTimes(1);
|
||||
expect(eventSpy).toHaveBeenCalledWith(clickEvent);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user