-
Notifications
You must be signed in to change notification settings - Fork 114
tests(sidebar): Add tests for sidebar #1715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
713e688
Add tests for sidebar
karangattu a7160f5
Add more test methods
karangattu c9214ae
Add checks for closed state for both desktop and mobile
karangattu 1ac0182
change name of the test
karangattu 5d7f736
Update CHANGELOG.md
karangattu 6eb7167
Add tests for expect_width()
karangattu 56ddccd
Apply suggestions from code review
schloerke 3bb9eb3
Merge branch 'main' into add-sidebar-kitchensink-tests
schloerke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts(fillable=True) | ||
|
|
||
| with ui.card(): | ||
| with ui.layout_sidebar(): | ||
| with ui.sidebar( | ||
| id="sidebar_left", | ||
| open="desktop", | ||
| title="Left sidebar", | ||
| bg="dodgerBlue", | ||
| class_="text-white", | ||
| gap="20px", | ||
| padding="10px", | ||
| ): | ||
| "Left sidebar content" | ||
|
|
||
| @render.code | ||
| def state_left(): | ||
| return f"input.sidebar_left(): {input.sidebar_left()}" | ||
|
|
||
|
|
||
| with ui.card(): | ||
| with ui.layout_sidebar(): | ||
| with ui.sidebar( | ||
| id="sidebar_right", | ||
| position="right", | ||
| open={"desktop": "closed", "mobile": "open"}, | ||
| padding=["10px", "20px"], | ||
| bg="SlateBlue", | ||
| ): | ||
| "Right sidebar content" | ||
|
|
||
| @render.code | ||
| def state_right(): | ||
| return f"input.sidebar_right(): {input.sidebar_right()}" | ||
|
|
||
|
|
||
| with ui.card(): | ||
| with ui.layout_sidebar(): | ||
| with ui.sidebar( | ||
| id="sidebar_closed", | ||
| open="closed", | ||
| bg="LightCoral", | ||
| padding=["10px", "20px", "30px"], | ||
| ): | ||
| "Closed sidebar content" | ||
|
|
||
| @render.code | ||
| def state_closed(): | ||
| return f"input.sidebar_closed(): {input.sidebar_closed()}" | ||
|
|
||
|
|
||
| with ui.card(): | ||
| with ui.layout_sidebar(): | ||
| with ui.sidebar( | ||
| id="sidebar_always", | ||
| open="always", | ||
| bg="PeachPuff", | ||
| padding=["10px", "20px", "30px", "40px"], | ||
| max_height_mobile="175px", | ||
| ): | ||
| "Always sidebar content" | ||
|
|
||
| @render.code | ||
| def state_always(): | ||
| return f"input.sidebar_always(): {input.sidebar_always()}" |
48 changes: 48 additions & 0 deletions
48
tests/playwright/shiny/inputs/sidebar_kitchensink/test_sidebar_kitchensink.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| from playwright.sync_api import Page | ||
|
|
||
| from shiny.playwright import controller | ||
| from shiny.run import ShinyAppProc | ||
|
|
||
|
|
||
| def test_sidebar_kitchensink(page: Page, local_app: ShinyAppProc) -> None: | ||
| page.goto(local_app.url) | ||
|
|
||
| left_sidebar = controller.Sidebar(page, "sidebar_left") | ||
| output_txt_left = controller.OutputTextVerbatim(page, "state_left") | ||
| left_sidebar.set(True) | ||
| left_sidebar.expect_padding(["10px"]) | ||
| left_sidebar.expect_title("Left sidebar") | ||
| left_sidebar.expect_gap("20px") | ||
| left_sidebar.expect_class("text-white", has_class=True) | ||
| left_sidebar.expect_bg_color("dodgerBlue") | ||
| left_sidebar.expect_desktop_state("open") | ||
| left_sidebar.expect_mobile_state("closed") | ||
| output_txt_left.expect_value("input.sidebar_left(): True") | ||
| left_sidebar.expect_open(True) | ||
| left_sidebar.set(False) | ||
| output_txt_left.expect_value("input.sidebar_left(): False") | ||
| left_sidebar.expect_handle(True) | ||
| left_sidebar.expect_open(False) | ||
| left_sidebar.loc_handle.click() | ||
| left_sidebar.expect_open(True) | ||
| output_txt_left.expect_value("input.sidebar_left(): True") | ||
|
|
||
| right_sidebar = controller.Sidebar(page, "sidebar_right") | ||
| right_sidebar.expect_padding(["10px", "20px"]) | ||
| right_sidebar.expect_bg_color("SlateBlue") | ||
| right_sidebar.expect_mobile_state("open") | ||
| right_sidebar.expect_desktop_state("closed") | ||
|
|
||
| closed_sidebar = controller.Sidebar(page, "sidebar_closed") | ||
| closed_sidebar.expect_padding(["10px", "20px", "30px"]) | ||
| closed_sidebar.expect_bg_color("LightCoral") | ||
| closed_sidebar.expect_mobile_state("closed") | ||
| closed_sidebar.expect_desktop_state("closed") | ||
|
|
||
| always_sidebar = controller.Sidebar(page, "sidebar_always") | ||
| always_sidebar.expect_padding(["10px", "20px", "30px", "40px"]) | ||
| always_sidebar.expect_bg_color("PeachPuff") | ||
| always_sidebar.expect_open(True) | ||
| always_sidebar.expect_desktop_state("always") | ||
| always_sidebar.expect_mobile_state("always") | ||
| always_sidebar.expect_mobile_max_height("175px") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.