File tree Expand file tree Collapse file tree 5 files changed +78
-10
lines changed Expand file tree Collapse file tree 5 files changed +78
-10
lines changed Original file line number Diff line number Diff line change @@ -89,27 +89,27 @@ describe('JobsList', () => {
8989 // Verify default sorting
9090 table = result . getByRole ( 'table' ) ;
9191 expect ( table . querySelectorAll ( 'tbody tr:nth-child(1) td' ) [ 3 ] . textContent ) . eq (
92- '10/ 30/2023, 10:30:38 AM '
92+ '30/10/ 2023 10:30:38'
9393 ) ;
9494 expect ( table . querySelectorAll ( 'tbody tr:nth-child(2) td' ) [ 3 ] . textContent ) . eq (
95- '10/ 30/2023, 10:15:38 AM '
95+ '30/10/ 2023 10:15:38'
9696 ) ;
9797 expect ( table . querySelectorAll ( 'tbody tr:nth-child(3) td' ) [ 3 ] . textContent ) . eq (
98- '10/ 30/2023, 10:00:38 AM '
98+ '30/10/ 2023 10:00:38'
9999 ) ;
100100
101101 // Sort by start date
102102 const startDateSorter = table . querySelector ( 'thead th:nth-child(4)' ) ;
103103 await fireEvent . click ( startDateSorter ) ;
104104 table = result . getByRole ( 'table' ) ;
105105 expect ( table . querySelectorAll ( 'tbody tr:nth-child(1) td' ) [ 3 ] . textContent ) . eq (
106- '10/ 30/2023, 10:00:38 AM '
106+ '30/10/ 2023 10:00:38'
107107 ) ;
108108 expect ( table . querySelectorAll ( 'tbody tr:nth-child(2) td' ) [ 3 ] . textContent ) . eq (
109- '10/ 30/2023, 10:15:38 AM '
109+ '30/10/ 2023 10:15:38'
110110 ) ;
111111 expect ( table . querySelectorAll ( 'tbody tr:nth-child(3) td' ) [ 3 ] . textContent ) . eq (
112- '10/ 30/2023, 10:30:38 AM '
112+ '30/10/ 2023 10:30:38'
113113 ) ;
114114 } ) ;
115115
Original file line number Diff line number Diff line change 1+ import { describe , it , expect } from 'vitest' ;
2+ import { render } from '@testing-library/svelte' ;
3+
4+ import TimestampCell from '../src/lib/components/jobs/TimestampCell.svelte' ;
5+
6+ describe ( 'TimestampCell' , ( ) => {
7+ it ( 'handles null timestamp' , async ( ) => {
8+ const result = render ( TimestampCell , {
9+ props : { timestamp : null }
10+ } ) ;
11+ expect ( result . container . textContent ) . eq ( '-' ) ;
12+ } ) ;
13+
14+ it ( 'handles empty timestamp' , async ( ) => {
15+ const result = render ( TimestampCell , {
16+ props : { timestamp : '' }
17+ } ) ;
18+ expect ( result . container . textContent ) . eq ( '-' ) ;
19+ } ) ;
20+
21+ it ( 'handles valid timestamp' , async ( ) => {
22+ const result = render ( TimestampCell , {
23+ props : { timestamp : '2024-02-09T10:35:56.237579+00:00' }
24+ } ) ;
25+ expect ( result . container . textContent ) . eq ( '9/2/2024 11:35:56' ) ;
26+ } ) ;
27+ } ) ;
Original file line number Diff line number Diff line change 1111 "lint" : " prettier --check . && eslint ." ,
1212 "format" : " prettier --write ." ,
1313 "pre-commit" : " lint-staged" ,
14- "test" : " TZ=Europe/Rome vitest"
14+ "test" : " TZ=Europe/Rome LANG='it-IT' vitest"
1515 },
1616 "devDependencies" : {
1717 "@playwright/test" : " ^1.40.0" ,
Original file line number Diff line number Diff line change 1010 import { onDestroy , onMount } from ' svelte' ;
1111 import { removeDuplicatedItems } from ' $lib/common/component_utilities' ;
1212 import StandardDismissableAlert from ' ../common/StandardDismissableAlert.svelte' ;
13+ import TimestampCell from ' ./TimestampCell.svelte' ;
1314
1415 /** @type {() => Promise<import('$lib/types').ApplyWorkflow[]>} */
1516 export let jobUpdater;
178179 <table class =" table jobs-table" >
179180 <colgroup >
180181 {#if ! columnsToHide .includes (' id' )}
181- <col width =" 40 " />
182+ <col width =" 60 " />
182183 {/if }
183184 <col width =" 100" />
184185 <col width =" 110" />
334335 {/if }
335336 </td >
336337 <td >
337- {row .start_timestamp ? new Date ( row . start_timestamp ). toLocaleString () : ' - ' }
338+ < TimestampCell timestamp = {row .start_timestamp } />
338339 </td >
339340 <td >
340- {row .end_timestamp ? new Date ( row . end_timestamp ). toLocaleString () : ' - ' }
341+ < TimestampCell timestamp = {row .end_timestamp } />
341342 </td >
342343 {#if ! columnsToHide .includes (' project' )}
343344 <td >
Original file line number Diff line number Diff line change 1+ <script >
2+ /** @type {string|null} */
3+ export let timestamp;
4+
5+ let date = ' ' ;
6+ let time = ' ' ;
7+
8+ $: {
9+ if (timestamp) {
10+ const dateObj = new Date (timestamp);
11+ date = dateObj .toLocaleString ([], {
12+ day: ' numeric' ,
13+ month: ' numeric' ,
14+ year: ' numeric'
15+ });
16+ time = dateObj .toLocaleString ([], {
17+ hour: ' numeric' ,
18+ minute: ' numeric' ,
19+ second: ' numeric' ,
20+ hour12: false
21+ });
22+ } else {
23+ date = ' ' ;
24+ time = ' ' ;
25+ }
26+ }
27+ </script >
28+
29+ {#if date === ' ' }
30+ -
31+ {:else }
32+ <span class ="nowrap" >{date }</span >
33+ <span class ="nowrap" >{time }</span >
34+ {/if }
35+
36+ <style >
37+ .nowrap {
38+ display : inline-block ;
39+ }
40+ </style >
You can’t perform that action at this time.
0 commit comments