@@ -2970,6 +2970,44 @@ it.effect("a list by tag keeps the runs that did something apart from skipped on
29702970 } ) . pipe ( Effect . provide ( NodeServices . layer ) , Effect . scoped ) ,
29712971) ;
29722972
2973+ it . effect ( "a list by tag shows a run once when it turns skipped between the two reads" , ( ) =>
2974+ Effect . gen ( function * ( ) {
2975+ const skipAfterRead = yield * Ref . make < string | undefined > ( undefined ) ;
2976+ const store = Layer . effect (
2977+ WorkflowStore . WorkflowStore ,
2978+ Effect . gen ( function * ( ) {
2979+ const real = yield * WorkflowStore . make ;
2980+ return WorkflowStore . WorkflowStore . of ( {
2981+ ...real ,
2982+ runsWhere : ( where ) =>
2983+ Effect . tap ( real . runsWhere ( where ) , ( ) =>
2984+ where . skippedTopLevel === false
2985+ ? Effect . flatMap ( Ref . getAndSet ( skipAfterRead , undefined ) , ( runId ) =>
2986+ runId === undefined
2987+ ? Effect . void
2988+ : real . runEnded ( runId , "skipped" , "not applicable" , null ) ,
2989+ )
2990+ : Effect . void ,
2991+ ) ,
2992+ } ) ;
2993+ } ) ,
2994+ ) ;
2995+ const { boot } = yield * harness ( store ) ;
2996+ yield * boot (
2997+ Effect . gen ( function * ( ) {
2998+ const workflows = yield * Workflows . Workflows ;
2999+ const run = yield * workflows . start ( "sorter" , { tags : [ "triage" ] } , { idempotencyKey : "r" } ) ;
3000+ yield * workflows . waitFor ( run . runId , status ( "waiting" ) ) ;
3001+ yield * Ref . set ( skipAfterRead , run . runId ) ;
3002+ assert . deepStrictEqual (
3003+ ( yield * workflows . list ( { tag : "triage" } ) ) . map ( ( listed ) => [ listed . runId , listed . status ] ) ,
3004+ [ [ run . runId , "skipped" ] ] ,
3005+ ) ;
3006+ } ) ,
3007+ ) ;
3008+ } ) . pipe ( Effect . provide ( NodeServices . layer ) , Effect . scoped ) ,
3009+ ) ;
3010+
29733011it ( "tags refuses a list with a gap in it" , ( ) => {
29743012 // The same list `tags([, "pr"])` makes: a first entry that was never set.
29753013 const gapped = new Array < string > ( 2 ) ;
0 commit comments