| 59 | def test_chat(page: Page, live_server_url: str): |
| 60 | # Set up a mock route to the /chat endpoint with streaming results |
| 61 | def handle(route: Route): |
| 62 | # Read the JSONL from our snapshot results and return as the response |
| 63 | f = open( |
| 64 | "tests/snapshots/test_api_routes/test_advanced_chat_streaming_flow/advanced_chat_streaming_flow_response.jsonlines" |
| 65 | ) |
| 66 | jsonl = f.read() |
| 67 | f.close() |
| 68 | route.fulfill(body=jsonl, status=200, headers={"Transfer-encoding": "Chunked"}) |
| 69 | |
| 70 | page.route("*/**/chat/stream", handle) |
| 71 | |