From 44225271832a3340cf565cea2a26d05d7c7678d4 Mon Sep 17 00:00:00 2001 From: Jimmy Jaramillo Date: Wed, 3 Aug 2022 02:19:29 -0500 Subject: [PATCH] fix: TTA-119 fix date column format in reports --- .../time-entries-table.component.spec.ts | 56 +++++++++++++++++-- .../time-entries-table.component.ts | 2 +- .../time-clock/services/entry.service.spec.ts | 3 +- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts index 510634060..5c74db2b0 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts @@ -155,13 +155,13 @@ describe('Reports Page', () => { }); }); - it('The data should be displayed as a multiple of hour when column is equal to 3', () => { - const column = 3; + it('The data should be displayed as a multiple of hour when column is equal to 4', () => { + const column = 4; expect(component.bodyExportOptions(durationTime, row, column, node)).toMatch(decimalValidator); }); - it('The data should not be displayed as a multiple of hour when column is different of 3', () => { - const column = 4; + it('The data should not be displayed as a multiple of hour when column is different of 4', () => { + const column = 5; expect(component.bodyExportOptions(durationTime, row, column, node)).toBe(durationTime.toString()); }); @@ -217,6 +217,54 @@ describe('Reports Page', () => { expect({hours, minutes, seconds}).toEqual({hours:0, minutes:0, seconds:0}); }); + it('should export data with the correct format', () => { + const data = [ + '', + '19', + 'user@ioet.com', + '07/01/2022', + '09:00', + '09:00', + '18:00', + 'Project_Name', + '3', + 'Customer_Name', + '3', + 'Activity_Name', + ` https://ioetec.atlassian.net/browse/CB-115 `, + '', + `
git
` + ]; + const dataFormat = [ + ' ', + '19', + 'user@ioet.com', + '07/01/2022', + '9.00', + '09:00', + '18:00', + 'Project_Name', + '3', + 'Customer_Name', + '3', + 'Activity_Name', + ' https://ioetec.atlassian.net/browse/CB-115 ', + '', + ' git ' + ]; + + data.forEach((value: any, index) => { + const formatValue = component.bodyExportOptions(value, row, index, node); + expect(formatValue).toEqual(dataFormat[index]); + }); + }); + afterEach(() => { fixture.destroy(); }); diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts index 9b2fbff84..a0bf5e768 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts @@ -137,7 +137,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn bodyExportOptions(data, row, column, node) { const dataFormated = data.toString().replace(/<((.|\n){0,200}?)>/gi, ''); - const durationColumnIndex = 3; + const durationColumnIndex = 4; return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated; } diff --git a/src/app/modules/time-clock/services/entry.service.spec.ts b/src/app/modules/time-clock/services/entry.service.spec.ts index f54abebe4..527898810 100644 --- a/src/app/modules/time-clock/services/entry.service.spec.ts +++ b/src/app/modules/time-clock/services/entry.service.spec.ts @@ -10,13 +10,14 @@ import * as moment from 'moment'; describe('EntryService', () => { let service: EntryService; let httpMock: HttpTestingController; - var reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report'; + let reportsUrl: any; beforeEach(() => { TestBed.configureTestingModule({imports: [HttpClientTestingModule], providers: [DatePipe]}); service = TestBed.inject(EntryService); httpMock = TestBed.inject(HttpTestingController); service.baseUrl = 'time-entries'; + reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report'; }); it('services are ready to be used', inject(