( page: Page, text: string, imagePath: string, )
| 32 | } |
| 33 | |
| 34 | export async function sendMessageWithImage( |
| 35 | page: Page, |
| 36 | text: string, |
| 37 | imagePath: string, |
| 38 | ) { |
| 39 | const input = page.getByTestId('chat-input') |
| 40 | const fileInput = page.getByTestId('image-attachment-input') |
| 41 | const userMessages = page.getByTestId('user-message') |
| 42 | |
| 43 | // Attaching the image auto-sends, using the prompt currently in the chat |
| 44 | // input, and the matched aimock fixture keys on the exact user text. A |
| 45 | // *controlled* React input is fragile here under CPU load (CI, parallel |
| 46 | // workers) in two ways: typing char-by-char can drop characters, leaving a |
| 47 | // truncated value like "cribe this image" (which 404s as "No fixture |
| 48 | // matched" → empty `chatStream fatal`); and the attach's onChange can land |
| 49 | // before the typed value is committed, dispatching nothing at all. So drive |
| 50 | // the interaction to its observable outcome — the user bubble rendering — |
| 51 | // retrying both the typing and the attach until the send actually fires with |
| 52 | // the full prompt. A redundant re-attach is harmless: the client ignores a |
| 53 | // second send while the first is still streaming. |
| 54 | await expect(async () => { |
| 55 | await input.click() |
| 56 | await input.fill('') |
| 57 | await input.pressSequentially(text, { delay: 15 }) |
| 58 | // Confirm the full prompt is committed before attaching. |
| 59 | expect(await input.inputValue()).toBe(text) |
| 60 | // Reset the selection so re-attaching the same path re-fires onChange. |
| 61 | await fileInput.setInputFiles([]) |
| 62 | await fileInput.setInputFiles(imagePath) |
| 63 | await expect(userMessages.first()).toBeVisible({ timeout: 2_000 }) |
| 64 | }).toPass({ timeout: 15_000, intervals: [250, 500, 1000] }) |
| 65 | } |
| 66 | |
| 67 | export async function waitForResponse(page: Page, timeout = 15_000) { |
| 68 | try { |
no outgoing calls
no test coverage detected