@@ -14,7 +14,7 @@ interface componentDSL {
14
14
15
15
//Defines a domain-specific language (DSL) for checking assertions against the system under test (sut)
16
16
interface componentDSLAssertions {
17
- thereAreTheFollowingSagaChangesInThisOrder ( sagaUpdates : { expectedRenderedLocalTime : string } [ ] ) : void ;
17
+ thereAreTheFollowingSagaChangesInThisOrder ( sagaUpdates : { expectedTime : Date } [ ] ) : void ;
18
18
displayedSagaGuidIs ( sagaId : string ) : void ;
19
19
displayedSagaNameIs ( humanizedSagaName : string ) : void ;
20
20
linkIsShown ( arg0 : { withText : string ; withHref : string } ) : void ;
@@ -136,14 +136,24 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
136
136
// but set them again explicitly here
137
137
//so that the reader of this test can see the preconditions at play
138
138
//and understand the test better without having to jump around
139
- sampleSagaHistory . changes [ 0 ] . start_time = new Date ( "2025-03-28T03:04:08.3819211Z" ) ; // A
140
- sampleSagaHistory . changes [ 0 ] . finish_time = new Date ( "2025-03-28T03:04:08.3836Z" ) ; // A1
141
- sampleSagaHistory . changes [ 1 ] . start_time = new Date ( "2025-03-28T03:04:07.5416262Z" ) ; // B
142
- sampleSagaHistory . changes [ 1 ] . finish_time = new Date ( "2025-03-28T03:04:07.5509712Z" ) ; //B1
143
- sampleSagaHistory . changes [ 2 ] . start_time = new Date ( "2025-03-28T03:04:06.3088353Z" ) ; //C
144
- sampleSagaHistory . changes [ 2 ] . finish_time = new Date ( "2025-03-28T03:04:06.3218175Z" ) ; //C1
145
- sampleSagaHistory . changes [ 3 ] . start_time = new Date ( "2025-03-28T03:04:05.3332078Z" ) ; //D
146
- sampleSagaHistory . changes [ 3 ] . finish_time = new Date ( "2025-03-28T03:04:05.3799483Z" ) ; //D1
139
+
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" ) ;
148
+
149
+ sampleSagaHistory . changes [ 0 ] . start_time = startTimeA ;
150
+ sampleSagaHistory . changes [ 0 ] . finish_time = finishTimeA1 ;
151
+ sampleSagaHistory . changes [ 1 ] . start_time = startTimeB ;
152
+ sampleSagaHistory . changes [ 1 ] . finish_time = finishTimeB1 ;
153
+ sampleSagaHistory . changes [ 2 ] . start_time = startTimeC ;
154
+ sampleSagaHistory . changes [ 2 ] . finish_time = finishTimeC1 ;
155
+ sampleSagaHistory . changes [ 3 ] . start_time = startTimeD ;
156
+ sampleSagaHistory . changes [ 3 ] . finish_time = finishTimeD1 ;
147
157
sampleSagaHistory . changes [ 3 ] . status = "new" ;
148
158
149
159
//B(1), C(2), A(0), D(3)
@@ -158,19 +168,18 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
158
168
} ) ;
159
169
160
170
//assert
161
-
162
171
componentDriver . assert . thereAreTheFollowingSagaChangesInThisOrder ( [
163
172
{
164
- expectedRenderedLocalTime : "3/28/2025 3:04:05 AM" ,
173
+ expectedTime : startTimeD ,
165
174
} ,
166
175
{
167
- expectedRenderedLocalTime : "3/28/2025 3:04:06 AM" ,
176
+ expectedTime : startTimeC ,
168
177
} ,
169
178
{
170
- expectedRenderedLocalTime : "3/28/2025 3:04:07 AM" ,
179
+ expectedTime : startTimeB ,
171
180
} ,
172
181
{
173
- expectedRenderedLocalTime : "3/28/2025 3:04:08 AM" ,
182
+ expectedTime : startTimeA ,
174
183
} ,
175
184
] ) ;
176
185
} ) ;
@@ -202,14 +211,23 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
202
211
// but set them again explicitly here
203
212
//so that the reader of this test can see the preconditions at play
204
213
//and understand the test better without having to jump around
205
- sampleSagaHistory . changes [ 0 ] . start_time = new Date ( "2025-03-28T03:04:08.3819211Z" ) ; // A
206
- sampleSagaHistory . changes [ 0 ] . finish_time = new Date ( "2025-03-28T03:04:08.3836Z" ) ; // A1
207
- sampleSagaHistory . changes [ 1 ] . start_time = new Date ( "2025-03-28T03:04:07.5416262Z" ) ; // B
208
- sampleSagaHistory . changes [ 1 ] . finish_time = new Date ( "2025-03-28T03:04:07.5509712Z" ) ; //B1
209
- sampleSagaHistory . changes [ 2 ] . start_time = new Date ( "2025-03-28T03:04:06.3088353Z" ) ; //C
210
- sampleSagaHistory . changes [ 2 ] . finish_time = new Date ( "2025-03-28T03:04:06.3218175Z" ) ; //C1
211
- sampleSagaHistory . changes [ 3 ] . start_time = new Date ( "2025-03-28T03:04:05.3332078Z" ) ; //D
212
- sampleSagaHistory . changes [ 3 ] . finish_time = new Date ( "2025-03-28T03:04:05.3799483Z" ) ; //D1
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" ) ;
222
+
223
+ sampleSagaHistory . changes [ 0 ] . start_time = startTimeA ;
224
+ sampleSagaHistory . changes [ 0 ] . finish_time = finishTimeA1 ;
225
+ sampleSagaHistory . changes [ 1 ] . start_time = startTimeB ;
226
+ sampleSagaHistory . changes [ 1 ] . finish_time = finishTimeB1 ;
227
+ sampleSagaHistory . changes [ 2 ] . start_time = startTimeC ;
228
+ sampleSagaHistory . changes [ 2 ] . finish_time = finishTimeC1 ;
229
+ sampleSagaHistory . changes [ 3 ] . start_time = startTimeD ;
230
+ sampleSagaHistory . changes [ 3 ] . finish_time = finishTimeD1 ;
213
231
sampleSagaHistory . changes [ 3 ] . status = "new" ;
214
232
215
233
// Set up the store with sample saga history
@@ -224,16 +242,16 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
224
242
225
243
componentDriver . assert . thereAreTheFollowingSagaChangesInThisOrder ( [
226
244
{
227
- expectedRenderedLocalTime : "3/27/2025 8:04:05 PM" ,
245
+ expectedTime : startTimeD ,
228
246
} ,
229
247
{
230
- expectedRenderedLocalTime : "3/27/2025 8:04:06 PM" ,
248
+ expectedTime : startTimeC ,
231
249
} ,
232
250
{
233
- expectedRenderedLocalTime : "3/27/2025 8:04:07 PM" ,
251
+ expectedTime : startTimeB ,
234
252
} ,
235
253
{
236
- expectedRenderedLocalTime : "3/27/2025 8:04:08 PM" ,
254
+ expectedTime : startTimeA ,
237
255
} ,
238
256
] ) ;
239
257
} ) ;
@@ -317,21 +335,30 @@ function rendercomponent({ initialState = {} }: { initialState?: { MessageStore?
317
335
expect ( sagaGuid ) . toBeInTheDocument ( ) ;
318
336
expect ( sagaGuid ) . toHaveTextContent ( guid ) ;
319
337
} ,
320
- thereAreTheFollowingSagaChangesInThisOrder : function ( sagaUpdates : { expectedRenderedLocalTime : string } [ ] ) : void {
338
+ thereAreTheFollowingSagaChangesInThisOrder : function ( sagaUpdates : { expectedTime : Date } [ ] ) : void {
321
339
//Retrive the main parent component that contains the saga changes
322
340
const sagaChangesContainer = screen . getByRole ( "table" , { name : / s a g a - s e q u e n c e - l i s t / i } ) ;
323
341
324
342
const sagaUpdatesElements = within ( sagaChangesContainer ) . queryAllByRole ( "row" ) ;
325
- //from within each sagaUpdatesElemtns get the values of an element with aria-label="time stamp"
343
+ //from within each sagaUpdatesElements get the values of an element with aria-label="time stamp"
326
344
//and check if the values are in the same order as the sagaUpdates array passed to this function
327
345
const sagaUpdatesTimestamps = sagaUpdatesElements . map ( ( item : HTMLElement ) => within ( item ) . getByLabelText ( "time stamp" ) ) ;
328
346
329
347
//expect the number of found sagaUpdatesTimestamps to be the same as the number of sagaUpdates passed to this function
330
348
expect ( sagaUpdatesTimestamps ) . toHaveLength ( sagaUpdates . length ) ;
331
349
332
350
const sagaUpdatesTimestampsValues = sagaUpdatesTimestamps . map ( ( item ) => item . innerHTML ) ;
333
- // //check if the values are in the same order as the sagaUpdates array passed to this function
334
- expect ( sagaUpdatesTimestampsValues ) . toEqual ( sagaUpdates . map ( ( item ) => item . expectedRenderedLocalTime ) ) ;
351
+
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 ) ;
335
362
} ,
336
363
} ,
337
364
} ;
0 commit comments