Skip to content

Commit 4e4b8ef

Browse files
committed
feat: TT-125 show customer field in time entries table
1 parent 22d7a5c commit 4e4b8ef

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

src/app/modules/time-entries/pages/time-entries.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<th class="col">Date</th>
2323
<th class="col">Time in - out</th>
2424
<th class="col">Duration</th>
25+
<th class="col">Customer</th>
2526
<th class="col">Project</th>
2627
<th class="col">Activity</th>
2728
<th class="col"></th>
@@ -33,6 +34,7 @@
3334
<td class="col">{{ entry.start_date | date: 'MM/dd/yyyy' }}</td>
3435
<td class="col">{{ entry.start_date | date: 'HH:mm' }} - {{ entry.end_date | date: 'HH:mm' }}</td>
3536
<td class="col">{{ entry.end_date | substractDate: entry.start_date }}</td>
37+
<td class="col">{{ entry.customer_name }}</td>
3638
<td class="col">{{ entry.project_name }}</td>
3739
<td class="col">{{ entry.activity_name }}</td>
3840
<td class="col">

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { TimeEntriesComponent } from './time-entries.component';
1818
import { ActionsSubject } from '@ngrx/store';
1919
import { EntryActionTypes } from './../../time-clock/store/entry.actions';
2020
import { NgxMaterialTimepickerModule } from 'ngx-material-timepicker';
21+
import { DebugElement } from '@angular/core';
2122

2223
describe('TimeEntriesComponent', () => {
2324
type Merged = TechnologyState & ProjectState & EntryState;
@@ -57,6 +58,7 @@ describe('TimeEntriesComponent', () => {
5758
project_name: 'Time-tracker',
5859
start_date: new Date('2020-02-05T15:36:15.887Z'),
5960
end_date: new Date('2020-02-05T18:36:15.887Z'),
61+
customer_name: 'ioet Inc.',
6062
activity_id: 'development',
6163
technologies: ['Angular', 'TypeScript'],
6264
description: 'No comments',
@@ -375,19 +377,59 @@ describe('TimeEntriesComponent', () => {
375377
component.entry = null;
376378
component.entryId = null;
377379
const lastEntry = {
378-
description : 'testing is fun',
379-
technologies : [],
380-
uri : 'http://testing.is.fun',
381-
activity_id : 'sss',
382-
project_id : 'id',
383-
start_date : new Date(new Date().setHours(0, 0, 0, 0)),
384-
end_date : new Date(new Date().setHours(0, 0, 0, 0))
380+
description: 'testing is fun',
381+
technologies: [],
382+
uri: 'http://testing.is.fun',
383+
activity_id: 'sss',
384+
project_id: 'id',
385+
start_date: new Date(new Date().setHours(0, 0, 0, 0)),
386+
end_date: new Date(new Date().setHours(0, 0, 0, 0))
385387
};
386-
state.timeEntriesDataSource.data = [ lastEntry ];
388+
state.timeEntriesDataSource.data = [lastEntry];
387389
mockEntriesSelector = store.overrideSelector(getTimeEntriesDataSource, state.timeEntriesDataSource);
388390

389-
component.projectSelected({ projectId : 'id'});
391+
component.projectSelected({ projectId: 'id' });
390392
expect(component.entry).toEqual(lastEntry);
391393
}));
392394

395+
it('when the data source is loaded, the entry should to have customer_name field', waitForAsync(() => {
396+
component.timeEntriesDataSource$.subscribe(() => {
397+
398+
fixture.detectChanges();
399+
400+
const expectedColumnTitles = [
401+
'Date',
402+
'Time in - out',
403+
'Duration',
404+
'Customer',
405+
'Project',
406+
'Activity',
407+
'',
408+
];
409+
410+
const columnTitles: string[] = [];
411+
412+
const HTMLTimeEntriesDebugElement: DebugElement = fixture.debugElement;
413+
const HTMLTimeEntriesElement: HTMLElement = HTMLTimeEntriesDebugElement.nativeElement;
414+
const HTMLTimeEntriesTable = HTMLTimeEntriesElement.querySelector('.table') as HTMLTableElement;
415+
const HTMLTableHead = HTMLTimeEntriesTable.rows[0];
416+
417+
Array.from(HTMLTableHead.cells).forEach(columnTitle => {
418+
columnTitles.push(columnTitle.innerText);
419+
});
420+
421+
expect(expectedColumnTitles).toEqual(columnTitles);
422+
423+
});
424+
}));
425+
426+
it('on success times entries data source charged, the entry should to have customer_name field', waitForAsync(() => {
427+
component.timeEntriesDataSource$.subscribe(dataSource => {
428+
const entryData = dataSource.data[0];
429+
430+
expect(entryData.customer_name).toContain('ioet Inc.');
431+
432+
});
433+
}));
434+
393435
});

0 commit comments

Comments
 (0)