(page: Page, live_server_url: str)
| 149 | |
| 150 | |
| 151 | def test_chat_nonstreaming(page: Page, live_server_url: str): |
| 152 | # Set up a mock route to the /chat_stream endpoint |
| 153 | def handle(route: Route): |
| 154 | # Read the JSON from our snapshot results and return as the response |
| 155 | f = open("tests/snapshots/test_api_routes/test_advanced_chat_flow/advanced_chat_flow_response.json") |
| 156 | json = f.read() |
| 157 | f.close() |
| 158 | route.fulfill(body=json, status=200) |
| 159 | |
| 160 | page.route("*/**/chat", handle) |
| 161 | |
| 162 | # Check initial page state |
| 163 | page.goto(live_server_url) |
| 164 | expect(page).to_have_title("RAG on PostgreSQL") |
| 165 | expect(page.get_by_role("button", name="Developer settings")).to_be_enabled() |
| 166 | page.get_by_role("button", name="Developer settings").click() |
| 167 | page.get_by_text("Stream chat completion responses").click() |
| 168 | page.locator("button").filter(has_text="Close").click() |
| 169 | |
| 170 | # Ask a question and wait for the message to appear |
| 171 | page.get_by_placeholder("Type a new question (e.g. does my plan cover annual eye exams?)").click() |
| 172 | page.get_by_placeholder("Type a new question (e.g. does my plan cover annual eye exams?)").fill( |
| 173 | "Whats the dental plan?" |
| 174 | ) |
| 175 | page.get_by_label("Ask question button").click() |
| 176 | |
| 177 | expect(page.get_by_text("Whats the dental plan?")).to_be_visible() |
| 178 | expect(page.get_by_text("The capital of France is Paris.")).to_be_visible() |
| 179 | expect(page.get_by_role("button", name="Clear chat")).to_be_enabled() |
nothing calls this directly
no outgoing calls
no test coverage detected