Skip to content

Commit 10ff4b3

Browse files
authored
tests: add sidebar test (#787)
1 parent 1b79379 commit 10ff4b3

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

tests/e2e/bugs/0666-sidebar/test_sidebar_colors.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
from colors import bg_color, fg_color
44
from conftest import ShinyAppProc
5-
6-
# from controls import Sidebar
5+
from controls import Sidebar
76
from playwright.sync_api import Page, expect
87

98

@@ -29,8 +28,7 @@ def test_sidebar_bg_colors(page: Page, local_app: ShinyAppProc) -> None:
2928
expect(first_sidebar).to_have_css("background-color", bg_color)
3029
expect(first_sidebar).to_have_css("color", fg_color)
3130

32-
# # TODO-karan; Test that sidebar position is left
33-
# s1 = Sidebar(page, "s1")
34-
# s1.expect_position("left")
35-
# s2 = Sidebar(page, "s2")
36-
# s2.expect_position("right")
31+
s1 = Sidebar(page, "s1")
32+
s1.expect_position("left")
33+
s2 = Sidebar(page, "s2")
34+
s2.expect_position("right")

tests/e2e/controls.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,10 +2390,22 @@ def __init__(self, page: Page, id: str) -> None:
23902390
loc_container="div.bslib-sidebar-layout",
23912391
)
23922392
self.loc_handle = self.loc_container.locator("button.collapse-toggle")
2393+
self.loc_position = self.loc.locator("..")
23932394

23942395
def expect_title(self, value: PatternOrStr, *, timeout: Timeout = None) -> None:
23952396
playwright_expect(self.loc).to_have_text(value, timeout=timeout)
23962397

2398+
def expect_position(
2399+
self, position: Literal["left", "right"], *, timeout: Timeout = None
2400+
) -> None:
2401+
is_right_sidebar = position == "right"
2402+
_expect_class_value(
2403+
self.loc_position,
2404+
f"sidebar-{position}",
2405+
is_right_sidebar,
2406+
timeout=timeout,
2407+
)
2408+
23972409
def expect_handle(self, exists: bool, *, timeout: Timeout = None) -> None:
23982410
playwright_expect(self.loc_handle).to_have_count(int(exists), timeout=timeout)
23992411

0 commit comments

Comments
 (0)