(page: Page, text: string)
| 13 | } |
| 14 | |
| 15 | export async function sendMessage(page: Page, text: string) { |
| 16 | const input = page.getByTestId('chat-input') |
| 17 | await input.click() |
| 18 | await input.fill(text) |
| 19 | // Dispatch an input event to trigger React's onChange for controlled inputs |
| 20 | await input.dispatchEvent('input', { bubbles: true }) |
| 21 | await page |
| 22 | .getByTestId('send-button') |
| 23 | .click({ timeout: 5000 }) |
| 24 | .catch(async (err) => { |
| 25 | // Only retry if button was disabled (fill() didn't trigger React onChange) |
| 26 | const isDisabled = await page.getByTestId('send-button').isDisabled() |
| 27 | if (!isDisabled) throw err |
| 28 | await input.clear() |
| 29 | await input.pressSequentially(text, { delay: 30 }) |
| 30 | await page.getByTestId('send-button').click() |
| 31 | }) |
| 32 | } |
| 33 | |
| 34 | export async function sendMessageWithImage( |
| 35 | page: Page, |
no test coverage detected