projects-switch.spec.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { test, expect } from "../fixtures"
  2. import { defocus, createTestProject, seedProjects, cleanupTestProject } from "../actions"
  3. import { projectSwitchSelector } from "../selectors"
  4. import { dirSlug } from "../utils"
  5. test("can switch between projects from sidebar", async ({ page, directory, gotoSession }) => {
  6. await page.setViewportSize({ width: 1400, height: 800 })
  7. const other = await createTestProject()
  8. const otherSlug = dirSlug(other)
  9. await seedProjects(page, { directory, extra: [other] })
  10. try {
  11. await gotoSession()
  12. await defocus(page)
  13. const currentSlug = dirSlug(directory)
  14. const otherButton = page.locator(projectSwitchSelector(otherSlug)).first()
  15. await expect(otherButton).toBeVisible()
  16. await otherButton.click()
  17. await expect(page).toHaveURL(new RegExp(`/${otherSlug}/session`))
  18. const currentButton = page.locator(projectSwitchSelector(currentSlug)).first()
  19. await expect(currentButton).toBeVisible()
  20. await currentButton.click()
  21. await expect(page).toHaveURL(new RegExp(`/${currentSlug}/session`))
  22. } finally {
  23. await cleanupTestProject(other)
  24. }
  25. })