1
1
import { render , describe , test , screen , expect , within } from "@component-test-utils" ;
2
2
import sut from "../messages2/SagaDiagram.vue" ;
3
- import Message , { SagaInfo } from "@/resources/Message" ;
4
3
import { SagaHistory } from "@/resources/SagaHistory" ;
5
4
import makeRouter from "@/router" ;
6
5
import { createTestingPinia } from "@pinia/testing" ;
6
+ import { MessageStore } from "@/stores/MessageStore" ;
7
7
8
8
//Defines a domain-specific language (DSL) for interacting with the system under test (sut)
9
9
interface componentDSL {
@@ -25,10 +25,22 @@ interface componentDSLAssertions {
25
25
describe ( "Feature: Message not involved in Saga" , ( ) => {
26
26
describe ( "Rule: When the selected message has not participated in a Saga, display a legend indicating it." , ( ) => {
27
27
test ( "EXAMPLE: A message that has not participated in a saga is selected" , ( ) => {
28
- const message = { } as Message ;
29
- message . invoked_sagas = [ ] ;
28
+ const messageStore = { } as MessageStore ;
29
+ messageStore . state = { } as MessageStore [ "state" ] ;
30
+ messageStore . state . data = { } as MessageStore [ "state" ] [ "data" ] ;
31
+ messageStore . state . data . invoked_saga = {
32
+ has_saga : false ,
33
+ saga_id : undefined ,
34
+ saga_type : undefined ,
35
+ } ;
30
36
31
- const componentDriver = rendercomponent ( { message : message } ) ;
37
+ // No need to manually set up the store - it will be empty by default
38
+ const componentDriver = rendercomponent ( {
39
+ initialState : {
40
+ MessageStore : messageStore ,
41
+ sagaHistory : undefined , // Lets pass undefined to simulate no saga data available
42
+ } ,
43
+ } ) ;
32
44
33
45
componentDriver . assert . NoSagaDataAvailableMessageIsShownWithMessage ( / n o s a g a d a t a / i) ;
34
46
} ) ;
@@ -38,15 +50,21 @@ describe("Feature: Message not involved in Saga", () => {
38
50
describe ( "Feature: Detecting no Audited Saga Data Available" , ( ) => {
39
51
describe ( "Rule: When a message participates in a Saga, but the Saga data is unavailable, display a legend indicating that the Saga audit plugin is needed to visualize the saga." , ( ) => {
40
52
test ( "EXAMPLE: A message that was participated in a Saga without the Saga audit plugin being active gets selected" , ( ) => {
41
- const message = { } as Message ;
42
- const invokedSaga = { } as SagaInfo ;
43
- invokedSaga . saga_id = "saga_id" ;
44
- message . invoked_sagas = [ invokedSaga ] ;
53
+ const messageStore = { } as MessageStore ;
54
+ messageStore . state = { } as MessageStore [ "state" ] ;
55
+ messageStore . state . data = { } as MessageStore [ "state" ] [ "data" ] ;
56
+ messageStore . state . data . invoked_saga = {
57
+ has_saga : true ,
58
+ saga_id : "saga-id-123" ,
59
+ saga_type : "Shipping.ShipOrderWorkflow" ,
60
+ } ;
45
61
46
62
// No need to manually set up the store - it will be empty by default
47
63
const componentDriver = rendercomponent ( {
48
- message : message ,
49
- // No initial state needed - we want an empty saga history
64
+ initialState : {
65
+ MessageStore : messageStore ,
66
+ sagaHistory : undefined , // Lets pass undefined to simulate no saga data available
67
+ } ,
50
68
} ) ;
51
69
52
70
componentDriver . assert . SagaPlugInNeededIsShownWithTheMessages ( {
@@ -61,21 +79,24 @@ describe("Feature: Navigation and Contextual Information", () => {
61
79
describe ( "Rule: Provide clear navigational elements to move between the message flow diagram and the saga view." , ( ) => {
62
80
test ( "EXAMPLE: A message record with id '123' and with a saga Id '88878' gets selected" , ( ) => {
63
81
//A "← Back to Messages" link allows users to easily navigate back to the flow diagram.
64
- const message = { } as Message ;
65
- const invokedSaga = { } as SagaInfo ;
66
- invokedSaga . saga_id = "88878" ;
67
- message . invoked_sagas = [ invokedSaga ] ;
68
-
69
82
const storedMessageRecordId = "123" ;
70
83
const message_id = "456" ;
71
84
72
- message . id = storedMessageRecordId ;
73
- message . message_id = message_id ;
85
+ const messageStore = { } as MessageStore ;
86
+ messageStore . state = { } as MessageStore [ "state" ] ;
87
+ messageStore . state . data = { } as MessageStore [ "state" ] [ "data" ] ;
88
+ messageStore . state . data . message_id = message_id ;
89
+ messageStore . state . data . id = storedMessageRecordId ;
90
+ messageStore . state . data . invoked_saga = {
91
+ has_saga : true ,
92
+ saga_id : "saga-id-123" ,
93
+ saga_type : "Shipping.ShipOrderWorkflow" ,
94
+ } ;
74
95
75
96
// Set initial state with sample saga history
76
97
const componentDriver = rendercomponent ( {
77
- message : message ,
78
98
initialState : {
99
+ MessageStore : messageStore ,
79
100
sagaHistory : { sagaHistory : sampleSagaHistory } ,
80
101
} ,
81
102
} ) ;
@@ -86,16 +107,19 @@ describe("Feature: Navigation and Contextual Information", () => {
86
107
87
108
describe ( "Rule: Clearly indicate contextual information like Saga ID and Saga Type." , ( ) => {
88
109
test ( "EXAMPLE: A message with a Saga Id '123' and a Saga Type 'ServiceControl.SmokeTest.AuditingSaga' gets selected" , ( ) => {
89
- const message = { } as Message ;
90
- const invokedSaga = { } as SagaInfo ;
91
- invokedSaga . saga_id = "123" ;
92
- invokedSaga . saga_type = "ServiceControl.SmokeTest.AuditingSaga" ;
93
- message . invoked_sagas = [ invokedSaga ] ;
110
+ const messageStore = { } as MessageStore ;
111
+ messageStore . state = { } as MessageStore [ "state" ] ;
112
+ messageStore . state . data = { } as MessageStore [ "state" ] [ "data" ] ;
113
+ messageStore . state . data . invoked_saga = {
114
+ has_saga : true ,
115
+ saga_id : "123" ,
116
+ saga_type : "ServiceControl.SmokeTest.AuditingSaga" ,
117
+ } ;
94
118
95
119
// Set initial state with sample saga history
96
120
const componentDriver = rendercomponent ( {
97
- message : message ,
98
121
initialState : {
122
+ MessageStore : messageStore ,
99
123
sagaHistory : { sagaHistory : sampleSagaHistory } ,
100
124
} ,
101
125
} ) ;
@@ -120,11 +144,14 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
120
144
121
145
//arragement
122
146
//sampleSagaHistory already not sorted TODO: Make this more clear so the reader of this test doesn't have to go arround and figure out the preconditions
123
- const message = { } as Message ;
124
- const invokedSaga = { } as SagaInfo ;
125
- invokedSaga . saga_id = "123" ;
126
- invokedSaga . saga_type = "ServiceControl.SmokeTest.AuditingSaga" ;
127
- message . invoked_sagas = [ invokedSaga ] ;
147
+ const messageStore = { } as MessageStore ;
148
+ messageStore . state = { } as MessageStore [ "state" ] ;
149
+ messageStore . state . data = { } as MessageStore [ "state" ] [ "data" ] ;
150
+ messageStore . state . data . invoked_saga = {
151
+ has_saga : true ,
152
+ saga_id : "123" ,
153
+ saga_type : "ServiceControl.SmokeTest.AuditingSaga" ,
154
+ } ;
128
155
129
156
// Set the environment to a fixed timezone
130
157
// JSDOM, used by Vitest, defaults to UTC timezone
@@ -152,8 +179,8 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
152
179
153
180
// Set up the store with sample saga history
154
181
const componentDriver = rendercomponent ( {
155
- message : message ,
156
182
initialState : {
183
+ MessageStore : messageStore ,
157
184
sagaHistory : { sagaHistory : sampleSagaHistory } ,
158
185
} ,
159
186
} ) ;
@@ -183,11 +210,14 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
183
210
184
211
//arragement
185
212
//sampleSagaHistory already not sorted TODO: Make this more clear so the reader of this test doesn't have to go arround and figure out the preconditions
186
- const message = { } as Message ;
187
- const invokedSaga = { } as SagaInfo ;
188
- invokedSaga . saga_id = "123" ;
189
- invokedSaga . saga_type = "ServiceControl.SmokeTest.AuditingSaga" ;
190
- message . invoked_sagas = [ invokedSaga ] ;
213
+ const messageStore = { } as MessageStore ;
214
+ messageStore . state = { } as MessageStore [ "state" ] ;
215
+ messageStore . state . data = { } as MessageStore [ "state" ] [ "data" ] ;
216
+ messageStore . state . data . invoked_saga = {
217
+ has_saga : true ,
218
+ saga_id : "123" ,
219
+ saga_type : "ServiceControl.SmokeTest.AuditingSaga" ,
220
+ } ;
191
221
192
222
// Set the environment to a fixed timezone
193
223
// JSDOM, used by Vitest, defaults to PST timezone
@@ -215,8 +245,8 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
215
245
216
246
// Set up the store with sample saga history
217
247
const componentDriver = rendercomponent ( {
218
- message : message ,
219
248
initialState : {
249
+ MessageStore : messageStore ,
220
250
sagaHistory : { sagaHistory : sampleSagaHistory } ,
221
251
} ,
222
252
} ) ;
@@ -241,14 +271,11 @@ describe("Feature: 3 Visual Representation of Saga Timeline", () => {
241
271
} ) ;
242
272
} ) ;
243
273
244
- function rendercomponent ( { message , initialState = { } } : { message : Message ; initialState ?: { sagaHistory ?: { sagaHistory : SagaHistory } } } ) : componentDSL {
274
+ function rendercomponent ( { initialState = { } } : { initialState ?: { MessageStore ?: MessageStore ; sagaHistory ?: { sagaHistory : SagaHistory } } } ) : componentDSL {
245
275
const router = makeRouter ( ) ;
246
276
247
277
// Render with createTestingPinia
248
278
render ( sut , {
249
- props : {
250
- message,
251
- } ,
252
279
global : {
253
280
plugins : [
254
281
router ,
0 commit comments