project-edit.spec.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { test, expect } from "../fixtures"
  2. import { clickMenuItem, openProjectMenu, openSidebar } from "../actions"
  3. test("dialog edit project updates name and startup script", async ({ page, project }) => {
  4. await page.setViewportSize({ width: 1400, height: 800 })
  5. await project.open()
  6. await openSidebar(page)
  7. const open = async () => {
  8. const menu = await openProjectMenu(page, project.slug)
  9. await clickMenuItem(menu, /^Edit$/i, { force: true })
  10. const dialog = page.getByRole("dialog")
  11. await expect(dialog).toBeVisible()
  12. await expect(dialog.getByRole("heading", { level: 2 })).toHaveText("Edit project")
  13. return dialog
  14. }
  15. const name = `e2e project ${Date.now()}`
  16. const startup = `echo e2e_${Date.now()}`
  17. const dialog = await open()
  18. const nameInput = dialog.getByLabel("Name")
  19. await nameInput.fill(name)
  20. const startupInput = dialog.getByLabel("Workspace startup script")
  21. await startupInput.fill(startup)
  22. await dialog.getByRole("button", { name: "Save" }).click()
  23. await expect(dialog).toHaveCount(0)
  24. await expect
  25. .poll(
  26. async () => {
  27. await page.reload()
  28. await openSidebar(page)
  29. const reopened = await open()
  30. const value = await reopened.getByLabel("Name").inputValue()
  31. const next = await reopened.getByLabel("Workspace startup script").inputValue()
  32. await reopened.getByRole("button", { name: "Cancel" }).click()
  33. await expect(reopened).toHaveCount(0)
  34. return `${value}\n${next}`
  35. },
  36. { timeout: 30_000 },
  37. )
  38. .toBe(`${name}\n${startup}`)
  39. })