prompt-multiline.spec.ts 755 B

123456789101112131415161718192021222324
  1. import { test, expect } from "../fixtures"
  2. import { promptSelector } from "../selectors"
  3. test("shift+enter inserts a newline without submitting", async ({ page, gotoSession }) => {
  4. await gotoSession()
  5. await expect(page).toHaveURL(/\/session\/?$/)
  6. const prompt = page.locator(promptSelector)
  7. await prompt.focus()
  8. await expect(prompt).toBeFocused()
  9. await prompt.pressSequentially("line one")
  10. await expect(prompt).toBeFocused()
  11. await prompt.press("Shift+Enter")
  12. await expect(page).toHaveURL(/\/session\/?$/)
  13. await expect(prompt).toBeFocused()
  14. await prompt.pressSequentially("line two")
  15. await expect(page).toHaveURL(/\/session\/?$/)
  16. await expect.poll(() => prompt.evaluate((el) => el.innerText)).toBe("line one\nline two")
  17. })