project-edit.spec.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { test, expect } from "../fixtures"
  2. import { openSidebar } from "../actions"
  3. test("dialog edit project updates name and startup script", async ({ page, gotoSession }) => {
  4. await gotoSession()
  5. await page.setViewportSize({ width: 1400, height: 800 })
  6. await openSidebar(page)
  7. const open = async () => {
  8. const header = page.locator(".group\\/project").first()
  9. await header.hover()
  10. const trigger = header.getByRole("button", { name: "More options" }).first()
  11. await expect(trigger).toBeVisible()
  12. await trigger.click({ force: true })
  13. await page.getByRole("menuitem", { name: "Edit" }).click()
  14. const dialog = page.getByRole("dialog")
  15. await expect(dialog).toBeVisible()
  16. await expect(dialog.getByRole("heading", { level: 2 })).toHaveText("Edit project")
  17. return dialog
  18. }
  19. const name = `e2e project ${Date.now()}`
  20. const startup = `echo e2e_${Date.now()}`
  21. const dialog = await open()
  22. const nameInput = dialog.getByLabel("Name")
  23. await nameInput.fill(name)
  24. const startupInput = dialog.getByLabel("Workspace startup script")
  25. await startupInput.fill(startup)
  26. await dialog.getByRole("button", { name: "Save" }).click()
  27. await expect(dialog).toHaveCount(0)
  28. const header = page.locator(".group\\/project").first()
  29. await expect(header).toContainText(name)
  30. const reopened = await open()
  31. await expect(reopened.getByLabel("Name")).toHaveValue(name)
  32. await expect(reopened.getByLabel("Workspace startup script")).toHaveValue(startup)
  33. await reopened.getByRole("button", { name: "Cancel" }).click()
  34. await expect(reopened).toHaveCount(0)
  35. })