-
Notifications
You must be signed in to change notification settings - Fork 114
tests(input_select): Add kitchensink tests for input_select and input_selectize #1686
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 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d2fc5aa
Add kitchensink tests for input_select
karangattu 49b63c2
Add tests and methods for input_selectize
karangattu 7945894
check for optgroups
karangattu b471a21
use a mixin for width of select and selectize
karangattu a82efcf
Merge branch 'main' into add-kitchensink-select-tests
karangattu 7224445
remove InputSelectionWidthM and use _InputSelectBase instead
karangattu 14f217e
remove unused function
karangattu a774ec6
use _expect_attribute_to_have_value instead
karangattu b16b8a5
Add comment for in-test function
karangattu 070a437
Rearrange class to Mixin class
schloerke 817063a
Code feedback
schloerke 1bdc012
Add more tests and notes about possible future implementation of `Inp…
schloerke da3926a
Update test_input_select.py
schloerke 12aea16
Review input_selectize given changes in input_select
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
65 changes: 65 additions & 0 deletions
65
tests/playwright/shiny/inputs/input_controls_kitchensink/input_select/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,65 @@ | ||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts(title="Select Inputs Kitchensink") | ||
|
|
||
| fruits = ["Apple", "Banana", "Cherry", "Date", "Elderberry"] | ||
| fruits_dict = { | ||
| "Citrus": { | ||
| "Orange": "Sweet and tangy", | ||
| "Lemon": "Zesty and refreshing", | ||
| "Lime": "Bright and tart", | ||
| }, | ||
| "Berries": { | ||
| "Strawberry": "Juicy and sweet", | ||
| "Blueberry": "Tiny and antioxidant-rich", | ||
| "Raspberry": "Delicate and slightly tart", | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| with ui.card(): | ||
| ui.input_select("basic_select", "Default select", fruits) | ||
|
|
||
| with ui.card(): | ||
| ui.input_select("multi_select", "Multiple Select", fruits, multiple=True) | ||
|
|
||
| with ui.card(): | ||
| ui.input_select( | ||
| "select_with_selected", "Select with selected", fruits, selected="Cherry" | ||
| ) | ||
|
|
||
| with ui.card(): | ||
| ui.input_select("width_select", "Select with Custom Width", fruits, width="400px") | ||
|
|
||
| with ui.card(): | ||
| ui.input_select( | ||
| "select_with_custom_size_and_dict", | ||
| "Select with custom size and dict", | ||
| fruits_dict, | ||
| size="4", | ||
| ) | ||
|
|
||
|
|
||
| @render.text | ||
| def basic_result_txt(): | ||
| return f"Basic select: {input.basic_select()}" | ||
|
|
||
|
|
||
| @render.text | ||
| def multi_result_txt(): | ||
| return f"Multi select: {', '.join(input.multi_select())}" | ||
|
|
||
|
|
||
| @render.text | ||
| def select_with_selected_txt(): | ||
| return f"Select with selected: {input.select_with_selected()}" | ||
|
|
||
|
|
||
| @render.text | ||
| def width_result_txt(): | ||
| return f"Width select: {input.width_select()}" | ||
|
|
||
|
|
||
| @render.text | ||
| def select_with_custom_size_and_dict_txt(): | ||
| return f"Dict and custom select: {input.select_with_custom_size_and_dict()}" |
33 changes: 33 additions & 0 deletions
33
...ght/shiny/inputs/input_controls_kitchensink/input_select/test_input_select_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,33 @@ | ||
| from playwright.sync_api import Page | ||
|
|
||
| from shiny.playwright import controller | ||
| from shiny.run import ShinyAppProc | ||
|
|
||
|
|
||
| def test_input_select_kitchensink(page: Page, local_app: ShinyAppProc) -> None: | ||
| page.goto(local_app.url) | ||
|
|
||
| basic_select = controller.InputSelect(page, "basic_select") | ||
| basic_select_txt = controller.OutputText(page, "basic_result_txt") | ||
| basic_select.expect_label("Default select") | ||
| basic_select_txt.expect_value("Basic select: Apple") | ||
|
|
||
| multiple_select = controller.InputSelect(page, "multi_select") | ||
| multiple_select_txt = controller.OutputText(page, "multi_result_txt") | ||
| multiple_select.set(["Banana", "Cherry"]) | ||
| # multiple_select.expect_multiple(True) # TODO-karan: Investigate why this is failing | ||
| multiple_select_txt.expect_value("Multi select: Banana, Cherry") | ||
|
|
||
| select_with_selected = controller.InputSelect(page, "select_with_selected") | ||
| select_with_selected_txt = controller.OutputText(page, "select_with_selected_txt") | ||
| select_with_selected.expect_selected("Cherry") | ||
| select_with_selected_txt.expect_value("Select with selected: Cherry") | ||
|
|
||
| select_with_width = controller.InputSelect(page, "width_select") | ||
| select_with_width.expect_width("400px") | ||
|
|
||
| select_with_custom_size_and_dict = controller.InputSelect( | ||
| page, "select_with_custom_size_and_dict" | ||
| ) | ||
| select_with_custom_size_and_dict.expect_choice_groups(["Citrus", "Berries"]) | ||
| select_with_custom_size_and_dict.expect_size("4") |
57 changes: 57 additions & 0 deletions
57
tests/playwright/shiny/inputs/input_controls_kitchensink/input_selectize/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,57 @@ | ||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts(title="Selectize Inputs kitchensink") | ||
|
|
||
| fruits = ["Apple", "Banana", "Cherry", "Date", "Elderberry"] | ||
| fruits_dict = { | ||
| "Citrus": { | ||
| "Orange": "Sweet and tangy", | ||
| "Lemon": "Zesty and refreshing", | ||
| "Lime": "Bright and tart", | ||
| }, | ||
| "Berries": { | ||
| "Strawberry": "Juicy and sweet", | ||
| "Blueberry": "Tiny and antioxidant-rich", | ||
| "Raspberry": "Delicate and slightly tart", | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| ui.input_selectize("basic_selectize", "Default selectize", fruits) | ||
|
|
||
|
|
||
| ui.input_selectize("multi_selectize", "Multiple Selectize", fruits, multiple=True) | ||
|
|
||
|
|
||
| ui.input_selectize( | ||
| "selectize_with_selected", "Selectize with selected", fruits, selected="Cherry" | ||
| ) | ||
|
|
||
|
|
||
| ui.input_selectize( | ||
| "selectize_width_close_button", | ||
| "Selectize with Custom Width and remove btn", | ||
| fruits_dict, | ||
| width="400px", | ||
| remove_button=True, | ||
| ) | ||
|
|
||
|
|
||
| @render.text | ||
| def basic_result_txt(): | ||
| return f"Basic select: {input.basic_selectize()}" | ||
|
|
||
|
|
||
| @render.text | ||
| def multi_result_txt(): | ||
| return f"Multi select: {', '.join(input.multi_selectize())}" | ||
|
|
||
|
|
||
| @render.text | ||
| def selected_result_txt(): | ||
| return f"Select with selected: {input.selectize_with_selected()}" | ||
|
|
||
|
|
||
| @render.text | ||
| def selectize_width_close_button_txt(): | ||
| return f"Selectize with close button: {input.selectize_width_close_button()}" |
37 changes: 37 additions & 0 deletions
37
...iny/inputs/input_controls_kitchensink/input_selectize/test_input_selectize_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,37 @@ | ||
| from playwright.sync_api import Page | ||
|
|
||
| from shiny.playwright import controller | ||
| from shiny.run import ShinyAppProc | ||
|
|
||
|
|
||
| def test_input_selectize_kitchensink(page: Page, local_app: ShinyAppProc) -> None: | ||
| page.goto(local_app.url) | ||
|
|
||
| basic_selectize = controller.InputSelectize(page, "basic_selectize") | ||
| basic_select_txt = controller.OutputText(page, "basic_result_txt") | ||
| basic_selectize.expect_label("Default selectize") | ||
| basic_select_txt.expect_value("Basic select: Apple") | ||
|
|
||
| multiple_selectize = controller.InputSelectize(page, "multi_selectize") | ||
| multiple_selectize_txt = controller.OutputText(page, "multi_result_txt") | ||
| multiple_selectize.set(["Banana", "Cherry"]) | ||
| multiple_selectize_txt.expect_value("Multi select: Banana, Cherry") | ||
|
|
||
| selectize_with_selected = controller.InputSelectize(page, "selectize_with_selected") | ||
| selectize_with_selected_txt = controller.OutputText(page, "selected_result_txt") | ||
| selectize_with_selected.expect_selected(["Cherry"]) | ||
| selectize_with_selected_txt.expect_value("Select with selected: Cherry") | ||
|
|
||
| selectize_width_close_button = controller.InputSelectize( | ||
| page, "selectize_width_close_button" | ||
| ) | ||
| selectize_width_close_button_txt = controller.OutputText( | ||
| page, "selectize_width_close_button_txt" | ||
| ) | ||
| selectize_width_close_button_txt.expect_value("Selectize with close button: Orange") | ||
| selectize_width_close_button.expect_width("400px") | ||
| selectize_width_close_button.expect_choice_groups(["Citrus", "Berries"]) | ||
| selectize_width_close_button.clear_selection() | ||
| selectize_width_close_button_txt.expect_value( | ||
| "Selectize with close button: " | ||
| ) # Expecting empty after clear |
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.