@@ -5,7 +5,6 @@ import makeRouter from "@/router";
55import { createTestingPinia } from "@pinia/testing" ;
66import { MessageStore } from "@/stores/MessageStore" ;
77import { MessageStatus } from "@/resources/Message" ;
8- import { toLocalDateTimeString } from "@/composables/formatUtils" ;
98
109//Defines a domain-specific language (DSL) for interacting with the system under test (sut)
1110interface componentDSL {
@@ -15,7 +14,7 @@ interface componentDSL {
1514
1615//Defines a domain-specific language (DSL) for checking assertions against the system under test (sut)
1716interface componentDSLAssertions {
18- thereAreTheFollowingSagaChangesInThisOrder ( sagaUpdates : { expectedRenderedLocalTime : string } [ ] ) : void ;
17+ thereAreTheFollowingSagaChangesInThisOrder ( sagaUpdates : { expectedTime : Date } [ ] ) : void ;
1918 displayedSagaGuidIs ( sagaId : string ) : void ;
2019 displayedSagaNameIs ( humanizedSagaName : string ) : void ;
2120 linkIsShown ( arg0 : { withText : string ; withHref : string } ) : void ;
@@ -138,14 +137,14 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
138137 //so that the reader of this test can see the preconditions at play
139138 //and understand the test better without having to jump around
140139
141- const startTimeA = new Date ( "2025-03-28T03:04:08.3819211Z " ) ;
142- const finishTimeA1 = new Date ( "2025-03-28T03:04:08.3836Z " ) ;
143- const startTimeB = new Date ( "2025-03-28T03:04:07.5416262Z " ) ;
144- const finishTimeB1 = new Date ( "2025-03-28T03:04:07.5509712Z " ) ;
145- const startTimeC = new Date ( "2025-03-28T03:04:06.3088353Z " ) ;
146- const finishTimeC1 = new Date ( "2025-03-28T03:04:06.3218175Z " ) ;
147- const startTimeD = new Date ( "2025-03-28T03:04:05.3332078Z " ) ;
148- const finishTimeD1 = new Date ( "2025-03-28T03:04:05.3799483Z " ) ;
140+ const startTimeA = new Date ( "2025-03-28T03:04:08.000Z " ) ;
141+ const finishTimeA1 = new Date ( "2025-03-28T03:04:08.000Z " ) ;
142+ const startTimeB = new Date ( "2025-03-28T03:04:07.000Z " ) ;
143+ const finishTimeB1 = new Date ( "2025-03-28T03:04:07.000Z " ) ;
144+ const startTimeC = new Date ( "2025-03-28T03:04:06.000Z " ) ;
145+ const finishTimeC1 = new Date ( "2025-03-28T03:04:06.000Z " ) ;
146+ const startTimeD = new Date ( "2025-03-28T03:04:05.000Z " ) ;
147+ const finishTimeD1 = new Date ( "2025-03-28T03:04:05.000Z " ) ;
149148
150149 sampleSagaHistory . changes [ 0 ] . start_time = startTimeA ;
151150 sampleSagaHistory . changes [ 0 ] . finish_time = finishTimeA1 ;
@@ -171,16 +170,16 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
171170 //assert
172171 componentDriver . assert . thereAreTheFollowingSagaChangesInThisOrder ( [
173172 {
174- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeD ) ,
173+ expectedTime : startTimeD ,
175174 } ,
176175 {
177- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeC ) ,
176+ expectedTime : startTimeC ,
178177 } ,
179178 {
180- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeB ) ,
179+ expectedTime : startTimeB ,
181180 } ,
182181 {
183- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeA ) ,
182+ expectedTime : startTimeA ,
184183 } ,
185184 ] ) ;
186185 } ) ;
@@ -212,14 +211,14 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
212211 // but set them again explicitly here
213212 //so that the reader of this test can see the preconditions at play
214213 //and understand the test better without having to jump around
215- const startTimeA = new Date ( "2025-03-28T03:04:08.3819211Z " ) ;
216- const finishTimeA1 = new Date ( "2025-03-28T03:04:08.3836Z " ) ;
217- const startTimeB = new Date ( "2025-03-28T03:04:07.5416262Z " ) ;
218- const finishTimeB1 = new Date ( "2025-03-28T03:04:07.5509712Z " ) ;
219- const startTimeC = new Date ( "2025-03-28T03:04:06.3088353Z " ) ;
220- const finishTimeC1 = new Date ( "2025-03-28T03:04:06.3218175Z " ) ;
221- const startTimeD = new Date ( "2025-03-28T03:04:05.3332078Z " ) ;
222- const finishTimeD1 = new Date ( "2025-03-28T03:04:05.3799483Z " ) ;
214+ const startTimeA = new Date ( "2025-03-28T03:04:08.000Z " ) ;
215+ const finishTimeA1 = new Date ( "2025-03-28T03:04:08.000Z " ) ;
216+ const startTimeB = new Date ( "2025-03-28T03:04:07.000Z " ) ;
217+ const finishTimeB1 = new Date ( "2025-03-28T03:04:07.000Z " ) ;
218+ const startTimeC = new Date ( "2025-03-28T03:04:06.000Z " ) ;
219+ const finishTimeC1 = new Date ( "2025-03-28T03:04:06.000Z " ) ;
220+ const startTimeD = new Date ( "2025-03-28T03:04:05.000Z " ) ;
221+ const finishTimeD1 = new Date ( "2025-03-28T03:04:05.000Z " ) ;
223222
224223 sampleSagaHistory . changes [ 0 ] . start_time = startTimeA ;
225224 sampleSagaHistory . changes [ 0 ] . finish_time = finishTimeA1 ;
@@ -243,16 +242,16 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
243242
244243 componentDriver . assert . thereAreTheFollowingSagaChangesInThisOrder ( [
245244 {
246- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeD ) ,
245+ expectedTime : startTimeD ,
247246 } ,
248247 {
249- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeC ) ,
248+ expectedTime : startTimeC ,
250249 } ,
251250 {
252- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeB ) ,
251+ expectedTime : startTimeB ,
253252 } ,
254253 {
255- expectedRenderedLocalTime : toLocalDateTimeString ( startTimeA ) ,
254+ expectedTime : startTimeA ,
256255 } ,
257256 ] ) ;
258257 } ) ;
@@ -336,7 +335,7 @@ function rendercomponent({ initialState = {} }: { initialState?: { MessageStore?
336335 expect ( sagaGuid ) . toBeInTheDocument ( ) ;
337336 expect ( sagaGuid ) . toHaveTextContent ( guid ) ;
338337 } ,
339- thereAreTheFollowingSagaChangesInThisOrder : function ( sagaUpdates : { expectedRenderedLocalTime : string } [ ] ) : void {
338+ thereAreTheFollowingSagaChangesInThisOrder : function ( sagaUpdates : { expectedTime : Date } [ ] ) : void {
340339 //Retrive the main parent component that contains the saga changes
341340 const sagaChangesContainer = screen . getByRole ( "table" , { name : / s a g a - s e q u e n c e - l i s t / i } ) ;
342341
@@ -350,8 +349,16 @@ function rendercomponent({ initialState = {} }: { initialState?: { MessageStore?
350349
351350 const sagaUpdatesTimestampsValues = sagaUpdatesTimestamps . map ( ( item ) => item . innerHTML ) ;
352351
353- // //check if the values are in the same order as the sagaUpdates array passed to this function
354- expect ( sagaUpdatesTimestampsValues ) . toEqual ( sagaUpdates . map ( ( item ) => item . expectedRenderedLocalTime ) ) ;
352+ // Parse the rendered timestamp strings back to Date objects for comparison
353+ const parsedDatesFromUI = sagaUpdatesTimestampsValues . map ( ( timestampString ) => {
354+ // Parse the retrieved timestamp string back to a Date
355+ return new Date ( timestampString ) ;
356+ } ) ;
357+
358+ const expectedDates = sagaUpdates . map ( ( item ) => item . expectedTime ) ;
359+
360+ // Compare the dates directly
361+ expect ( parsedDatesFromUI ) . toEqual ( expectedDates ) ;
355362 } ,
356363 } ,
357364 } ;
0 commit comments