sidebar-session-links.spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import { test, expect } from "../fixtures"
  2. import { cleanupSession, openSidebar, withSession } from "../actions"
  3. import { promptSelector } from "../selectors"
  4. test("sidebar session links navigate to the selected session", async ({ page, slug, sdk, gotoSession }) => {
  5. const stamp = Date.now()
  6. const one = await sdk.session.create({ title: `e2e sidebar nav 1 ${stamp}` }).then((r) => r.data)
  7. const two = await sdk.session.create({ title: `e2e sidebar nav 2 ${stamp}` }).then((r) => r.data)
  8. if (!one?.id) throw new Error("Session create did not return an id")
  9. if (!two?.id) throw new Error("Session create did not return an id")
  10. try {
  11. await gotoSession(one.id)
  12. await openSidebar(page)
  13. const target = page.locator(`[data-session-id="${two.id}"] a`).first()
  14. await expect(target).toBeVisible()
  15. await target.click()
  16. await expect(page).toHaveURL(new RegExp(`/${slug}/session/${two.id}(?:\\?|#|$)`))
  17. await expect(page.locator(promptSelector)).toBeVisible()
  18. await expect(page.locator(`[data-session-id="${two.id}"] a`).first()).toHaveClass(/\bactive\b/)
  19. } finally {
  20. await cleanupSession({ sdk, sessionID: one.id })
  21. await cleanupSession({ sdk, sessionID: two.id })
  22. }
  23. })