Skip to content

Commit

Permalink
[APPS-2108] migrate analytics report to date-fns (#8985)
Browse files Browse the repository at this point in the history
* migrate analytics report to date-fns

* migrate bar chart model
  • Loading branch information
DenysVuika authored Oct 10, 2023
1 parent f6d48cb commit a86b9e6
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { SimpleChange } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import { ReportParametersModel } from '../../diagram/models/report/report-parameters.model';
import * as analyticParamsMock from '../../mock';
import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component';
import { AnalyticsReportParametersComponent, ReportFormValues } from '../components/analytics-report-parameters.component';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { AnalyticsService } from '../services/analytics.service';
import { of } from 'rxjs';
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('AnalyticsReportParametersComponent', () => {

it('Should initialize the Report form with a Form Group ', async () => {
const fakeReportParam = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
await component.successReportParams.subscribe(() => {
component.successReportParams.subscribe(() => {
fixture.detectChanges();
expect(component.reportForm.get('taskGroup')).toBeDefined();
expect(component.reportForm.get('taskGroup').get('taskName')).toBeDefined();
Expand All @@ -70,7 +70,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should render a dropdown with all the status when the definition parameter type is \'status\' ', async () => {
await component.successReportParams.subscribe(() => {
component.successReportParams.subscribe(() => {
fixture.detectChanges();
const dropDown: any = element.querySelector('#select-status');
expect(element.querySelector('h4').textContent.trim()).toEqual('Fake Task overview status');
Expand All @@ -94,7 +94,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should render a number with the default value when the definition parameter type is \'integer\' ', async () => {
await component.successReportParams.subscribe(() => {
component.successReportParams.subscribe(() => {
fixture.detectChanges();
const numberElement: any = element.querySelector('#slowProcessInstanceInteger');
expect(numberElement.value).toEqual('10');
Expand All @@ -112,7 +112,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should render a duration component when the definition parameter type is "duration"', async () => {
await component.successReportParams.subscribe(() => {
component.successReportParams.subscribe(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
const numberElement: any = element.querySelector('#duration');
Expand Down Expand Up @@ -147,12 +147,12 @@ describe('AnalyticsReportParametersComponent', () => {
expect(res.processDefinitionId).toEqual('FakeProcess:1:22');
expect(res.taskName).toEqual('FakeTaskName');
expect(res.duration).toEqual(22);
expect(res.dateRangeInterval).toEqual(120);
expect(res.dateRangeInterval).toEqual('120');
expect(res.slowProcessInstanceInteger).toEqual(2);
expect(res.typeFiltering).toEqual(true);
});

const values: any = {
const values: ReportFormValues = {
dateRange: {
startDate: '2016-09-01', endDate: '2016-10-05'
},
Expand All @@ -169,10 +169,10 @@ describe('AnalyticsReportParametersComponent', () => {
duration: 22
},
dateIntervalGroup: {
dateRangeInterval: 120
dateRangeInterval: '120'
},
processInstanceGroup: {
slowProcessInstanceInteger: 2
slowProcessInstanceInteger: '2'
},
typeFilteringGroup: {
typeFiltering: true
Expand All @@ -183,7 +183,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should render a checkbox with the value true when the definition parameter type is \'boolean\' ', async () => {
await component.successReportParams.subscribe(() => {
component.successReportParams.subscribe(() => {
fixture.detectChanges();
const checkElement: any = element.querySelector('#typeFiltering-input');
expect(checkElement.checked).toBeTruthy();
Expand All @@ -201,7 +201,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should render a date range components when the definition parameter type is \'dateRange\' ', async () => {
await component.successReportParams.subscribe(() => {
component.successReportParams.subscribe(() => {
const dateElement: any = element.querySelector('adf-date-range-widget');
expect(dateElement).toBeDefined();
});
Expand All @@ -219,7 +219,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should render a dropdown with all the RangeInterval when the definition parameter type is \'dateRangeInterval\' ', async () => {
await component.successReportParams.subscribe(() => {
component.successReportParams.subscribe(() => {
fixture.detectChanges();
const dropDown: any = element.querySelector('#select-dateRangeInterval');
expect(dropDown).toBeDefined();
Expand All @@ -244,7 +244,7 @@ describe('AnalyticsReportParametersComponent', () => {

it('Should render a dropdown with all the process definition when the definition parameter type is \'processDefinition\' and the' +
' reportId change', async () => {
await component.successParamOpt.subscribe(() => {
component.successParamOpt.subscribe(() => {
fixture.detectChanges();
const dropDown: any = element.querySelector('#select-processDefinitionId');
expect(dropDown).toBeDefined();
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('AnalyticsReportParametersComponent', () => {

it('Should render a dropdown with all the process definition when the definition parameter type is \'processDefinition\' and the' +
' appId change', async () => {
await component.successParamOpt.subscribe(() => {
component.successParamOpt.subscribe(() => {
fixture.detectChanges();
const dropDown: any = element.querySelector('#select-processDefinitionId');
expect(dropDown).toBeDefined();
Expand Down Expand Up @@ -347,7 +347,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should emit an error with a 404 response when the options response is not found', async () => {
await component.error.subscribe((err) => {
component.error.subscribe((err) => {
expect(err).toBeDefined();
});

Expand All @@ -370,7 +370,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should emit an error with a 404 response when the report parameters response is not found', async () => {
await component.error.subscribe((err) => {
component.error.subscribe((err) => {
expect(err).toBeDefined();
});

Expand All @@ -386,7 +386,7 @@ describe('AnalyticsReportParametersComponent', () => {
});

it('Should convert a string in number', () => {
const numberConvert = component.convertNumber('2');
const numberConvert = component.parseNumber('2');
expect(numberConvert).toEqual(2);
});

Expand Down
Loading

0 comments on commit a86b9e6

Please sign in to comment.