-
Couldn't load subscription status.
- Fork 114
tests(input_numeric): Add kitchensink tests for more input components #1705
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 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
424835e
Add tests for more input components
karangattu 68fe5e8
add tests for input_password
karangattu 65994ff
linting issues
karangattu 2d16d7d
Add tests for input_action_button
karangattu 06dc5e3
Add TODO
karangattu 02086b9
add tests for action_link
karangattu c3b3b48
Update function description
karangattu 6f207a6
commenting unused code
karangattu 90b79ca
Add CHANGELOG entries
karangattu fb866e0
add tests to check for icons in action_buttons
karangattu 7791493
Update CHANGELOG.md
karangattu 91da187
Merge branch 'main' into add-kitchensink-tests
schloerke 029d567
Apply suggestions from code review
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
40 changes: 40 additions & 0 deletions
40
tests/playwright/shiny/inputs/input_kitchensink/input_action_button_kitchensink/app.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,40 @@ | ||
| from faicons import icon_svg | ||
|
|
||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts(title="Kitchen Sink: ui.input_action_button()", fillable=True) | ||
|
|
||
| with ui.layout_columns(): | ||
| with ui.card(): | ||
| ui.h3("Default Action Button") | ||
| ui.input_action_button("default", label="Default button") | ||
|
|
||
| @render.code | ||
| def default_txt(): | ||
| return f"Button clicked {input.default()} times" | ||
|
|
||
| with ui.card(): | ||
| ui.h3("With Custom Width") | ||
| ui.input_action_button("width", "Wide button", width="200px") | ||
|
|
||
| @render.code | ||
| def width_txt(): | ||
| return f"Button clicked {input.width()} times" | ||
|
|
||
| with ui.card(): | ||
| ui.h3("With Icon") | ||
| ui.input_action_button( | ||
| "icon", "Button with icon", icon=icon_svg("trash-arrow-up") | ||
| ) | ||
|
|
||
| @render.code | ||
| def icon_txt(): | ||
| return f"Button clicked {input.icon()} times" | ||
|
|
||
| with ui.card(): | ||
| ui.h3("Disabled Button") | ||
| ui.input_action_button("disabled", "Disabled button", disabled=True) | ||
|
|
||
| @render.code | ||
| def disabled_txt(): | ||
| return f"Button clicked {input.disabled()} times" |
22 changes: 22 additions & 0 deletions
22
...input_kitchensink/input_action_button_kitchensink/test_input_action_button_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,22 @@ | ||
| from playwright.sync_api import Page | ||
|
|
||
| from shiny.playwright import controller | ||
| from shiny.run import ShinyAppProc | ||
|
|
||
|
|
||
| def test_input_action_button_kitchen(page: Page, local_app: ShinyAppProc) -> None: | ||
| page.goto(local_app.url) | ||
|
|
||
| default = controller.InputActionButton(page, "default") | ||
| default.expect_label("Default button") | ||
| controller.OutputCode(page, "default_txt").expect_value("Button clicked 0 times") | ||
| default.click() | ||
| controller.OutputCode(page, "default_txt").expect_value("Button clicked 1 times") | ||
|
|
||
| width = controller.InputActionButton(page, "width") | ||
| width.expect_width("200px") | ||
|
|
||
| disabled = controller.InputActionButton(page, "disabled") | ||
| disabled.expect_disabled() | ||
|
|
||
| # TODO-karan: test for icon |
20 changes: 20 additions & 0 deletions
20
tests/playwright/shiny/inputs/input_kitchensink/input_action_link_kitchensink/app.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,20 @@ | ||
| from faicons import icon_svg | ||
|
|
||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts(title="Kitchen Sink: ui.input_action_link()", fillable=True) | ||
|
|
||
| with ui.layout_columns(): | ||
| with ui.card(): | ||
| ui.input_action_link("default", label="Default action link") | ||
|
|
||
| @render.code | ||
| def default_txt(): | ||
| return f"Link clicked {input.default()} times" | ||
|
|
||
| with ui.card(): | ||
| ui.input_action_link("icon", "Link with icon", icon=icon_svg("trash-arrow-up")) | ||
|
|
||
| @render.code | ||
| def icon_txt(): | ||
| return f"Link clicked {input.icon()} times" |
16 changes: 16 additions & 0 deletions
16
...uts/input_kitchensink/input_action_link_kitchensink/test_input_action_link_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,16 @@ | ||
| from playwright.sync_api import Page | ||
|
|
||
| from shiny.playwright import controller | ||
| from shiny.run import ShinyAppProc | ||
|
|
||
|
|
||
| def test_input_action_link_kitchen(page: Page, local_app: ShinyAppProc) -> None: | ||
| page.goto(local_app.url) | ||
|
|
||
| default = controller.InputActionLink(page, "default") | ||
| default.expect_label("Default action link") | ||
| controller.OutputCode(page, "default_txt").expect_value("Link clicked 0 times") | ||
| default.click() | ||
| controller.OutputCode(page, "default_txt").expect_value("Link clicked 1 times") | ||
|
|
||
| # TODO-karan: test for icon |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
tests/playwright/shiny/inputs/input_kitchensink/input_numeric_kitchensink/app.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,38 @@ | ||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts(title="Kitchen Sink: ui.input_numeric()", fillable=True) | ||
|
|
||
| with ui.layout_columns(): | ||
| with ui.card(): | ||
| ui.h3("Default Numeric Input") | ||
| ui.input_numeric("default", label="Default numeric input", value=10) | ||
|
|
||
| @render.code | ||
| def default_txt(): | ||
| return str(input.default()) | ||
|
|
||
| with ui.card(): | ||
| ui.h3("With Min and Max") | ||
| ui.input_numeric("min_max", "Min and Max", min=0, max=100, value=50) | ||
|
|
||
| @render.code | ||
| def min_max_txt(): | ||
| return str(input.min_max()) | ||
|
|
||
|
|
||
| with ui.layout_columns(): | ||
| with ui.card(): | ||
| ui.h3("With Step") | ||
| ui.input_numeric("step", "Step of 0.5", step=0.5, value=2.5) | ||
|
|
||
| @render.code | ||
| def step_txt(): | ||
| return str(input.step()) | ||
|
|
||
| with ui.card(): | ||
| ui.h3("Custom Width") | ||
| ui.input_numeric("width", "Custom width", width="200px", value=15) | ||
|
|
||
| @render.code | ||
| def width_txt(): | ||
| return str(input.width()) |
28 changes: 28 additions & 0 deletions
28
...hiny/inputs/input_kitchensink/input_numeric_kitchensink/test_input_numeric_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,28 @@ | ||
| from playwright.sync_api import Page | ||
|
|
||
| from shiny.playwright import controller | ||
| from shiny.run import ShinyAppProc | ||
|
|
||
|
|
||
| def test_input_numeric_kitchen(page: Page, local_app: ShinyAppProc) -> None: | ||
| page.goto(local_app.url) | ||
|
|
||
| default = controller.InputNumeric(page, "default") | ||
| default.expect_label("Default numeric input") | ||
| default.expect_value("10") | ||
| controller.OutputUi(page, "default_txt").expect.to_have_text("10") | ||
|
|
||
| min_max = controller.InputNumeric(page, "min_max") | ||
| min_max.expect_max("100") | ||
| min_max.expect_min("0") | ||
| min_max.expect_value("50") | ||
| controller.OutputUi(page, "min_max_txt").expect.to_have_text("50") | ||
|
|
||
| step = controller.InputNumeric(page, "step") | ||
| step.expect_step("0.5") | ||
|
|
||
| width = controller.InputNumeric(page, "width") | ||
| width.expect_width("200px") | ||
| width.set("20") | ||
| width.expect_value("20") | ||
| controller.OutputUi(page, "width_txt").expect.to_have_text("20") |
36 changes: 36 additions & 0 deletions
36
tests/playwright/shiny/inputs/input_kitchensink/input_password_kitchensink/app.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,36 @@ | ||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts(title="Kitchen Sink: ui.input_password()", fillable=True) | ||
|
|
||
| with ui.layout_columns(): | ||
| with ui.card(): | ||
| ui.input_password("default", label="Default password input") | ||
|
|
||
| @render.code | ||
| def default_txt(): | ||
| return str(input.default()) | ||
|
|
||
| with ui.card(): | ||
| ui.input_password( | ||
| "placeholder", "With placeholder", placeholder="Enter password" | ||
| ) | ||
|
|
||
| @render.code | ||
| def placeholder_txt(): | ||
| return str(input.placeholder()) | ||
|
|
||
|
|
||
| with ui.layout_columns(): | ||
| with ui.card(): | ||
| ui.input_password("width", "Custom width", width="200px") | ||
|
|
||
| @render.code | ||
| def width_txt(): | ||
| return str(input.width()) | ||
|
|
||
| with ui.card(): | ||
| ui.input_password("value", "With initial value", value="secret123") | ||
|
|
||
| @render.code | ||
| def value_txt(): | ||
| return str(input.value()) |
Oops, something went wrong.
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.