mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[AAE-11989] Automate C586839 - Should be able to see the tooltip for form widget (#8138)
This commit is contained in:
parent
0b9fb82de2
commit
73e1953418
@ -24,6 +24,7 @@ import { FormFieldTypes } from '../core/form-field-types';
|
|||||||
import { CoreTestingModule } from '../../../../testing/core.testing.module';
|
import { CoreTestingModule } from '../../../../testing/core.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { FormModel } from '../core/form.model';
|
import { FormModel } from '../core/form.model';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('AmountWidgetComponent', () => {
|
describe('AmountWidgetComponent', () => {
|
||||||
|
|
||||||
@ -81,6 +82,42 @@ describe('AmountWidgetComponent', () => {
|
|||||||
expect(widget.placeholder).toBe('1234');
|
expect(widget.placeholder).toBe('1234');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.AMOUNT,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const amountInput = fixture.nativeElement.querySelector('input');
|
||||||
|
amountInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const amountInput = fixture.nativeElement.querySelector('input');
|
||||||
|
amountInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
amountInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -275,35 +312,6 @@ describe('AmountWidgetComponent - rendering', () => {
|
|||||||
expect(errorMessage.textContent.trim()).toContain('FORM.FIELD.VALIDATOR.INVALID_NUMBER');
|
expect(errorMessage.textContent.trim()).toContain('FORM.FIELD.VALIDATOR.INVALID_NUMBER');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', async () => {
|
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
|
||||||
id: 'TestAmount1',
|
|
||||||
name: 'Test Amount',
|
|
||||||
type: 'amount',
|
|
||||||
required: true,
|
|
||||||
colspan: 2,
|
|
||||||
placeholder: 'Check Placeholder Text',
|
|
||||||
minValue: null,
|
|
||||||
maxValue: null,
|
|
||||||
visibilityCondition: null,
|
|
||||||
params: {
|
|
||||||
existingColspan: 1,
|
|
||||||
maxColspan: 2
|
|
||||||
},
|
|
||||||
enableFractions: false,
|
|
||||||
currency: '$',
|
|
||||||
tooltip: 'ammount widget'
|
|
||||||
});
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const ammountElement: any = fixture.nativeElement.querySelector('#TestAmount1');
|
|
||||||
const tooltip = ammountElement.getAttribute('ng-reflect-message');
|
|
||||||
|
|
||||||
expect(tooltip).toEqual(widget.field.tooltip);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when form model has left labels', () => {
|
describe('when form model has left labels', () => {
|
||||||
|
|
||||||
it('should have left labels classes on leftLabels true', async () => {
|
it('should have left labels classes on leftLabels true', async () => {
|
||||||
|
@ -27,6 +27,7 @@ import { TranslateLoaderService } from '../../../../services/translate-loader.se
|
|||||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||||
import { CoreTestingModule } from '../../../../testing';
|
import { CoreTestingModule } from '../../../../testing';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('CheckboxWidgetComponent', () => {
|
describe('CheckboxWidgetComponent', () => {
|
||||||
|
|
||||||
@ -111,16 +112,40 @@ describe('CheckboxWidgetComponent', () => {
|
|||||||
expect(checkbox.getAttribute('aria-checked')).toBe('false');
|
expect(checkbox.getAttribute('aria-checked')).toBe('false');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', async () => {
|
describe('when tooltip is set', () => {
|
||||||
widget.field.tooltip = 'checkbox widget';
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
beforeEach(() => {
|
||||||
await fixture.whenStable();
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.BOOLEAN,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
const checkbox = fixture.debugElement.nativeElement.querySelector('#check-id');
|
it('should show tooltip', async () => {
|
||||||
const tooltip = checkbox.getAttribute('ng-reflect-message');
|
const checkboxInput = fixture.nativeElement.querySelector('mat-checkbox');
|
||||||
|
checkboxInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(tooltip).toEqual(widget.field.tooltip);
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const checkboxInput = fixture.nativeElement.querySelector('mat-checkbox');
|
||||||
|
checkboxInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
checkboxInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,6 +25,7 @@ import { CoreTestingModule } from '../../../../testing/core.testing.module';
|
|||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { FormFieldTypes } from '../core/form-field-types';
|
import { FormFieldTypes } from '../core/form-field-types';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('DateTimeWidgetComponent', () => {
|
describe('DateTimeWidgetComponent', () => {
|
||||||
|
|
||||||
@ -108,6 +109,42 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
expect(widget.onFieldChanged).toHaveBeenCalledWith(field);
|
expect(widget.onFieldChanged).toHaveBeenCalledWith(field);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.DATETIME,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const dateTimeInput = fixture.nativeElement.querySelector('input');
|
||||||
|
dateTimeInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const dateTimeInput = fixture.nativeElement.querySelector('input');
|
||||||
|
dateTimeInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
dateTimeInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -197,25 +234,6 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
dateButton = element.querySelector<HTMLButtonElement>('button');
|
dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeTruthy();
|
expect(dateButton.disabled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', () => {
|
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
|
||||||
id: 'date-field-id',
|
|
||||||
name: 'date-name',
|
|
||||||
value: '12-30-9999 10:30 AM',
|
|
||||||
dateDisplayFormat: 'MM-DD-YYYY HH:mm A',
|
|
||||||
type: 'datetime',
|
|
||||||
readOnly: 'false',
|
|
||||||
tooltip: 'datetime widget'
|
|
||||||
});
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
|
||||||
const tooltip = dateElement.getAttribute('ng-reflect-message');
|
|
||||||
|
|
||||||
expect(tooltip).toEqual(widget.field.tooltip);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display always the json value', () => {
|
it('should display always the json value', () => {
|
||||||
|
@ -23,6 +23,7 @@ import { CoreTestingModule } from '../../../../testing/core.testing.module';
|
|||||||
import { FormFieldModel } from '../core/form-field.model';
|
import { FormFieldModel } from '../core/form-field.model';
|
||||||
import { FormModel } from '../core/form.model';
|
import { FormModel } from '../core/form.model';
|
||||||
import { FormFieldTypes } from '../core/form-field-types';
|
import { FormFieldTypes } from '../core/form-field-types';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('MultilineTextWidgetComponentComponent', () => {
|
describe('MultilineTextWidgetComponentComponent', () => {
|
||||||
|
|
||||||
@ -47,6 +48,42 @@ describe('MultilineTextWidgetComponentComponent', () => {
|
|||||||
expect(widget).toBeDefined();
|
expect(widget).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.MULTILINE_TEXT,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const multilineTextarea = fixture.nativeElement.querySelector('textarea');
|
||||||
|
multilineTextarea.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const multilineTextarea = fixture.nativeElement.querySelector('textarea');
|
||||||
|
multilineTextarea.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
multilineTextarea.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -19,6 +19,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { CoreTestingModule, setupTestBed } from '../../../../testing';
|
import { CoreTestingModule, setupTestBed } from '../../../../testing';
|
||||||
import { FormFieldModel, FormFieldTypes, FormModel } from '../core';
|
import { FormFieldModel, FormFieldTypes, FormModel } from '../core';
|
||||||
@ -50,6 +51,74 @@ describe('NumberWidgetComponent', () => {
|
|||||||
expect(widget).toBeDefined();
|
expect(widget).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.NUMBER,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const numberInput = fixture.nativeElement.querySelector('input');
|
||||||
|
numberInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const numberInput = fixture.nativeElement.querySelector('input');
|
||||||
|
numberInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
numberInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when is required', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.NUMBER,
|
||||||
|
required: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be marked as invalid after interaction', async () => {
|
||||||
|
const numberInput = fixture.nativeElement.querySelector('input');
|
||||||
|
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeFalsy();
|
||||||
|
|
||||||
|
numberInput.dispatchEvent(new Event('blur'));
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to display label with asterisk', async () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
const asterisk: HTMLElement = element.querySelector('.adf-asterisk');
|
||||||
|
|
||||||
|
expect(asterisk).toBeTruthy();
|
||||||
|
expect(asterisk.textContent).toEqual('*');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when form model has left labels', () => {
|
describe('when form model has left labels', () => {
|
||||||
|
|
||||||
it('should have left labels classes on leftLabels true', async () => {
|
it('should have left labels classes on leftLabels true', async () => {
|
||||||
|
@ -26,6 +26,7 @@ import { MatIconModule } from '@angular/material/icon';
|
|||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { CoreTestingModule } from '../../../../testing';
|
import { CoreTestingModule } from '../../../../testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
const enterValueInTextField = (element: HTMLInputElement, value: string) => {
|
const enterValueInTextField = (element: HTMLInputElement, value: string) => {
|
||||||
element.value = value;
|
element.value = value;
|
||||||
@ -175,23 +176,41 @@ describe('TextWidgetComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
expect(widget.field.isValid).toBe(false);
|
expect(widget.field.isValid).toBe(false);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', async () => {
|
describe('when tooltip is set', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
|
||||||
id: 'text-id',
|
beforeEach(() => {
|
||||||
name: 'text-name',
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
value: '',
|
|
||||||
type: FormFieldTypes.TEXT,
|
type: FormFieldTypes.TEXT,
|
||||||
tooltip: 'text widget'
|
tooltip: 'my custom tooltip'
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const textInput = fixture.nativeElement.querySelector('input');
|
||||||
|
textInput.dispatchEvent(new Event('mouseenter'));
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
const textElement: any = element.querySelector('#text-id');
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
const tooltip = textElement.getAttribute('ng-reflect-message');
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
expect(tooltip).toEqual(widget.field.tooltip);
|
it('should hide tooltip', async () => {
|
||||||
|
const textInput = fixture.nativeElement.querySelector('input');
|
||||||
|
textInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
textInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -472,18 +472,6 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(widget.rootNodeId).toEqual('-my-');
|
expect(widget.rootNodeId).toEqual('-my-');
|
||||||
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'single', false, true);
|
expect(openUploadFileDialogSpy).toHaveBeenCalledWith('-my-', 'single', false, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', async () => {
|
|
||||||
createUploadWidgetField(new FormModel(), 'attach-file-attach', [], onlyLocalParams);
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const attachElement = element.querySelector('#attach-file-attach');
|
|
||||||
const tooltip = attachElement.getAttribute('ng-reflect-message');
|
|
||||||
|
|
||||||
expect(tooltip).toEqual(widget.field.tooltip);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -590,7 +578,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should preview file when show is clicked', async() => {
|
it('should preview file when show is clicked', async () => {
|
||||||
spyOn(processCloudContentService, 'getRawContentNode').and.returnValue(of(new Blob()));
|
spyOn(processCloudContentService, 'getRawContentNode').and.returnValue(of(new Blob()));
|
||||||
await formService.formContentClicked.subscribe(
|
await formService.formContentClicked.subscribe(
|
||||||
(fileClicked: any) => {
|
(fileClicked: any) => {
|
||||||
@ -606,7 +594,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
showOption.click();
|
showOption.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should request form to be updated with metadata when retrieve is clicked', async() => {
|
it('should request form to be updated with metadata when retrieve is clicked', async () => {
|
||||||
updateFormSpy = spyOn(formService.updateFormValuesRequested, 'next');
|
updateFormSpy = spyOn(formService.updateFormValuesRequested, 'next');
|
||||||
widget.field.value = [fakeNodeWithProperties];
|
widget.field.value = [fakeNodeWithProperties];
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -670,7 +658,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be called onInit when widget has no value', async() => {
|
it('should not be called onInit when widget has no value', async () => {
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -678,7 +666,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have been called onInit when widget only one file', async() => {
|
it('should have been called onInit when widget only one file', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties];
|
widget.field.value = [fakeNodeWithProperties];
|
||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
|
|
||||||
@ -689,7 +677,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(fakeNodeWithProperties, widget.field.id));
|
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(fakeNodeWithProperties, widget.field.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be called onInit when widget has more than one file', async() => {
|
it('should not be called onInit when widget has more than one file', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -697,7 +685,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be called on remove node if node removed is not the selected one', async() => {
|
it('should not be called on remove node if node removed is not the selected one', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
||||||
widget.selectedNode = fakeNodeWithProperties;
|
widget.selectedNode = fakeNodeWithProperties;
|
||||||
|
|
||||||
@ -709,7 +697,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have been called on remove node if node removed is the selected one', async() => {
|
it('should have been called on remove node if node removed is the selected one', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
||||||
widget.selectedNode = fakeNodeWithProperties;
|
widget.selectedNode = fakeNodeWithProperties;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -722,7 +710,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(undefined, widget.field.id));
|
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(undefined, widget.field.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have been called on attach file when value was empty', async() => {
|
it('should have been called on attach file when value was empty', async () => {
|
||||||
clickOnAttachFileWidget('attach-file-alfresco');
|
clickOnAttachFileWidget('attach-file-alfresco');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@ -732,7 +720,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(fakeNodeWithProperties, widget.field.id));
|
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(fakeNodeWithProperties, widget.field.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be called on attach file when has a file previously', async() => {
|
it('should not be called on attach file when has a file previously', async () => {
|
||||||
widget.field.value = [fakeMinimalNode];
|
widget.field.value = [fakeMinimalNode];
|
||||||
|
|
||||||
clickOnAttachFileWidget('attach-file-alfresco');
|
clickOnAttachFileWidget('attach-file-alfresco');
|
||||||
@ -900,4 +888,40 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const attachButton = fixture.nativeElement.querySelector('button');
|
||||||
|
attachButton.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const attachButton = fixture.nativeElement.querySelector('button');
|
||||||
|
attachButton.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
attachButton.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -22,6 +22,7 @@ import moment from 'moment';
|
|||||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { DATE_FORMAT_CLOUD } from '../../../../models/date-format-cloud.model';
|
import { DATE_FORMAT_CLOUD } from '../../../../models/date-format-cloud.model';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('DateWidgetComponent', () => {
|
describe('DateWidgetComponent', () => {
|
||||||
|
|
||||||
@ -181,25 +182,6 @@ describe('DateWidgetComponent', () => {
|
|||||||
|
|
||||||
expect(widget.field.isValid).toBeFalsy();
|
expect(widget.field.isValid).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', async () => {
|
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
|
||||||
id: 'date-field-id',
|
|
||||||
name: 'date-name',
|
|
||||||
value: 'aa',
|
|
||||||
type: 'date',
|
|
||||||
readOnly: 'false',
|
|
||||||
tooltip: 'date widget'
|
|
||||||
});
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const dateElement = element.querySelector('#date-field-id');
|
|
||||||
const tooltip = dateElement.getAttribute('ng-reflect-message');
|
|
||||||
|
|
||||||
expect(tooltip).toEqual(widget.field.tooltip);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display always the json value', async () => {
|
it('should display always the json value', async () => {
|
||||||
@ -488,9 +470,77 @@ describe('DateWidgetComponent', () => {
|
|||||||
expect(widget.field.maxValue).toEqual(expectedMaxValueString);
|
expect(widget.field.maxValue).toEqual(expectedMaxValueString);
|
||||||
expect(widget.field.minValue).toEqual(expectedMinValueString);
|
expect(widget.field.minValue).toEqual(expectedMinValueString);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.DATE,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const dateCloudInput = fixture.nativeElement.querySelector('input');
|
||||||
|
dateCloudInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const dateCloudInput = fixture.nativeElement.querySelector('input');
|
||||||
|
dateCloudInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
dateCloudInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when is required', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.DATE,
|
||||||
|
required: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to display label with asterisk', async () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
const asterisk: HTMLElement = element.querySelector('.adf-asterisk');
|
||||||
|
|
||||||
|
expect(asterisk).toBeTruthy();
|
||||||
|
expect(asterisk.textContent).toEqual('*');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be invalid after user interaction without typing', async () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
expect(element.querySelector('.adf-invalid')).toBeFalsy();
|
||||||
|
|
||||||
|
const dateCloudInput = fixture.nativeElement.querySelector('input');
|
||||||
|
dateCloudInput.dispatchEvent(new Event('blur'));
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
expect(element.querySelector('.adf-invalid')).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -117,20 +117,6 @@ describe('DropdownCloudWidgetComponent', () => {
|
|||||||
expect(dropDownElement.attributes['ng-reflect-model'].value).toBe('empty');
|
expect(dropDownElement.attributes['ng-reflect-model'].value).toBe('empty');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', async () => {
|
|
||||||
widget.field.tooltip = 'dropdown widget';
|
|
||||||
|
|
||||||
widget.ngOnInit();
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const dropDownElement: any = element.querySelector('#dropdown-id');
|
|
||||||
const tooltip = dropDownElement.getAttribute('ng-reflect-message');
|
|
||||||
|
|
||||||
expect(tooltip).toEqual(widget.field.tooltip);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load data from restUrl and populate options', async () => {
|
it('should load data from restUrl and populate options', async () => {
|
||||||
const jsonDataSpy = spyOn(formCloudService, 'getRestWidgetData').and.returnValue(of(fakeOptionList));
|
const jsonDataSpy = spyOn(formCloudService, 'getRestWidgetData').and.returnValue(of(fakeOptionList));
|
||||||
widget.field.restUrl = 'https://fake-rest-url';
|
widget.field.restUrl = 'https://fake-rest-url';
|
||||||
@ -308,6 +294,42 @@ describe('DropdownCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.DROPDOWN,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const dropdownInput = fixture.debugElement.query(By.css('mat-select')).nativeElement;
|
||||||
|
dropdownInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const dropdownInput = fixture.debugElement.query(By.css('mat-select')).nativeElement;
|
||||||
|
dropdownInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
dropdownInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -21,6 +21,7 @@ import { GroupCloudWidgetComponent } from './group-cloud.widget';
|
|||||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('GroupCloudWidgetComponent', () => {
|
describe('GroupCloudWidgetComponent', () => {
|
||||||
let fixture: ComponentFixture<GroupCloudWidgetComponent>;
|
let fixture: ComponentFixture<GroupCloudWidgetComponent>;
|
||||||
@ -61,6 +62,42 @@ describe('GroupCloudWidgetComponent', () => {
|
|||||||
expect(widget.validate).toBeTruthy();
|
expect(widget.validate).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.GROUP,
|
||||||
|
tooltip: 'my custom tooltip'
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const cloudGroupInput = element.querySelector('adf-cloud-group');
|
||||||
|
cloudGroupInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const cloudGroupInput = element.querySelector('[data-automation-id="adf-cloud-group-search-input"]');
|
||||||
|
cloudGroupInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
cloudGroupInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -23,6 +23,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|||||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||||
import { IdentityUserService } from '../../../../people/services/identity-user.service';
|
import { IdentityUserService } from '../../../../people/services/identity-user.service';
|
||||||
import { mockShepherdsPie, mockYorkshirePudding } from '../../../../people/mock/people-cloud.mock';
|
import { mockShepherdsPie, mockYorkshirePudding } from '../../../../people/mock/people-cloud.mock';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('PeopleCloudWidgetComponent', () => {
|
describe('PeopleCloudWidgetComponent', () => {
|
||||||
let fixture: ComponentFixture<PeopleCloudWidgetComponent>;
|
let fixture: ComponentFixture<PeopleCloudWidgetComponent>;
|
||||||
@ -88,6 +89,43 @@ describe('PeopleCloudWidgetComponent', () => {
|
|||||||
expect(widget.validate).toBeTruthy();
|
expect(widget.validate).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.PEOPLE,
|
||||||
|
tooltip: 'my custom tooltip',
|
||||||
|
value: [mockYorkshirePudding]
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const cloudPeopleInput = element.querySelector('adf-cloud-people');
|
||||||
|
cloudPeopleInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const cloudPeopleInput = element.querySelector('adf-cloud-people');
|
||||||
|
cloudPeopleInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
cloudPeopleInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -22,6 +22,7 @@ import { FormCloudService } from '../../../services/form-cloud.service';
|
|||||||
import { RadioButtonsCloudWidgetComponent } from './radio-buttons-cloud.widget';
|
import { RadioButtonsCloudWidgetComponent } from './radio-buttons-cloud.widget';
|
||||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||||
import { of, throwError } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
describe('RadioButtonsCloudWidgetComponent', () => {
|
describe('RadioButtonsCloudWidgetComponent', () => {
|
||||||
let fixture: ComponentFixture<RadioButtonsCloudWidgetComponent>;
|
let fixture: ComponentFixture<RadioButtonsCloudWidgetComponent>;
|
||||||
@ -191,4 +192,42 @@ describe('RadioButtonsCloudWidgetComponent', () => {
|
|||||||
expect(errorIcon.textContent).toBe('error_outline');
|
expect(errorIcon.textContent).toBe('error_outline');
|
||||||
expect(errorMessage.textContent).toBe('FORM.FIELD.REST_API_FAILED');
|
expect(errorMessage.textContent).toBe('FORM.FIELD.REST_API_FAILED');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
|
type: FormFieldTypes.RADIO_BUTTONS,
|
||||||
|
tooltip: 'my custom tooltip',
|
||||||
|
optionType: 'manual',
|
||||||
|
options: restOption
|
||||||
|
});
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show tooltip', async () => {
|
||||||
|
const radioButtonsInput = element.querySelector('mat-radio-button');
|
||||||
|
radioButtonsInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip')).nativeElement;
|
||||||
|
expect(tooltipElement).toBeTruthy();
|
||||||
|
expect(tooltipElement.textContent.trim()).toBe('my custom tooltip');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip', async () => {
|
||||||
|
const radioButtonsInput = element.querySelector('mat-radio-button');
|
||||||
|
radioButtonsInput.dispatchEvent(new Event('mouseenter'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
radioButtonsInput.dispatchEvent(new Event('mouseleave'));
|
||||||
|
await fixture.whenStable();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const tooltipElement = fixture.debugElement.query(By.css('.mat-tooltip'));
|
||||||
|
expect(tooltipElement).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user