@@ -7,6 +7,16 @@ type BoundTaskFlow = ReturnType<
77 NonNullable < OpenClawPluginApi [ "runtime" ] > [ "taskFlow" ] [ "bindSession" ]
88> ;
99
10+ function expectManagedFlowFailure (
11+ result : Awaited < ReturnType < typeof runManagedLobsterFlow | typeof resumeManagedLobsterFlow > > ,
12+ ) {
13+ expect ( result . ok ) . toBe ( false ) ;
14+ if ( result . ok ) {
15+ throw new Error ( "Expected managed Lobster flow to fail" ) ;
16+ }
17+ return result ;
18+ }
19+
1020function createFakeTaskFlow ( overrides ?: Partial < BoundTaskFlow > ) {
1121 const baseFlow = {
1222 flowId : "flow-1" ,
@@ -160,8 +170,8 @@ describe("runManagedLobsterFlow", () => {
160170 goal : "Run Lobster workflow" ,
161171 } ) ;
162172
163- expect ( result . ok ) . toBe ( false ) ;
164- expect ( result . error . message ) . toBe ( "boom" ) ;
173+ const failure = expectManagedFlowFailure ( result ) ;
174+ expect ( failure . error . message ) . toBe ( "boom" ) ;
165175 expect ( taskFlow . fail ) . toHaveBeenCalledWith ( {
166176 flowId : "flow-1" ,
167177 expectedRevision : 1 ,
@@ -188,8 +198,8 @@ describe("runManagedLobsterFlow", () => {
188198 goal : "Run Lobster workflow" ,
189199 } ) ;
190200
191- expect ( result . ok ) . toBe ( false ) ;
192- expect ( result . error . message ) . toBe ( "crashed" ) ;
201+ const failure = expectManagedFlowFailure ( result ) ;
202+ expect ( failure . error . message ) . toBe ( "crashed" ) ;
193203 expect ( taskFlow . fail ) . toHaveBeenCalledWith ( {
194204 flowId : "flow-1" ,
195205 expectedRevision : 1 ,
@@ -264,8 +274,8 @@ describe("resumeManagedLobsterFlow", () => {
264274 } ,
265275 } ) ;
266276
267- expect ( result . ok ) . toBe ( false ) ;
268- expect ( result . error . message ) . toMatch ( / r e v i s i o n _ c o n f l i c t / ) ;
277+ const failure = expectManagedFlowFailure ( result ) ;
278+ expect ( failure . error . message ) . toMatch ( / r e v i s i o n _ c o n f l i c t / ) ;
269279 expect ( runner . run ) . not . toHaveBeenCalled ( ) ;
270280 } ) ;
271281
0 commit comments