@@ -711,6 +711,31 @@ async def test_post_event_to_running_workflow(client: AsyncClient) -> None:
711711 assert result ["result" ] == "received: Hello from test"
712712
713713
714+ @pytest .mark .asyncio
715+ async def test_post_event_simple_schema_to_running_workflow (
716+ client : AsyncClient ,
717+ ) -> None :
718+ # Start an interactive workflow
719+ response = await client .post ("/workflows/interactive/run-nowait" , json = {})
720+ assert response .status_code == 200
721+ handler_id = response .json ()["handler_id" ]
722+
723+ # Wait a bit for workflow to start
724+ await asyncio .sleep (0.1 )
725+
726+ # Send the event
727+ event_str = '{"type": "ExternalEvent", "data": {"response": "Hello from test"}}'
728+ response = await client .post (f"/events/{ handler_id } " , json = {"event" : event_str })
729+ assert response .status_code == 200
730+ assert response .json () == {"status" : "sent" }
731+
732+ result = await wait_for_passing (
733+ lambda : validate_result_response (handler_id , client )
734+ )
735+
736+ assert result ["result" ] == "received: Hello from test"
737+
738+
714739@pytest .mark .asyncio
715740async def test_get_workflow_result_returns_202_when_pending (
716741 client : AsyncClient ,
@@ -787,7 +812,9 @@ async def test_post_event_context_not_available(
787812 client : AsyncClient , server : WorkflowServer
788813) -> None :
789814 # Dumb test for code coverage. Inject a dummy handler with no context to trigger 500 path
790- wrapper = SimpleNamespace (run_handler = SimpleNamespace (done = lambda : False , ctx = None ))
815+ wrapper = SimpleNamespace (
816+ run_handler = SimpleNamespace (done = lambda : False , ctx = None ), workflow_name = "test"
817+ )
791818
792819 handler_id = "noctx-1"
793820 server ._handlers [handler_id ] = wrapper # type: ignore[assignment]
0 commit comments