|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from colors import bg_color, fg_color |
| 4 | +from conftest import ShinyAppProc |
| 5 | +from playwright.sync_api import Page, expect |
| 6 | + |
| 7 | + |
| 8 | +def test_colors_are_rgb() -> None: |
| 9 | + assert bg_color.startswith("rgb(") |
| 10 | + assert fg_color.startswith("rgb(") |
| 11 | + |
| 12 | + |
| 13 | +def test_sidebar_bg_colors(page: Page, local_app: ShinyAppProc) -> None: |
| 14 | + page.goto(local_app.url) |
| 15 | + |
| 16 | + main_content = page.locator("#main-content") |
| 17 | + main_sidebar = page.locator("#main-sidebar") |
| 18 | + main_layout = main_sidebar.locator("..") |
| 19 | + |
| 20 | + # x_content = page.locator("#x-content") |
| 21 | + # x_sidebar = page.locator("#x-sidebar") |
| 22 | + # x_layout = x_sidebar.locator("..") |
| 23 | + |
| 24 | + expect(main_layout).to_have_attribute("data-bslib-sidebar-open", "always") |
| 25 | + # expect(x_layout).to_have_attribute("data-bslib-sidebar-open", "always") |
| 26 | + |
| 27 | + expect(main_content).to_have_text("`main` - Main content") |
| 28 | + # expect(x_content).to_have_text("`x` - Main content") |
| 29 | + expect(main_sidebar).to_have_text("`main` - Sidebar content") |
| 30 | + # expect(x_sidebar).to_have_text("`x` - Sidebar content") |
| 31 | + |
| 32 | + # Only works if css file is loaded |
| 33 | + expect(main_sidebar).to_have_css("background-color", bg_color) |
| 34 | + # expect(x_sidebar).to_have_css("background-color", bg_color) |
| 35 | + expect(main_sidebar).to_have_css("color", fg_color) |
| 36 | + # expect(x_sidebar).to_have_css("color", fg_color) |
0 commit comments