Skip to content

Commit 0cfc649

Browse files
committed
fix ts and lint errors, add dummy data for test
1 parent 94d83c2 commit 0cfc649

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SagaHistory } from "@/resources/SagaHistory";
44
import makeRouter from "@/router";
55
import { createTestingPinia } from "@pinia/testing";
66
import { MessageStore } from "@/stores/MessageStore";
7+
import { MessageStatus } from "@/resources/Message";
78

89
//Defines a domain-specific language (DSL) for interacting with the system under test (sut)
910
interface componentDSL {
@@ -377,9 +378,12 @@ const sampleSagaHistory: SagaHistory = {
377378
is_saga_timeout_message: true,
378379
originating_endpoint: "Endpoint1",
379380
originating_machine: "mobvm2",
381+
receiving_endpoint: "receiving endpoint",
380382
time_sent: new Date("2025-03-28T03:04:06.321561Z"),
381383
message_type: "ServiceControl.SmokeTest.MyCustomTimeout",
382384
intent: "Send",
385+
body_url: "body_url",
386+
message_status: MessageStatus.Successful,
383387
},
384388
outgoing_messages: [],
385389
endpoint: "Endpoint1",
@@ -394,9 +398,12 @@ const sampleSagaHistory: SagaHistory = {
394398
is_saga_timeout_message: true,
395399
originating_endpoint: "Endpoint1",
396400
originating_machine: "mobvm2",
401+
receiving_endpoint: "receiving endpoint",
397402
time_sent: new Date("2025-03-28T03:04:05.37723Z"),
398403
message_type: "ServiceControl.SmokeTest.MyCustomTimeout",
399404
intent: "Send",
405+
body_url: "body_url",
406+
message_status: MessageStatus.Successful,
400407
},
401408
outgoing_messages: [],
402409
endpoint: "Endpoint1",
@@ -411,9 +418,12 @@ const sampleSagaHistory: SagaHistory = {
411418
is_saga_timeout_message: false,
412419
originating_endpoint: "Sender",
413420
originating_machine: "mobvm2",
421+
receiving_endpoint: "receiving endpoint",
414422
time_sent: new Date("2025-03-28T03:04:06.293765Z"),
415423
message_type: "ServiceControl.SmokeTest.SagaMessage2",
416424
intent: "Send",
425+
body_url: "body_url",
426+
message_status: MessageStatus.Successful,
417427
},
418428
outgoing_messages: [
419429
{
@@ -423,6 +433,13 @@ const sampleSagaHistory: SagaHistory = {
423433
time_sent: new Date("2025-03-28T03:04:06.3214397Z"),
424434
message_type: "ServiceControl.SmokeTest.MyCustomTimeout",
425435
intent: "Send",
436+
deliver_at: new Date("2025-03-28T03:04:06.293765Z"),
437+
is_saga_timeout_message: false,
438+
originating_endpoint: "Sender",
439+
originating_machine: "mobvm2",
440+
receiving_endpoint: "receiving endpoint",
441+
body_url: "body_url",
442+
message_status: MessageStatus.Successful,
426443
},
427444
],
428445
endpoint: "Endpoint1",
@@ -437,9 +454,12 @@ const sampleSagaHistory: SagaHistory = {
437454
is_saga_timeout_message: false,
438455
originating_endpoint: "Sender",
439456
originating_machine: "mobvm2",
457+
receiving_endpoint: "receiving endpoint",
440458
time_sent: new Date("2025-03-28T03:04:05.235534Z"),
441459
message_type: "ServiceControl.SmokeTest.SagaMessage1",
442460
intent: "Send",
461+
body_url: "body_url",
462+
message_status: MessageStatus.Successful,
443463
},
444464
outgoing_messages: [
445465
{
@@ -449,6 +469,13 @@ const sampleSagaHistory: SagaHistory = {
449469
time_sent: new Date("2025-03-28T03:04:05.3715034Z"),
450470
message_type: "ServiceControl.SmokeTest.MyCustomTimeout",
451471
intent: "Send",
472+
deliver_at: new Date("2025-03-28T03:04:06.293765Z"),
473+
is_saga_timeout_message: false,
474+
originating_endpoint: "Sender",
475+
originating_machine: "mobvm2",
476+
receiving_endpoint: "receiving endpoint",
477+
body_url: "body_url",
478+
message_status: MessageStatus.Successful,
452479
},
453480
],
454481
endpoint: "Endpoint1",

src/Frontend/src/components/messages2/SagaDiagram/SagaUpdateNode.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import EventIcon from "@/assets/event.svg";
99
import SagaInitiatedIcon from "@/assets/SagaInitiatedIcon.svg";
1010
import SagaUpdatedIcon from "@/assets/SagaUpdatedIcon.svg";
1111
12-
const props = defineProps<{
12+
defineProps<{
1313
update: SagaUpdateViewModel;
1414
showMessageData?: boolean;
1515
}>();

src/Frontend/src/resources/SagaHistory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface SagaMessage {
2121
message_id: string;
2222
is_saga_timeout_message: boolean;
2323
originating_endpoint: string;
24+
originating_machine: string;
2425
receiving_endpoint: string;
2526
time_sent: Date;
2627
message_type: string;

src/Frontend/src/stores/SagaDiagramStore.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { acceptHMRUpdate, defineStore } from "pinia";
22
import { ref, watch } from "vue";
33
import { SagaHistory, SagaMessage } from "@/resources/SagaHistory";
44
import { useFetchFromServiceControl } from "@/composables/serviceServiceControlUrls";
5-
import { MessageStatus } from "@/resources/Message";
5+
import Message from "@/resources/Message";
66
const StandardKeys = ["$type", "Id", "Originator", "OriginalMessageId"];
77
export interface SagaMessageDataItem {
88
key: string;
@@ -55,7 +55,7 @@ export const useSagaDiagramStore = defineStore("sagaHistory", () => {
5555
if (needsBodyUrl && messagesToFetch.length > 0) {
5656
const auditMessages = await getAuditMessages(sagaId.value!);
5757
messagesToFetch.forEach((message) => {
58-
const auditMessage = auditMessages.find((x) => x.message_id === message.message_id);
58+
const auditMessage = auditMessages.find((x: Message) => x.message_id === message.message_id);
5959
if (auditMessage) {
6060
message.body_url = auditMessage.body_url;
6161
}
@@ -198,24 +198,26 @@ export const useSagaDiagramStore = defineStore("sagaHistory", () => {
198198
}
199199

200200
// Replace or modify the existing processJsonValues function
201-
function processJsonValues(jsonBody: any): SagaMessageDataItem[] {
201+
function processJsonValues(jsonBody: string | Record<string, unknown>): SagaMessageDataItem[] {
202+
let parsedBody: Record<string, unknown>;
202203
if (typeof jsonBody === "string") {
203204
try {
204-
jsonBody = JSON.parse(jsonBody);
205+
parsedBody = JSON.parse(jsonBody);
205206
} catch (e) {
206207
console.error("Error parsing JSON:", e);
207208
return [];
208209
}
210+
} else {
211+
parsedBody = jsonBody;
209212
}
210213

211214
const items: SagaMessageDataItem[] = [];
212215

213-
// Filter out standard keys and convert to KeyValuePairs
214-
for (const key in jsonBody) {
216+
for (const key in parsedBody) {
215217
if (!StandardKeys.includes(key)) {
216218
items.push({
217219
key: key,
218-
value: String(jsonBody[key] ?? ""),
220+
value: String(parsedBody[key] ?? ""),
219221
});
220222
}
221223
}

0 commit comments

Comments
 (0)