@@ -58,7 +58,7 @@ export class InstanceModifier extends RpcTarget {
5858 return sleepNameCountHash ;
5959 }
6060
61- public async disableSleeps ( steps ?: StepSelector [ ] ) : Promise < void > {
61+ async disableSleeps ( steps ?: StepSelector [ ] ) : Promise < void > {
6262 if ( ! steps ) {
6363 console . log ( "[Modifier.disableSleeps()] Disabling all sleeps" ) ;
6464 await this . #state. storage . put ( "disableAllSleeps" , true ) ;
@@ -74,10 +74,7 @@ export class InstanceModifier extends RpcTarget {
7474 }
7575 }
7676
77- public async mockStepResult (
78- step : StepSelector ,
79- stepResult : unknown
80- ) : Promise < void > {
77+ async mockStepResult ( step : StepSelector , stepResult : unknown ) : Promise < void > {
8178 console . log (
8279 "[Modifier.mockStepResult()] Mocking step result of step:" ,
8380 step . name
@@ -86,15 +83,15 @@ export class InstanceModifier extends RpcTarget {
8683 await this . #state. storage . put ( `replace-result-${ valueKey } ` , stepResult ) ;
8784 }
8885
89- public async mockStepImplementation (
86+ async mockStepImplementation (
9087 _step : StepSelector ,
9188 _implementation : ( ) => Promise < unknown >
9289 ) : Promise < void > {
9390 // TODO
9491 // somehow pass the implementation to context so it can race with timeout
9592 }
9693
97- public async mockStepError (
94+ async mockStepError (
9895 step : StepSelector ,
9996 error : Error ,
10097 times ?: number
@@ -119,7 +116,7 @@ export class InstanceModifier extends RpcTarget {
119116 }
120117 }
121118
122- public async forceStepTimeout ( step : StepSelector , times ?: number ) {
119+ async forceStepTimeout ( step : StepSelector , times ?: number ) {
123120 const valueKey = await this . #getStepCacheKey( step ) ;
124121 if ( times ) {
125122 for ( let time = 1 ; time <= times ; time ++ ) {
@@ -132,22 +129,19 @@ export class InstanceModifier extends RpcTarget {
132129 }
133130 }
134131
135- public async mockEvent ( event : UserEvent ) : Promise < void > {
136- // could maybe:
137- // WorkflowInstance.sendEvent()
138- // Engine.receiveEvent()
139- // flag with waitForEventKey
140-
132+ async mockEvent ( event : UserEvent ) : Promise < void > {
141133 const myEvent : Event = {
142134 timestamp : new Date ( ) ,
143135 payload : event . payload ,
144136 type : event . type ,
145137 } ;
146138
139+ await this . #state. storage . put ( `mockEvent-${ event . type } ` , true ) ;
140+
147141 await this . #engine. receiveEvent ( myEvent ) ;
148142 }
149143
150- public async forceEventTimeout ( step : StepSelector ) : Promise < void > {
144+ async forceEventTimeout ( step : StepSelector ) : Promise < void > {
151145 const waitForEventKey = await this . #getWaitForEventCacheKey( step ) ;
152146 await this . #state. storage . put ( `forceEventTimeout-${ waitForEventKey } ` , true ) ;
153147 }
0 commit comments