Skip to content

Commit b58a9e9

Browse files
fix: TTA-119 fix date column format in reports (#910)
Co-authored-by: Jimmy Jaramillo <[email protected]>
1 parent e32b521 commit b58a9e9

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ describe('Reports Page', () => {
155155
});
156156
});
157157

158-
it('The data should be displayed as a multiple of hour when column is equal to 3', () => {
159-
const column = 3;
158+
it('The data should be displayed as a multiple of hour when column is equal to 4', () => {
159+
const column = 4;
160160
expect(component.bodyExportOptions(durationTime, row, column, node)).toMatch(decimalValidator);
161161
});
162162

163-
it('The data should not be displayed as a multiple of hour when column is different of 3', () => {
164-
const column = 4;
163+
it('The data should not be displayed as a multiple of hour when column is different of 4', () => {
164+
const column = 5;
165165
expect(component.bodyExportOptions(durationTime, row, column, node)).toBe(durationTime.toString());
166166
});
167167

@@ -217,6 +217,54 @@ describe('Reports Page', () => {
217217
expect({hours, minutes, seconds}).toEqual({hours:0, minutes:0, seconds:0});
218218
});
219219

220+
it('should export data with the correct format', () => {
221+
const data = [
222+
'<mat-checkbox _ngcontent-tst-c180="" class="mat-checkbox mat-accent" id="mat-checkbox-27"><label class="mat-checkbox-layout" for="mat-checkbox-27-input"><span class="mat-checkbox-inner-container mat-checkbox-inner-container-no-side-margin"><input type="checkbox" class="mat-checkbox-input cdk-visually-hidden" id="mat-checkbox-27-input" tabindex="0" aria-checked="false"><span matripple="" class="mat-ripple mat-checkbox-ripple mat-focus-indicator" ng-reflect-trigger="[object HTMLLabelElement]" ng-reflect-disabled="false" ng-reflect-radius="20" ng-reflect-centered="true" ng-reflect-animation="[object Object]"><span class="mat-ripple-element mat-checkbox-persistent-ripple"></span></span><span class="mat-checkbox-frame"></span><span class="mat-checkbox-background"><svg version="1.1" focusable="false" viewBox="0 0 24 24" xml:space="preserve" class="mat-checkbox-checkmark"><path fill="none" stroke="white" d="M4.1,12.7 9,17.6 20.3,6.3" class="mat-checkbox-checkmark-path"></path></svg><span class="mat-checkbox-mixedmark"></span></span></span><span class="mat-checkbox-label"><span style="display: none;">&nbsp;</span></span></label></mat-checkbox>',
223+
'19',
224+
225+
'07/01/2022',
226+
'09:00',
227+
'09:00',
228+
'18:00',
229+
'Project_Name',
230+
'3',
231+
'Customer_Name',
232+
'3',
233+
'Activity_Name',
234+
`<a _ngcontent-tst-c180="" class="is-url ng-star-inserted"> https://ioetec.atlassian.net/browse/CB-115 </a><!--ng-container--><!--bindings={
235+
"ng-reflect-ng-if": "true"
236+
}-->`,
237+
'',
238+
`<div _ngcontent-tst-c180="" class="badge bg-secondary text-wrap ng-star-inserted"> git </div><!--bindings={
239+
"ng-reflect-ng-for-of": "git"
240+
}--><!--ng-container--><!--bindings={
241+
"ng-reflect-ng-if": "true"
242+
}-->`
243+
];
244+
const dataFormat = [
245+
'<span matripple="" class="mat-ripple mat-checkbox-ripple mat-focus-indicator" ng-reflect-trigger="[object HTMLLabelElement]" ng-reflect-disabled="false" ng-reflect-radius="20" ng-reflect-centered="true" ng-reflect-animation="[object Object]">&nbsp;',
246+
'19',
247+
248+
'07/01/2022',
249+
'9.00',
250+
'09:00',
251+
'18:00',
252+
'Project_Name',
253+
'3',
254+
'Customer_Name',
255+
'3',
256+
'Activity_Name',
257+
' https://ioetec.atlassian.net/browse/CB-115 ',
258+
'',
259+
' git '
260+
];
261+
262+
data.forEach((value: any, index) => {
263+
const formatValue = component.bodyExportOptions(value, row, index, node);
264+
expect(formatValue).toEqual(dataFormat[index]);
265+
});
266+
});
267+
220268
afterEach(() => {
221269
fixture.destroy();
222270
});

src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
137137

138138
bodyExportOptions(data, row, column, node) {
139139
const dataFormated = data.toString().replace(/<((.|\n){0,200}?)>/gi, '');
140-
const durationColumnIndex = 3;
140+
const durationColumnIndex = 4;
141141
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
142142
}
143143

src/app/modules/time-clock/services/entry.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import * as moment from 'moment';
1010
describe('EntryService', () => {
1111
let service: EntryService;
1212
let httpMock: HttpTestingController;
13-
var reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report';
13+
let reportsUrl: any;
1414

1515
beforeEach(() => {
1616
TestBed.configureTestingModule({imports: [HttpClientTestingModule], providers: [DatePipe]});
1717
service = TestBed.inject(EntryService);
1818
httpMock = TestBed.inject(HttpTestingController);
1919
service.baseUrl = 'time-entries';
20+
reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report';
2021
});
2122

2223
it('services are ready to be used', inject(

0 commit comments

Comments
 (0)