summaryrefslogtreecommitdiffhomepage
path: root/packages/app/e2e/sidebar/sidebar.spec.ts
blob: 5c78c2220d29f7e0a1fcdbccf757e5052a9b4bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { test, expect } from "../fixtures"
import { openSidebar, toggleSidebar, withSession } from "../actions"

test("sidebar can be collapsed and expanded", async ({ page, gotoSession }) => {
  await gotoSession()

  await openSidebar(page)

  await toggleSidebar(page)
  await expect(page.locator("main")).toHaveClass(/xl:border-l/)

  await toggleSidebar(page)
  await expect(page.locator("main")).not.toHaveClass(/xl:border-l/)
})

test("sidebar collapsed state persists across navigation and reload", async ({ page, sdk, gotoSession }) => {
  await withSession(sdk, "sidebar persist session 1", async (session1) => {
    await withSession(sdk, "sidebar persist session 2", async (session2) => {
      await gotoSession(session1.id)

      await openSidebar(page)
      await toggleSidebar(page)
      await expect(page.locator("main")).toHaveClass(/xl:border-l/)

      await gotoSession(session2.id)
      await expect(page.locator("main")).toHaveClass(/xl:border-l/)

      await page.reload()
      await expect(page.locator("main")).toHaveClass(/xl:border-l/)

      const opened = await page.evaluate(
        () => JSON.parse(localStorage.getItem("opencode.global.dat:layout") ?? "{}").sidebar?.opened,
      )
      await expect(opened).toBe(false)
    })
  })
})