Skip to content

Commit 9879cfc

Browse files
Refactor SagaDiagram tests to use named constants for start and finish times
1 parent 000f372 commit 9879cfc

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

src/Frontend/src/components/messages/SagaDiagram.spec.ts

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,24 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
137137
// but set them again explicitly here
138138
//so that the reader of this test can see the preconditions at play
139139
//and understand the test better without having to jump around
140-
sampleSagaHistory.changes[0].start_time = new Date("2025-03-28T03:04:08.3819211Z"); // A
141-
sampleSagaHistory.changes[0].finish_time = new Date("2025-03-28T03:04:08.3836Z"); // A1
142-
sampleSagaHistory.changes[1].start_time = new Date("2025-03-28T03:04:07.5416262Z"); // B
143-
sampleSagaHistory.changes[1].finish_time = new Date("2025-03-28T03:04:07.5509712Z"); //B1
144-
sampleSagaHistory.changes[2].start_time = new Date("2025-03-28T03:04:06.3088353Z"); //C
145-
sampleSagaHistory.changes[2].finish_time = new Date("2025-03-28T03:04:06.3218175Z"); //C1
146-
sampleSagaHistory.changes[3].start_time = new Date("2025-03-28T03:04:05.3332078Z"); //D
147-
sampleSagaHistory.changes[3].finish_time = new Date("2025-03-28T03:04:05.3799483Z"); //D1
140+
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");
149+
150+
sampleSagaHistory.changes[0].start_time = startTimeA;
151+
sampleSagaHistory.changes[0].finish_time = finishTimeA1;
152+
sampleSagaHistory.changes[1].start_time = startTimeB;
153+
sampleSagaHistory.changes[1].finish_time = finishTimeB1;
154+
sampleSagaHistory.changes[2].start_time = startTimeC;
155+
sampleSagaHistory.changes[2].finish_time = finishTimeC1;
156+
sampleSagaHistory.changes[3].start_time = startTimeD;
157+
sampleSagaHistory.changes[3].finish_time = finishTimeD1;
148158
sampleSagaHistory.changes[3].status = "new";
149159

150160
//B(1), C(2), A(0), D(3)
@@ -161,16 +171,16 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
161171
//assert
162172
componentDriver.assert.thereAreTheFollowingSagaChangesInThisOrder([
163173
{
164-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[3].start_time), // D
174+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeD),
165175
},
166176
{
167-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[2].start_time), // C
177+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeC),
168178
},
169179
{
170-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[1].start_time), // B
180+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeB),
171181
},
172182
{
173-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[0].start_time), // A
183+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeA),
174184
},
175185
]);
176186
});
@@ -202,14 +212,23 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
202212
// but set them again explicitly here
203213
//so that the reader of this test can see the preconditions at play
204214
//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
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");
223+
224+
sampleSagaHistory.changes[0].start_time = startTimeA;
225+
sampleSagaHistory.changes[0].finish_time = finishTimeA1;
226+
sampleSagaHistory.changes[1].start_time = startTimeB;
227+
sampleSagaHistory.changes[1].finish_time = finishTimeB1;
228+
sampleSagaHistory.changes[2].start_time = startTimeC;
229+
sampleSagaHistory.changes[2].finish_time = finishTimeC1;
230+
sampleSagaHistory.changes[3].start_time = startTimeD;
231+
sampleSagaHistory.changes[3].finish_time = finishTimeD1;
213232
sampleSagaHistory.changes[3].status = "new";
214233

215234
// Set up the store with sample saga history
@@ -224,16 +243,16 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
224243

225244
componentDriver.assert.thereAreTheFollowingSagaChangesInThisOrder([
226245
{
227-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[3].start_time), // D
246+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeD),
228247
},
229248
{
230-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[2].start_time), // C
249+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeC),
231250
},
232251
{
233-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[1].start_time), // B
252+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeB),
234253
},
235254
{
236-
expectedRenderedLocalTime: toLocalDateTimeString(sampleSagaHistory.changes[0].start_time), // A
255+
expectedRenderedLocalTime: toLocalDateTimeString(startTimeA),
237256
},
238257
]);
239258
});

0 commit comments

Comments
 (0)